├── .gitattributes ├── .github └── workflows │ └── build.yml ├── .gitignore ├── .travis-before_install-xonotic.sh ├── .travis-id_xonotic.enc ├── .travis-script-xonotic.sh ├── .travis.yml ├── BSDmakefile ├── CONTRIBUTING.md ├── COPYING ├── CREDITS.md ├── DPiOS.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Darkplaces.app └── Contents │ ├── Info.plist │ ├── MacOS │ └── darkplaces-osx-sdl │ ├── PkgInfo │ └── Resources │ ├── ._Darkplaces.icns │ ├── Darkplaces.icns │ └── English.lproj │ └── InfoPlist.strings ├── Doxyfile ├── Info.plist ├── README.iOS ├── README.md ├── av_backend_libav.c ├── bih.c ├── bih.h ├── bspfile.h ├── builddate.c ├── cap.h ├── cap_avi.c ├── cap_avi.h ├── cap_ogg.c ├── cap_ogg.h ├── cd_shared.c ├── cdaudio.h ├── cl_cmd.c ├── cl_collision.c ├── cl_collision.h ├── cl_demo.c ├── cl_ents.c ├── cl_ents4.c ├── cl_ents5.c ├── cl_ents_nq.c ├── cl_ents_qw.c ├── cl_input.c ├── cl_main.c ├── cl_parse.c ├── cl_parse.h ├── cl_particles.c ├── cl_particles.h ├── cl_screen.c ├── cl_screen.h ├── cl_video.c ├── cl_video.h ├── cl_video_jamdecode.c ├── cl_video_libavw.c ├── cl_video_libavw.h ├── client.h ├── clprogdefs.h ├── clvm_cmds.c ├── clvm_cmds.h ├── cmd.c ├── cmd.h ├── collision.c ├── collision.h ├── com_crc16.c ├── com_ents.c ├── com_ents4.c ├── com_game.c ├── com_game.h ├── com_infostring.c ├── com_infostring.h ├── com_list.h ├── com_msg.c ├── common.c ├── common.h ├── console.c ├── console.h ├── convex.c ├── convex.h ├── crypto-keygen-standalone-brute.sh ├── crypto-keygen-standalone.c ├── crypto.c ├── crypto.h ├── csprogs.c ├── csprogs.h ├── curves.c ├── curves.h ├── cvar.c ├── cvar.h ├── darkplaces-sdl2-vs2019.vcxproj ├── darkplaces-vs2019.sln ├── darkplaces.h ├── darkplaces.ico ├── darkplaces.rc ├── darkplaces.txt ├── darkplaces.xpm ├── darkplaces16x16.png ├── darkplaces24x24.png ├── darkplaces32x32.png ├── darkplaces48x48.png ├── darkplaces64x64.png ├── darkplaces72x72.png ├── dpdefs ├── README.txt ├── csprogsdefs.qc ├── dpextensions.qc ├── keycodes.qc ├── menudefs.qc ├── progsdefs.qc ├── source_compare.pl └── source_compare.txt ├── dpvsimpledecode.c ├── dpvsimpledecode.h ├── draw.h ├── filematch.c ├── filematch.h ├── fogeval.pl ├── fractalnoise.c ├── fs.c ├── fs.h ├── ft2.c ├── ft2.h ├── ft2_defs.h ├── ft2_fontdefs.h ├── gl_backend.c ├── gl_backend.h ├── gl_draw.c ├── gl_rmain.c ├── gl_rsurf.c ├── gl_textures.c ├── glquake.h ├── hmac.c ├── hmac.h ├── host.c ├── host.h ├── image.c ├── image.h ├── image_png.c ├── image_png.h ├── input.h ├── jpeg.c ├── jpeg.h ├── keys.c ├── keys.h ├── lhfont.h ├── lhnet.c ├── lhnet.h ├── libcurl.c ├── libcurl.h ├── makefile ├── makefile.inc ├── mathlib.c ├── mathlib.h ├── matrixlib.c ├── matrixlib.h ├── mdfour.c ├── mdfour.h ├── menu.c ├── menu.h ├── meshqueue.c ├── meshqueue.h ├── mingw_note.txt ├── mod_skeletal_animatevertices_generic.c ├── mod_skeletal_animatevertices_generic.h ├── mod_skeletal_animatevertices_sse.c ├── mod_skeletal_animatevertices_sse.h ├── model_alias.c ├── model_alias.h ├── model_brush.c ├── model_brush.h ├── model_dpmodel.h ├── model_hlmdl.h ├── model_iqm.h ├── model_psk.h ├── model_q1bsp.h ├── model_q2bsp.h ├── model_q3bsp.h ├── model_shared.c ├── model_shared.h ├── model_sprite.c ├── model_sprite.h ├── model_vbsp.h ├── model_zymotic.h ├── modelgen.h ├── mprogdefs.h ├── mvm_cmds.c ├── netconn.c ├── netconn.h ├── nexuiz.ico ├── nexuiz.rc ├── nexuiz.xpm ├── packages.config ├── palette.c ├── palette.h ├── phys.c ├── phys.h ├── pmove.h ├── polygon.c ├── polygon.h ├── portals.c ├── portals.h ├── pr_comp.h ├── progdefs.h ├── progs.h ├── progsvm.h ├── protocol.c ├── protocol.h ├── prvm_cmds.c ├── prvm_cmds.h ├── prvm_edict.c ├── prvm_exec.c ├── prvm_execprogram.h ├── prvm_offsets.h ├── qdefs.h ├── qstats.h ├── qtypes.h ├── quakedef.h ├── r_explosion.c ├── r_lightning.c ├── r_modules.c ├── r_modules.h ├── r_qshader.h ├── r_shadow.c ├── r_shadow.h ├── r_sky.c ├── r_sprites.c ├── r_stats.c ├── r_stats.h ├── r_textures.h ├── render.h ├── resource.h ├── sbar.c ├── sbar.h ├── screen.h ├── server.h ├── shader_glsl.h ├── snd_main.c ├── snd_main.h ├── snd_mem.c ├── snd_mix.c ├── snd_null.c ├── snd_ogg.c ├── snd_ogg.h ├── snd_sdl.c ├── snd_wav.c ├── snd_wav.h ├── snd_xmp.c ├── snd_xmp.h ├── sound.h ├── spritegn.h ├── sv_ccmds.c ├── sv_demo.c ├── sv_demo.h ├── sv_ents.c ├── sv_ents4.c ├── sv_ents5.c ├── sv_ents_csqc.c ├── sv_ents_nq.c ├── sv_main.c ├── sv_move.c ├── sv_phys.c ├── sv_save.c ├── sv_send.c ├── sv_user.c ├── svbsp.c ├── svbsp.h ├── svn-eol-style-from-gitattributes.sh ├── svvm_cmds.c ├── sys.h ├── sys_null.c ├── sys_sdl.c ├── sys_shared.c ├── sys_wasm.c ├── taskqueue.c ├── taskqueue.h ├── thread.h ├── thread_null.c ├── thread_pthread.c ├── thread_sdl.c ├── thread_win.c ├── timing.h ├── todo ├── utf8lib.c ├── utf8lib.h ├── vid.h ├── vid_null.c ├── vid_sdl.c ├── vid_shared.c ├── view.c ├── view.h ├── vpk.h ├── wad.c ├── wad.h ├── wasm ├── autoexec.cfg ├── index.html ├── pre.js ├── preload │ └── runhere ├── standalone-shell.html └── standaloneprejs.js ├── world.c ├── world.h ├── zone.c └── zone.h /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | # Run on pushes to tags, the "master" branch, and PR's 5 | push: 6 | branches: 7 | - master 8 | pull_request: 9 | 10 | jobs: 11 | sdl-release: 12 | runs-on: ubuntu-latest 13 | container: 14 | image: debian:latest 15 | steps: 16 | # Must install git before checking out the repo otherwise github doesn't fetch the .git directory. 17 | - name: Install dependencies 18 | run: | 19 | apt update 20 | apt install --yes build-essential git libjpeg-dev libsdl2-dev libcurl4-openssl-dev libpng-dev libfreetype-dev libvorbis-dev 21 | 22 | - name: Fetch repository 23 | uses: actions/checkout@v4.1.1 24 | with: 25 | # make `git describe` show the correct commit hash 26 | fetch-depth: '0' 27 | 28 | - name: Compile 29 | run: | 30 | # prevent git complaining about dubious ownership of the repo 31 | chown -R root:root . 32 | # fail if `git describe` doesn't work (required for the buildstring) 33 | git describe --always 34 | # fail if there's any warnings 35 | export CC="cc -Werror" 36 | make sdl-release 37 | 38 | - name: Upload Linux artifacts 39 | uses: actions/upload-artifact@v4 40 | with: 41 | name: Linux 42 | path: | 43 | darkplaces-sdl 44 | 45 | wasm-release: 46 | runs-on: ubuntu-latest 47 | container: 48 | image: debian:latest 49 | steps: 50 | - name: Install dependencies 51 | run: | 52 | apt update 53 | apt install --yes build-essential python3-certifi 54 | 55 | - name: Fetch repository 56 | uses: actions/checkout@v4.1.1 57 | with: 58 | # make `git describe` show the correct commit hash 59 | fetch-depth: '0' 60 | 61 | - name: Install emsdk 62 | uses: actions/checkout@v4.1.1 63 | with: 64 | repository: emscripten-core/emsdk 65 | path: emsdk 66 | 67 | - name: Compile 68 | shell: bash 69 | run: | 70 | cd emsdk 71 | 72 | # Download and install the latest SDK tools. 73 | ./emsdk install latest 74 | 75 | # Make the "latest" SDK "active" for the current user. (writes .emscripten file) 76 | ./emsdk activate latest 77 | 78 | # Activate PATH and other environment variables in the current terminal 79 | source ./emsdk_env.sh 80 | 81 | cd .. 82 | 83 | # fail if there's any warnings 84 | #export CC="cc" 85 | 86 | make emscripten-release 87 | 88 | - name: Upload WASM artifacts 89 | uses: actions/upload-artifact@v4 90 | with: 91 | name: Wasm 92 | path: | 93 | darkplaces-wasm.js 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | *.d 3 | *.o 4 | *.i 5 | *.s 6 | 7 | # MSVC build objects 8 | Debug-darkplaces-sdl2-vs*/ 9 | Release-darkplaces-sdl2-vs*/ 10 | *.obj 11 | *.tlog 12 | # MSVC NuGet packages, VS downloads them automatically. 13 | # Other platforms also provide SDL2 headers rather than storing old ones here. 14 | packages/ 15 | 16 | ChangeLog 17 | darkplaces-agl 18 | darkplaces-glx 19 | darkplaces-sdl 20 | darkplaces-wasm.html 21 | darkplaces-wasm.js 22 | darkplaces-dedicated 23 | gmon.out 24 | *.ncb 25 | *.opt 26 | *.plg 27 | *.exe 28 | darkplaces_private.h 29 | darkplaces_private.rc 30 | Makefile.win 31 | *.dll 32 | *.dylib 33 | *.dSYM 34 | .vscode 35 | *.code-workspace 36 | .ccls-cache 37 | *.gch 38 | /.vs 39 | /build 40 | /.cache 41 | *.kdev4 42 | *.vcxproj.user 43 | *.pdb 44 | *.lib 45 | *.exp 46 | 47 | # emscripten 48 | build-obj/ 49 | emsdk/ 50 | docs/output/ 51 | wasm/preload/* 52 | !wasm/preload/runhere 53 | -------------------------------------------------------------------------------- /.travis-before_install-xonotic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | export USRLOCAL="$PWD"/usrlocal 6 | mkdir "$USRLOCAL" 7 | 8 | for os in "$@"; do 9 | git archive --format=tar --remote=git://de.git.xonotic.org/xonotic/xonotic.git \ 10 | --prefix=".deps/${os}/" master:"misc/builddeps/${os}" | tar xvf - 11 | 12 | case "$os" in 13 | linux32) 14 | wget https://www.libsdl.org/release/SDL2-2.0.10.tar.gz 15 | tar xf SDL2-2.0.10.tar.gz 16 | ( 17 | cd SDL2-2.0.10 18 | export CC="gcc -m32" 19 | i386 ./configure --enable-static --disable-shared --prefix="$USRLOCAL" \ 20 | --enable-video-x11-xinput --enable-video-x11-xrandr ||\ cat config.log 21 | i386 make 22 | i386 make install 23 | ) 24 | ;; 25 | linux64) 26 | wget https://www.libsdl.org/release/SDL2-2.0.10.tar.gz 27 | tar xf SDL2-2.0.10.tar.gz 28 | ( 29 | cd SDL2-2.0.10 30 | ./configure --enable-static --disable-shared --prefix="$USRLOCAL" \ 31 | --enable-video-x11-xinput --enable-video-x11-xrandr ||\ cat config.log 32 | make 33 | make install 34 | ) 35 | ;; 36 | win32) 37 | git archive --format=tar --remote=git://de.git.xonotic.org/xonotic/xonotic.git \ 38 | --prefix=".icons/" master:"misc/logos/icons_ico" | tar xvf - 39 | mv .icons/xonotic.ico darkplaces.ico 40 | ;; 41 | win64) 42 | git archive --format=tar --remote=git://de.git.xonotic.org/xonotic/xonotic.git \ 43 | --prefix=".icons/" master:"misc/logos/icons_ico" | tar xvf - 44 | mv .icons/xonotic.ico darkplaces.ico 45 | ;; 46 | osx) 47 | git archive --format=tar --remote=git://de.git.xonotic.org/xonotic/xonotic.git \ 48 | --prefix=SDL2.framework/ master:misc/buildfiles/osx/Xonotic.app/Contents/Frameworks/SDL2.framework | tar xvf - 49 | ;; 50 | esac 51 | done 52 | 53 | for X in .deps/*; do 54 | rsync --remove-source-files -aL "$X"/*/ "$X"/ || true 55 | done 56 | -------------------------------------------------------------------------------- /.travis-id_xonotic.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DarkPlacesEngine/DarkPlaces/af1e5c03be8e2fd41135f9064ad8e4c4c1ccd8f4/.travis-id_xonotic.enc -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | matrix: 3 | include: 4 | - os: linux 5 | env: PROJECT=xonotic OS="linux32" 6 | compiler: gcc 7 | sudo: false 8 | addons: 9 | apt: 10 | packages: 11 | - libxpm-dev:i386 12 | - libsdl1.2-dev:i386 13 | - libxxf86vm-dev:i386 14 | - gcc-multilib 15 | - g++-multilib 16 | # Workaround packages to install to fix dependency hell. 17 | - libcaca-dev:i386 18 | - libgl1-mesa-dev:i386 19 | - libglib2.0-dev:i386 20 | - libglu1-mesa-dev:i386 21 | - libpng-dev:i386 22 | - libpulse-dev:i386 23 | - libslang2-dev:i386 24 | - libxext-dev:i386 25 | - libxi-dev:i386 26 | - libxrandr-dev:i386 27 | - os: linux 28 | env: PROJECT=xonotic OS="linux64" 29 | compiler: gcc 30 | sudo: false 31 | addons: 32 | apt: 33 | packages: 34 | - libxpm-dev 35 | - libsdl1.2-dev 36 | - libxi-dev 37 | - libxrandr-dev 38 | - libxxf86vm-dev 39 | - os: linux 40 | env: PROJECT=xonotic OS="win32" 41 | compiler: gcc 42 | sudo: false 43 | addons: 44 | apt: 45 | packages: 46 | - gcc-mingw-w64-i686 47 | - binutils-mingw-w64-i686 48 | - os: linux 49 | env: PROJECT=xonotic OS="win64" 50 | compiler: gcc 51 | sudo: false 52 | addons: 53 | apt: 54 | packages: 55 | - gcc-mingw-w64-x86-64 56 | - binutils-mingw-w64-x86-64 57 | - os: osx 58 | env: PROJECT=xonotic OS="osx" 59 | compiler: gcc 60 | before_install: 61 | - "./.travis-before_install-${PROJECT}.sh $OS" 62 | install: 63 | - true 64 | before_script: 65 | - true 66 | script: 67 | - "./.travis-script-${PROJECT}.sh $OS" 68 | after_success: 69 | - true 70 | after_failure: 71 | - true 72 | after_script: 73 | - true 74 | -------------------------------------------------------------------------------- /BSDmakefile: -------------------------------------------------------------------------------- 1 | ##### DP_MAKE_TARGET autodetection and arch specific variables ##### 2 | 3 | .ifndef DP_MAKE_TARGET 4 | 5 | DP_MAKE_TARGET=bsd 6 | 7 | .endif 8 | DP_ARCH != uname 9 | 10 | # Makefile name 11 | MAKEFILE=BSDmakefile 12 | 13 | # Commands 14 | CMD_RM=$(CMD_UNIXRM) 15 | CMD_CP=$(CMD_UNIXCP) 16 | CMD_MKDIR=$(CMD_UNIXMKDIR) 17 | 18 | # default targets 19 | TARGETS_DEBUG=sv-debug sdl-debug 20 | TARGETS_PROFILE=sv-profile sdl-profile 21 | TARGETS_RELEASE=sv-release sdl-release 22 | TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile 23 | TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz 24 | 25 | # Link options 26 | DP_LINK_ZLIB?=shared 27 | DP_LINK_JPEG?=shared 28 | DP_LINK_ODE?= 29 | DP_LINK_CRYPTO?=dlopen 30 | DP_LINK_CRYPTO_RIJNDAEL?=dlopen 31 | DP_LINK_XMP?=dlopen 32 | 33 | ###### Optional features ##### 34 | DP_VIDEO_CAPTURE?=enabled 35 | .if $(DP_VIDEO_CAPTURE) == "enabled" 36 | CFLAGS_VIDEO_CAPTURE=-DCONFIG_VIDEO_CAPTURE 37 | OBJ_VIDEO_CAPTURE=cap_avi.o cap_ogg.o 38 | .else 39 | CFLAGS_VIDEO_CAPTURE= 40 | OBJ_VIDEO_CAPTURE= 41 | .endif 42 | 43 | # X11 libs 44 | UNIX_X11LIBPATH=/usr/X11R6/lib 45 | 46 | # BSD configuration 47 | .if $(DP_MAKE_TARGET) == "bsd" 48 | 49 | # FreeBSD uses OSS 50 | .if $(DP_ARCH) == "FreeBSD" 51 | DEFAULT_SNDAPI=OSS 52 | .else 53 | DEFAULT_SNDAPI=BSD 54 | .endif 55 | 56 | OBJ_ICON= 57 | OBJ_ICON_NEXUIZ= 58 | 59 | LDFLAGS_SV=$(LDFLAGS_BSDSV) 60 | LDFLAGS_SDL=$(LDFLAGS_BSDSDL) 61 | 62 | SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11) 63 | SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11) 64 | SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11) 65 | 66 | EXE_SV=$(EXE_UNIXSV) 67 | EXE_SDL=$(EXE_UNIXSDL) 68 | EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ) 69 | EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ) 70 | 71 | # set these to "" if you want to use dynamic loading instead 72 | # zlib 73 | .if $(DP_LINK_ZLIB) == "shared" 74 | CFLAGS_LIBZ=-DLINK_TO_ZLIB 75 | LIB_Z=-lz 76 | .else 77 | CFLAGS_LIBZ= 78 | LIB_Z= 79 | .endif 80 | 81 | # jpeg 82 | .if $(DP_LINK_JPEG) == "shared" 83 | CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG 84 | LIB_JPEG=-ljpeg 85 | .else 86 | CFLAGS_LIBJPEG= 87 | LIB_JPEG= 88 | .endif 89 | 90 | # ode 91 | .if $(DP_LINK_ODE) == "shared" 92 | ODE_CONFIG?=ode-config 93 | LIB_ODE=`$(ODE_CONFIG) --libs` 94 | CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE 95 | .else 96 | LIB_ODE= 97 | CFLAGS_ODE=-DUSEODE 98 | .endif 99 | 100 | # d0_blind_id 101 | .if $(DP_LINK_CRYPTO) == "shared" 102 | LIB_CRYPTO=-ld0_blind_id 103 | CFLAGS_CRYPTO=-DLINK_TO_CRYPTO 104 | .else 105 | LIB_CRYPTO= 106 | CFLAGS_CRYPTO= 107 | .endif 108 | .if $(DP_LINK_CRYPTO_RIJNDAEL) == "shared" 109 | LIB_CRYPTO_RIJNDAEL=-ld0_rijndael 110 | CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL 111 | .else 112 | LIB_CRYPTO_RIJNDAEL= 113 | CFLAGS_CRYPTO_RIJNDAEL= 114 | .endif 115 | 116 | # xmp 117 | .if $(DP_LINK_XMP) == "shared" 118 | OBJ_SND_XMP=snd_xmp.o 119 | LIB_SND_XMP=-lxmp 120 | CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP 121 | .else 122 | OBJ_SND_XMP=snd_xmp.o 123 | LIB_SND_XMP= 124 | CFLAGS_SND_XMP=-DUSEXMP 125 | .endif 126 | 127 | .endif 128 | 129 | 130 | ##### Extra CFLAGS ##### 131 | 132 | CFLAGS_MAKEDEP=-MD 133 | .ifdef DP_FS_BASEDIR 134 | CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"' 135 | .else 136 | CFLAGS_FS= 137 | .endif 138 | 139 | CFLAGS_PRELOAD= 140 | .ifdef DP_PRELOAD_DEPENDENCIES 141 | LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD) 142 | LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD) 143 | CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD) 144 | .endif 145 | 146 | CFLAGS_NET= 147 | # Systems without IPv6 support should uncomment this: 148 | #CFLAGS_NET+=-DNOSUPPORTIPV6 149 | 150 | ##### BSD Make specific definitions ##### 151 | 152 | MAKE:=$(MAKE) -f BSDmakefile 153 | 154 | DO_LD=$(CC) -o ../../../$@ $> $(LDFLAGS) 155 | 156 | 157 | ##### Definitions shared by all makefiles ##### 158 | .include "makefile.inc" 159 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # DarkPlaces Contributing Guidelines 2 | ------------------------------------------------------------------------------- 3 | 4 | 1. ### Do not break Quake or its mods, and any other game using the engine. 5 | 6 | The engine has known compatibility issues with Quake and many community 7 | mods. All code must not make the situation worse. This is analogous to the policy 8 | of the Linux kernel to not break userspace. 9 | 10 | 2. ### Sign off all of your commits if they are to be included upstream. 11 | 12 | You must use a valid, permanent email address. 13 | 14 | 2. ### All code submitted should follow the Allman style for the most part. 15 | 16 | 1. In statements, the curly brace should be placed on the next line at the 17 | same indentation level as the statement. If the statement only involves 18 | a single line, do not use curly braces. 19 | 20 | ```c 21 | // Example: 22 | if(foo == 1) 23 | { 24 | Do_Something(); 25 | Do_Something_Else(); 26 | } 27 | else 28 | Do_Something_Else_Else(); 29 | 30 | if(bar == 1) 31 | Do_Something_Else_Else_Else(); 32 | ``` 33 | 34 | 2. Use tabs for indentation. 35 | 36 | Use spaces subsequently for alignment of the 37 | parameters of multi-line function calls or declarations, or statements. 38 | 39 | ```c 40 | // Example: 41 | if(very_long_statement && 42 | very_long_statement_aligned && 43 | foo) 44 | { 45 | if(indented) 46 | { 47 | Do_Something(); 48 | Do_Something_Else(); 49 | } 50 | } 51 | ``` 52 | 53 | 3. If possible, try to keep individual lines of code less than 100 54 | characters. 55 | 56 | 4. Pointer operators should be placed on the right-hand side. 57 | 58 | ```c 59 | int foo = 1; 60 | int *bar = &foo; 61 | ``` 62 | 63 | 5. Type casts should have a space between the type and the pointer. 64 | 65 | ```c 66 | int *foo = (int *)malloc(5); 67 | ``` 68 | 69 | 6. Use spaces after each comma when listing parameters or variables of a 70 | struct. 71 | 72 | 7. Multi-line comments should be formatted like so: 73 | 74 | ```c 75 | /* 76 | * This is a multi-line comment. 77 | * Sometimes, I dream about cheese. 78 | */ 79 | ``` 80 | 81 | But this is okay too: 82 | 83 | ```c 84 | /* This is another multi-line comment. 85 | * Hiya! How are you? 86 | */ 87 | ``` 88 | 89 | 8. If following these guidelines in any manner would make any code less 90 | readable or harder to follow, ***ignore them***. This section is only 91 | guidelines, not rules. We're not gonna beat you over the head in pull 92 | requests because you misplaced a dereference operator. 93 | 94 | For example, in some situations, placing the block on the same line as 95 | the condition would be okay because it looks cleaner: 96 | 97 | ```c 98 | if (foo) Do_Something(); 99 | if (bar) Do_Something_Else(); 100 | if (far) near(); 101 | if (boo) AHH("!!!\n"); 102 | ``` 103 | 104 | 4. DarkPlaces is written in the common subset of C and C++. This means it is 105 | (usually) both valid C and C++. We historically wanted to keep it that way, 106 | but don't worry about it unless you care enough and/or are a maintainer. 107 | 108 | Most of the differences are caught by `-Wc++-compat` but some are subtle 109 | and would cause behavior differences between the two compilers, or are not 110 | caught by that warning. The things to look out for are: 111 | 112 | 1. Character constants are `int`-sized in C but `char`-sized in C++. This 113 | means `sizeof('a')` will be 4 in C, but 1 in C++. 114 | 115 | 2. `goto label;` cannot jump over a variable initialization. This will 116 | cause a compiler error as C++ but is not caught by `-Wc++-compat`. 117 | This is nevertheless bad code, so avoid this anyway. 118 | 119 | If, for some reason, you care enough, compatibility can always be tested 120 | affirmatively by setting CC=g++. CC=clang++ may not work in the future, if 121 | it didn't already stop working in current versions of LLVM, as it otherwise 122 | spams deprecation warnings for using a C file as input to a C++ compiler. 123 | 124 | > [!NOTE] 125 | > We do not officially support building C code with a C++ compiler and may not 126 | > address issue reports for buggy behavior that does not occur when compiled 127 | > with a C compiler. That said, there have been fleeting ideas for converting 128 | > either the entire engine or parts of it to C++, which is what `-Wc++-compat` 129 | > would make a little easier. So, we at least *do not discourage* such issue 130 | > reports, especially for things the warning doesn't catch. They will be noted 131 | > as they would become relevant in the event we do decide to convert to C++. -------------------------------------------------------------------------------- /CREDITS.md: -------------------------------------------------------------------------------- 1 | Credits 2 | =============================================================================== 3 | 4 | Sorted by alphanumeric order by last name, and pseudonym if not available. Active contributors are in bold. 5 | 6 | **Quake 1 engine** 7 | ------------------------------------------------------------------------------- 8 | 9 | * **id Software** 10 | * Michael Abrash 11 | * John Carmack 12 | * John Cash 13 | 14 | **DarkPlaces Engine** 15 | ------------------------------------------------------------------------------- 16 | 17 | * **Project Leader** 18 | * **Ashley Rose Hale (LadyHavoc)** 19 | 20 | * **Core Developers/Maintainers** 21 | * **Ashley Rose Hale (LadyHavoc)** 22 | * **David Knapp (Cloudwalk)** 23 | * **Rudolf Polzer (divVerent)** 24 | 25 | * **Major Contributors** 26 | * [515] 27 | * Blub\0 28 | * eihrul 29 | * Zephaniah Hull (Mercury) 30 | * Andreas Kirsch (BlackHC) 31 | * Mathieu Olivier (Elric) 32 | * Dale Weiler (graphitemaster) 33 | 34 | * **Contributors** 35 | * Akari 36 | * **bones_was_here** 37 | * Matthias Buecher (Maddes) 38 | * Thomas Joseph Carter (knghtbrd) 39 | * coderjo 40 | * Diablo-D3 41 | * EvilTypeGuy 42 | * fleeky 43 | * GreEn`mArine 44 | * **Terence Hill (terencehill)** 45 | * incognico 46 | * Tomas Jakobsson (Tomaz) 47 | * KillPixel 48 | * KrimZon 49 | * kristus 50 | * (R.I.P.) Christopher Robert Lais (zinx) 51 | * MarioSMB 52 | * Patrick McKeever (Dresk) 53 | * Chris Page 54 | * parasti 55 | * Marko Permanto (Urre/ImUnreal) 56 | * Qantourisc 57 | * Res2k 58 | * Sajt 59 | * Samual 60 | * taniwha 61 | * TimePath 62 | * tZork 63 | * VorteX 64 | * David Walton (Spoike) 65 | * Alexander Zubov (motorsep) 66 | 67 | **In Memory Of** 68 | ------------------------------------------------------------------------------- 69 | * [Christopher Robert Lais (zinx)](http://obits.al.com/obituaries/birmingham/obituary.aspx?n=christopher-robert-lais&pid=186080667) -------------------------------------------------------------------------------- /DPiOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Darkplaces.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | darkplaces-osx-sdl 9 | CFBundleIconFile 10 | Darkplaces 11 | CFBundlePackageType 12 | APPL 13 | CFBundleSignature 14 | ???? 15 | CFBundleVersion 16 | 1.0 17 | LSApplicationCategoryType 18 | public.app-category.action-games 19 | LSMinimumSystemVersion 20 | 10.4.0 21 | LSMinimumSystemVersionByArchitecture 22 | 23 | x86_64 24 | 10.6.0 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Darkplaces.app/Contents/MacOS/darkplaces-osx-sdl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Get dylib files from the same dir as the executable 4 | export DYLD_LIBRARY_PATH="${0%/*}" 5 | 6 | set -- "$0"-bin "$@" 7 | 8 | exec "$@" 9 | -------------------------------------------------------------------------------- /Darkplaces.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /Darkplaces.app/Contents/Resources/._Darkplaces.icns: -------------------------------------------------------------------------------- 1 | Mac OS X  2 R -------------------------------------------------------------------------------- /Darkplaces.app/Contents/Resources/Darkplaces.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DarkPlacesEngine/DarkPlaces/af1e5c03be8e2fd41135f9064ad8e4c4c1ccd8f4/Darkplaces.app/Contents/Resources/Darkplaces.icns -------------------------------------------------------------------------------- /Darkplaces.app/Contents/Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DarkPlacesEngine/DarkPlaces/af1e5c03be8e2fd41135f9064ad8e4c4c1ccd8f4/Darkplaces.app/Contents/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | darkplaces64x64 13 | CFBundleIdentifier 14 | com.ghdigital.${PRODUCT_NAME:identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationLandscapeLeft 32 | UIInterfaceOrientationPortraitUpsideDown 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationPortrait 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /README.iOS: -------------------------------------------------------------------------------- 1 | To build DarkPlaces for iOS, you need to extract this zip into the source folder: 2 | http://ghdigital.com/~havoc/SDLiOS20110208.zip 3 | 4 | This is built from the in-development version of SDL 1.3, to make an updated include folder and libSDL*.a files, you need to get the SDL 1.3 source (from hg or a nightly build or whatever), then simply open Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj and build libSDL for both simulator and device and then the SDL Application xcode template. 5 | 6 | Then copy the include folder and two libSDL*.a files from the Xcode-iPhoneOS/SDL/build/Debug-template (or Release-template) into the darkplaces source folder, and it will build with your updated files. 7 | -------------------------------------------------------------------------------- /bih.h: -------------------------------------------------------------------------------- 1 | 2 | // This code written in 2010 by Ashley Rose Hale (LadyHavoc) (darkplacesengine gmail com), and placed into public domain. 3 | 4 | // Based on information in http://zach.in.tu-clausthal.de/papers/vrst02.html (in particular vrst02_boxtree.pdf) 5 | 6 | #ifndef BIH_H 7 | #define BIH_H 8 | 9 | #define BIH_MAXUNORDEREDCHILDREN 8 10 | 11 | typedef enum biherror_e 12 | { 13 | BIHERROR_OK, // no error, be happy 14 | BIHERROR_OUT_OF_NODES // could not produce complete hierarchy, maxnodes too low (should be roughly half of numleafs) 15 | } 16 | biherror_t; 17 | 18 | typedef enum bih_nodetype_e 19 | { 20 | BIH_SPLITX = 0, 21 | BIH_SPLITY = 1, 22 | BIH_SPLITZ = 2, 23 | BIH_UNORDERED = 3, 24 | } 25 | bih_nodetype_t; 26 | 27 | typedef enum bih_leaftype_e 28 | { 29 | BIH_BRUSH = 4, 30 | BIH_COLLISIONTRIANGLE = 5, 31 | BIH_RENDERTRIANGLE = 6 32 | } 33 | bih_leaftype_t; 34 | 35 | typedef struct bih_node_s 36 | { 37 | bih_nodetype_t type; // = BIH_SPLITX and similar values 38 | // TODO: store just one float for distance, and have BIH_SPLITMINX and BIH_SPLITMAXX distinctions, to reduce memory footprint and traversal time, as described in the paper (vrst02_boxtree.pdf) 39 | // TODO: move bounds data to parent node and remove it from leafs? 40 | float mins[3]; 41 | float maxs[3]; 42 | union { 43 | struct{ 44 | // node indexes of children (always > this node's index) 45 | int front; 46 | int back; 47 | // interval of children 48 | float frontmin; // children[0] 49 | float backmax; // children[1] 50 | }; 51 | // BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list 52 | int children[BIH_MAXUNORDEREDCHILDREN]; 53 | }; 54 | } 55 | bih_node_t; 56 | 57 | typedef struct bih_leaf_s 58 | { 59 | bih_leaftype_t type; // = BIH_BRUSH And similar values 60 | float mins[3]; 61 | float maxs[3]; 62 | // data past this point is generic and entirely up to the caller... 63 | int textureindex; 64 | int surfaceindex; 65 | int itemindex; // triangle or brush index 66 | } 67 | bih_leaf_t; 68 | 69 | typedef struct bih_s 70 | { 71 | // permanent fields 72 | // leafs are constructed by caller before calling BIH_Build 73 | int numleafs; 74 | bih_leaf_t *leafs; 75 | // nodes are constructed by BIH_Build 76 | int numnodes; 77 | bih_node_t *nodes; 78 | int rootnode; // 0 if numnodes > 0, -1 otherwise 79 | // bounds calculated by BIH_Build 80 | float mins[3]; 81 | float maxs[3]; 82 | 83 | // fields used only during BIH_Build: 84 | int maxnodes; 85 | int error; // set to a value if an error occurs in building (such as numnodes == maxnodes) 86 | int *leafsort; 87 | int *leafsortscratch; 88 | } 89 | bih_t; 90 | 91 | int BIH_Build(bih_t *bih, int numleafs, bih_leaf_t *leafs, int maxnodes, bih_node_t *nodes, int *temp_leafsort, int *temp_leafsortscratch); 92 | 93 | int BIH_GetTriangleListForBox(const bih_t *bih, int maxtriangles, int *trianglelist_idx, int *trianglelist_surf, const float *mins, const float *maxs); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /builddate.c: -------------------------------------------------------------------------------- 1 | #define STRINGIFY2(arg) #arg 2 | #define STRINGIFY(arg) STRINGIFY2(arg) 3 | 4 | extern const char *buildstring; 5 | const char *buildstring = 6 | #ifdef VCREVISION 7 | STRINGIFY(VCREVISION) 8 | #else 9 | "-" 10 | #endif 11 | #ifndef NO_BUILD_TIMESTAMPS 12 | // " " __TIME__ 13 | " " __DATE__ 14 | #endif 15 | #ifdef BUILDTYPE 16 | " " STRINGIFY(BUILDTYPE) 17 | #endif 18 | #ifdef __clang__ // must be first because clang pretends to be GCC 4.2... 19 | " Clang " 20 | // STRINGIFY(__clang_major__) 21 | // "." 22 | // STRINGIFY(__clang_minor__) 23 | #elif defined(__GNUC__) 24 | " GCC " 25 | // STRINGIFY(__GNUC__) 26 | // "." 27 | // STRINGIFY(__GNUC_MINOR__) 28 | #elif defined(_MSC_VER) 29 | " MSC " 30 | // STRINGIFY(_MSC_VER) 31 | #endif 32 | ; 33 | -------------------------------------------------------------------------------- /cap.h: -------------------------------------------------------------------------------- 1 | #ifndef CAP_H 2 | #define CAP_H 3 | 4 | #ifdef CONFIG_VIDEO_CAPTURE 5 | 6 | #include "qtypes.h" 7 | #include "qdefs.h" 8 | #include "fs.h" 9 | #include "snd_main.h" 10 | #include "glquake.h" 11 | 12 | typedef enum capturevideoformat_e 13 | { 14 | CAPTUREVIDEOFORMAT_AVI_I420, 15 | CAPTUREVIDEOFORMAT_OGG_VORBIS_THEORA 16 | } 17 | capturevideoformat_t; 18 | 19 | typedef struct capturevideostate_s 20 | { 21 | double startrealtime; 22 | double framerate; 23 | int framestep; 24 | int framestepframe; 25 | qbool active; 26 | qbool realtime; 27 | qbool error; 28 | int soundrate; 29 | int soundchannels; 30 | int frame; 31 | double starttime; 32 | double lastfpstime; 33 | int lastfpsframe; 34 | int soundsampleframe; 35 | unsigned char *outbuffer; 36 | char basename[MAX_QPATH]; 37 | int width, height; 38 | 39 | // precomputed RGB to YUV tables 40 | // converts the RGB values to YUV (see cap_avi.c for how to use them) 41 | short rgbtoyuvscaletable[3][3][256]; 42 | unsigned char yuvnormalizetable[3][256]; 43 | 44 | // precomputed gamma ramp (only needed if the capturevideo module uses RGB output) 45 | // note: to map from these values to RGB24, you have to multiply by 255.0/65535.0, then add 0.5, then cast to integer 46 | unsigned short vidramp[256 * 3]; 47 | 48 | // stuff to be filled in by the video format module 49 | capturevideoformat_t format; 50 | const char *formatextension; 51 | qfile_t *videofile; 52 | // always use this: 53 | // cls.capturevideo.videofile = FS_OpenRealFile(va(vabuf, sizeof(vabuf), "%s.%s", cls.capturevideo.basename, cls.capturevideo.formatextension), "wb", false); 54 | void (*writeEndVideo) (void); 55 | void (*writeVideoFrame) (int num, u8 *in); 56 | void (*writeSoundFrame) (const portable_sampleframe_t *paintbuffer, size_t length); 57 | 58 | // format specific data 59 | void *formatspecific; 60 | 61 | // GL backend 62 | #define PBO_COUNT 3 // bones_was_here: slightly faster than double buffering 63 | GLuint PBOs[PBO_COUNT]; 64 | GLuint PBOindex; 65 | GLuint FBO; 66 | GLuint FBOtex; 67 | } 68 | capturevideostate_t; 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /cap_avi.h: -------------------------------------------------------------------------------- 1 | void SCR_CaptureVideo_Avi_BeginVideo(void); 2 | -------------------------------------------------------------------------------- /cap_ogg.h: -------------------------------------------------------------------------------- 1 | #include "qtypes.h" 2 | 3 | void SCR_CaptureVideo_Ogg_Init(void); 4 | qbool SCR_CaptureVideo_Ogg_Available(void); 5 | void SCR_CaptureVideo_Ogg_BeginVideo(void); 6 | void SCR_CaptureVideo_Ogg_CloseDLL(void); 7 | -------------------------------------------------------------------------------- /cdaudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #include "qtypes.h" 22 | #include "cvar.h" 23 | 24 | extern cvar_t cdaudioinitialized; 25 | 26 | int CDAudio_Init(void); 27 | void CDAudio_Play(int track, qbool looping); 28 | void CDAudio_Stop(void); 29 | void CDAudio_Pause(void); 30 | void CDAudio_Resume(void); 31 | int CDAudio_Startup(void); 32 | void CDAudio_Shutdown(void); 33 | void CDAudio_Update(void); 34 | float CDAudio_GetPosition(void); 35 | -------------------------------------------------------------------------------- /cl_collision.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CL_COLLISION_H 3 | #define CL_COLLISION_H 4 | 5 | float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int *hitent, entity_render_t *ignoreent); 6 | void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius); 7 | 8 | model_t *CL_GetModelByIndex(int modelindex); 9 | model_t *CL_GetModelFromEdict(prvm_edict_t *ed); 10 | 11 | void CL_LinkEdict(prvm_edict_t *ent); 12 | int CL_GenericHitSuperContentsMask(const prvm_edict_t *edict); 13 | trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities); 14 | trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces); 15 | trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities); 16 | trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int type, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask); 17 | #define CL_PointSuperContents(point) (CL_TracePoint((point), sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL, 0, 0, 0, true, false, NULL, false).startsupercontents) 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /cl_parse.h: -------------------------------------------------------------------------------- 1 | #ifndef CL_PARSE_H 2 | #define CL_PARSE_H 3 | 4 | #include "qtypes.h" 5 | #include "cvar.h" 6 | 7 | extern cvar_t qport; 8 | 9 | void CL_Parse_Init(void); 10 | void CL_Parse_Shutdown(void); 11 | void CL_ParseServerMessage(void); 12 | void CL_Parse_DumpPacket(void); 13 | void CL_Parse_ErrorCleanUp(void); 14 | void QW_CL_StartUpload(unsigned char *data, int size); 15 | void CL_KeepaliveMessage(qbool readmessages); // call this during loading of large content 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cl_screen.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CL_SCREEN_H 3 | #define CL_SCREEN_H 4 | 5 | #include "qtypes.h" 6 | 7 | void SHOWLMP_decodehide(void); 8 | void SHOWLMP_decodeshow(void); 9 | void SHOWLMP_drawall(void); 10 | 11 | extern struct cvar_s vid_conwidth; 12 | extern struct cvar_s vid_conheight; 13 | extern struct cvar_s vid_pixelheight; 14 | extern struct cvar_s scr_screenshot_jpeg; 15 | extern struct cvar_s scr_screenshot_jpeg_quality; 16 | extern struct cvar_s scr_screenshot_png; 17 | extern struct cvar_s scr_screenshot_gammaboost; 18 | extern struct cvar_s scr_screenshot_name; 19 | 20 | extern char cl_connect_status[MAX_QPATH]; 21 | 22 | void CL_Screen_NewMap(void); 23 | void CL_Screen_Init(void); 24 | void CL_Screen_Shutdown(void); 25 | void CL_UpdateScreen(void); 26 | 27 | qbool R_Stereo_Active(void); 28 | qbool R_Stereo_ColorMasking(void); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /cl_video.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CL_VIDEO_H 3 | #define CL_VIDEO_H 4 | 5 | #include "qtypes.h" 6 | #include "qdefs.h" 7 | 8 | #define CLVIDEOPREFIX "video/" 9 | #define CLTHRESHOLD 2.0 10 | 11 | #define MENUOWNER 1 12 | 13 | typedef enum clvideostate_e 14 | { 15 | CLVIDEO_UNUSED, 16 | CLVIDEO_PLAY, 17 | CLVIDEO_LOOP, 18 | CLVIDEO_PAUSE, 19 | CLVIDEO_FIRSTFRAME, 20 | CLVIDEO_RESETONWAKEUP, 21 | CLVIDEO_STATECOUNT 22 | } clvideostate_t; 23 | 24 | #define CLVIDEO_MAX_SUBTITLES 512 25 | 26 | extern struct cvar_s cl_video_subtitles; 27 | extern struct cvar_s cl_video_subtitles_lines; 28 | extern struct cvar_s cl_video_subtitles_textsize; 29 | extern struct cvar_s cl_video_scale; 30 | extern struct cvar_s cl_video_scale_vpos; 31 | extern struct cvar_s cl_video_stipple; 32 | extern struct cvar_s cl_video_brightness; 33 | extern struct cvar_s cl_video_keepaspectratio; 34 | 35 | typedef struct clvideo_s 36 | { 37 | int ownertag; 38 | clvideostate_t state; 39 | 40 | // private stuff 41 | void *stream; 42 | 43 | double starttime; 44 | int framenum; 45 | double framerate; 46 | 47 | void *imagedata; 48 | 49 | // cachepic holds the relevant texture_t and we simply update the texture as needed 50 | struct cachepic_s *cachepic; 51 | char name[MAX_QPATH]; // name of this video UI element (not the filename) 52 | int width; 53 | int height; 54 | 55 | // VorteX: subtitles array 56 | int subtitles; 57 | char *subtitle_text[CLVIDEO_MAX_SUBTITLES]; 58 | float subtitle_start[CLVIDEO_MAX_SUBTITLES]; 59 | float subtitle_end[CLVIDEO_MAX_SUBTITLES]; 60 | 61 | // this functions gets filled by video format module 62 | void (*close) (void *stream); 63 | unsigned int (*getwidth) (void *stream); 64 | unsigned int (*getheight) (void *stream); 65 | double (*getframerate) (void *stream); 66 | double (*getaspectratio) (void *stream); 67 | int (*decodeframe) (void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow); 68 | 69 | // if a video is suspended, it is automatically paused (else we'd still have to process the frames) 70 | // used to determine whether the video's resources should be freed or not 71 | double lasttime; 72 | // when lasttime - realtime > THRESHOLD, all but the stream is freed 73 | qbool suspended; 74 | 75 | char filename[MAX_QPATH]; 76 | } clvideo_t; 77 | 78 | clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner, const char *subtitlesfile ); 79 | clvideo_t* CL_GetVideoByName( const char *name ); 80 | void CL_SetVideoState( clvideo_t *video, clvideostate_t state ); 81 | void CL_RestartVideo( clvideo_t *video ); 82 | 83 | void CL_CloseVideo( clvideo_t * video ); 84 | void CL_PurgeOwner( int owner ); 85 | 86 | void CL_Video_Frame( void ); // update all videos 87 | void CL_Video_Init( void ); 88 | void CL_Video_Shutdown( void ); 89 | 90 | // old interface 91 | extern int cl_videoplaying; 92 | 93 | void CL_DrawVideo( void ); 94 | void CL_VideoStart( char *filename, const char *subtitlesfile ); 95 | void CL_VideoStop( void ); 96 | 97 | // new function used for fullscreen videos 98 | // TODO: Andreas Kirsch: move this subsystem somewhere else (preferably host) since the cl_video system shouldnt do such work like managing key events.. 99 | void CL_Video_KeyEvent( int key, int ascii, qbool down ); 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /cl_video_libavw.h: -------------------------------------------------------------------------------- 1 | #include "quakedef.h" 2 | #include "cl_video.h" 3 | 4 | void libavw_close(void *stream); 5 | void *LibAvW_OpenVideo(clvideo_t *video, char *filename, const char **errorstring); 6 | qbool LibAvW_OpenLibrary(void); 7 | void LibAvW_CloseLibrary(void); -------------------------------------------------------------------------------- /clprogdefs.h: -------------------------------------------------------------------------------- 1 | /* file generated by qcc, do not modify */ 2 | 3 | 4 | #ifndef CLPROGDEFS_H 5 | #define CLPROGDEFS_H 6 | 7 | /* 8 | typedef struct cl_globalvars_s 9 | { 10 | int pad[28]; 11 | int self; 12 | int other; 13 | int world; 14 | float time; 15 | float frametime; 16 | float player_localentnum; 17 | float player_localnum; 18 | float maxclients; 19 | float clientcommandframe; 20 | float servercommandframe; 21 | string_t mapname; 22 | vec3_t v_forward; 23 | vec3_t v_up; 24 | vec3_t v_right; 25 | float trace_allsolid; 26 | float trace_startsolid; 27 | float trace_fraction; 28 | vec3_t trace_endpos; 29 | vec3_t trace_plane_normal; 30 | float trace_plane_dist; 31 | int trace_ent; 32 | float trace_inopen; 33 | float trace_inwater; 34 | func_t CSQC_Init; 35 | func_t CSQC_Shutdown; 36 | func_t CSQC_InputEvent; 37 | func_t CSQC_UpdateView; 38 | func_t CSQC_ConsoleCommand; 39 | vec3_t pmove_org; 40 | vec3_t pmove_vel; 41 | vec3_t pmove_mins; 42 | vec3_t pmove_maxs; 43 | float input_timelength; 44 | vec3_t input_angles; 45 | vec3_t input_movevalues; 46 | float input_buttons; 47 | float movevar_gravity; 48 | float movevar_stopspeed; 49 | float movevar_maxspeed; 50 | float movevar_spectatormaxspeed; 51 | float movevar_accelerate; 52 | float movevar_airaccelerate; 53 | float movevar_wateraccelerate; 54 | float movevar_friction; 55 | float movevar_waterfriction; 56 | float movevar_entgravity; 57 | } cl_globalvars_t; 58 | 59 | typedef struct cl_entvars_s 60 | { 61 | float modelindex; 62 | vec3_t absmin; 63 | vec3_t absmax; 64 | float entnum; 65 | float drawmask; 66 | func_t predraw; 67 | float movetype; 68 | float solid; 69 | vec3_t origin; 70 | vec3_t oldorigin; 71 | vec3_t velocity; 72 | vec3_t angles; 73 | vec3_t avelocity; 74 | string_t classname; 75 | string_t model; 76 | float frame; 77 | float skin; 78 | float effects; 79 | vec3_t mins; 80 | vec3_t maxs; 81 | vec3_t size; 82 | func_t touch; 83 | func_t use; 84 | func_t think; 85 | func_t blocked; 86 | float nextthink; 87 | int chain; 88 | string_t netname; 89 | int enemy; 90 | float flags; 91 | float colormap; 92 | int owner; 93 | } cl_entvars_t; 94 | 95 | #define CL_PROGHEADER_CRC 52195 96 | */ 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /clvm_cmds.h: -------------------------------------------------------------------------------- 1 | #ifndef __CLVM_CMDS_H__ 2 | #define __CLVM_CMDS_H__ 3 | 4 | /* These are VM built-ins that originate in the client-side programs support 5 | but are reused by the other programs (usually the menu). */ 6 | 7 | void VM_CL_setmodel (void); 8 | void VM_CL_precache_model (void); 9 | void VM_CL_setorigin (void); 10 | 11 | void VM_CL_R_AddDynamicLight (void); 12 | void VM_CL_R_ClearScene (void); 13 | void VM_CL_R_AddEntities (void); 14 | void VM_CL_R_AddEntity (void); 15 | void VM_CL_R_SetView (void); 16 | void VM_CL_R_RenderScene (void); 17 | void VM_CL_R_LoadWorldModel (void); 18 | 19 | void VM_CL_R_PolygonBegin (void); 20 | void VM_CL_R_PolygonVertex (void); 21 | void VM_CL_R_PolygonEnd (void); 22 | 23 | void VM_CL_setattachment(void); 24 | void VM_CL_gettagindex(void); 25 | void VM_CL_gettaginfo(void); 26 | 27 | #endif /* __CLVM_CMDS_H__ */ 28 | -------------------------------------------------------------------------------- /com_ents.c: -------------------------------------------------------------------------------- 1 | #include "quakedef.h" 2 | #include "protocol.h" 3 | 4 | // (client and server) allocates a new empty database 5 | entityframe_database_t *EntityFrame_AllocDatabase(mempool_t *mempool) 6 | { 7 | return (entityframe_database_t *)Mem_Alloc(mempool, sizeof(entityframe_database_t)); 8 | } 9 | 10 | // (client and server) frees the database 11 | void EntityFrame_FreeDatabase(entityframe_database_t *d) 12 | { 13 | Mem_Free(d); 14 | } 15 | 16 | // (client and server) clears the database to contain no frames (thus delta compression compresses against nothing) 17 | void EntityFrame_ClearDatabase(entityframe_database_t *d) 18 | { 19 | memset(d, 0, sizeof(*d)); 20 | } 21 | 22 | // (client and server) clears frame, to prepare for adding entities 23 | void EntityFrame_Clear(entity_frame_t *f, vec3_t eye, int framenum) 24 | { 25 | f->time = 0; 26 | f->framenum = framenum; 27 | f->numentities = 0; 28 | if (eye == NULL) 29 | VectorClear(f->eye); 30 | else 31 | VectorCopy(eye, f->eye); 32 | } 33 | 34 | // (server and client) removes frames older than 'frame' from database 35 | void EntityFrame_AckFrame(entityframe_database_t *d, int frame) 36 | { 37 | int i; 38 | d->ackframenum = frame; 39 | for (i = 0;i < d->numframes && d->frames[i].framenum < frame;i++); 40 | // ignore outdated frame acks (out of order packets) 41 | if (i == 0) 42 | return; 43 | d->numframes -= i; 44 | // if some queue is left, slide it down to beginning of array 45 | if (d->numframes) 46 | memmove(&d->frames[0], &d->frames[i], sizeof(d->frames[0]) * d->numframes); 47 | } 48 | 49 | // (server and client) reads a frame from the database 50 | void EntityFrame_FetchFrame(entityframe_database_t *d, int framenum, entity_frame_t *f) 51 | { 52 | int i, n; 53 | EntityFrame_Clear(f, NULL, -1); 54 | for (i = 0;i < d->numframes && d->frames[i].framenum < framenum;i++); 55 | if (i < d->numframes && framenum == d->frames[i].framenum) 56 | { 57 | f->framenum = framenum; 58 | f->numentities = d->frames[i].endentity - d->frames[i].firstentity; 59 | n = MAX_ENTITY_DATABASE - (d->frames[i].firstentity % MAX_ENTITY_DATABASE); 60 | if (n > f->numentities) 61 | n = f->numentities; 62 | memcpy(f->entitydata, d->entitydata + d->frames[i].firstentity % MAX_ENTITY_DATABASE, sizeof(*f->entitydata) * n); 63 | if (f->numentities > n) 64 | memcpy(f->entitydata + n, d->entitydata, sizeof(*f->entitydata) * (f->numentities - n)); 65 | VectorCopy(d->eye, f->eye); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /com_ents4.c: -------------------------------------------------------------------------------- 1 | #include "quakedef.h" 2 | #include "protocol.h" 3 | 4 | entityframe4_database_t *EntityFrame4_AllocDatabase(mempool_t *pool) 5 | { 6 | entityframe4_database_t *d; 7 | d = (entityframe4_database_t *)Mem_Alloc(pool, sizeof(*d)); 8 | d->mempool = pool; 9 | EntityFrame4_ResetDatabase(d); 10 | return d; 11 | } 12 | 13 | void EntityFrame4_FreeDatabase(entityframe4_database_t *d) 14 | { 15 | int i; 16 | for (i = 0;i < MAX_ENTITY_HISTORY;i++) 17 | if (d->commit[i].entity) 18 | Mem_Free(d->commit[i].entity); 19 | if (d->referenceentity) 20 | Mem_Free(d->referenceentity); 21 | Mem_Free(d); 22 | } 23 | 24 | void EntityFrame4_ResetDatabase(entityframe4_database_t *d) 25 | { 26 | int i; 27 | d->referenceframenum = -1; 28 | for (i = 0;i < MAX_ENTITY_HISTORY;i++) 29 | d->commit[i].numentities = 0; 30 | for (i = 0;i < d->maxreferenceentities;i++) 31 | d->referenceentity[i] = defaultstate; 32 | } 33 | 34 | entity_state_t *EntityFrame4_GetReferenceEntity(entityframe4_database_t *d, int number) 35 | { 36 | if (d->maxreferenceentities <= number) 37 | { 38 | int oldmax = d->maxreferenceentities; 39 | entity_state_t *oldentity = d->referenceentity; 40 | d->maxreferenceentities = (number + 15) & ~7; 41 | d->referenceentity = (entity_state_t *)Mem_Alloc(d->mempool, d->maxreferenceentities * sizeof(*d->referenceentity)); 42 | if (oldentity) 43 | { 44 | memcpy(d->referenceentity, oldentity, oldmax * sizeof(*d->referenceentity)); 45 | Mem_Free(oldentity); 46 | } 47 | // clear the newly created entities 48 | for (;oldmax < d->maxreferenceentities;oldmax++) 49 | { 50 | d->referenceentity[oldmax] = defaultstate; 51 | d->referenceentity[oldmax].number = oldmax; 52 | } 53 | } 54 | return d->referenceentity + number; 55 | } 56 | 57 | void EntityFrame4_AddCommitEntity(entityframe4_database_t *d, const entity_state_t *s) 58 | { 59 | // resize commit's entity list if full 60 | if (d->currentcommit->maxentities <= d->currentcommit->numentities) 61 | { 62 | entity_state_t *oldentity = d->currentcommit->entity; 63 | d->currentcommit->maxentities += 8; 64 | d->currentcommit->entity = (entity_state_t *)Mem_Alloc(d->mempool, d->currentcommit->maxentities * sizeof(*d->currentcommit->entity)); 65 | if (oldentity) 66 | { 67 | memcpy(d->currentcommit->entity, oldentity, d->currentcommit->numentities * sizeof(*d->currentcommit->entity)); 68 | Mem_Free(oldentity); 69 | } 70 | } 71 | d->currentcommit->entity[d->currentcommit->numentities++] = *s; 72 | } 73 | 74 | int EntityFrame4_AckFrame(entityframe4_database_t *d, int framenum, int servermode) 75 | { 76 | int i, j, found; 77 | entity_database4_commit_t *commit; 78 | if (framenum == -1) 79 | { 80 | // reset reference, but leave commits alone 81 | d->referenceframenum = -1; 82 | for (i = 0;i < d->maxreferenceentities;i++) 83 | d->referenceentity[i] = defaultstate; 84 | // if this is the server, remove commits 85 | for (i = 0, commit = d->commit;i < MAX_ENTITY_HISTORY;i++, commit++) 86 | commit->numentities = 0; 87 | found = true; 88 | } 89 | else if (d->referenceframenum == framenum) 90 | found = true; 91 | else 92 | { 93 | found = false; 94 | for (i = 0, commit = d->commit;i < MAX_ENTITY_HISTORY;i++, commit++) 95 | { 96 | if (commit->numentities && commit->framenum <= framenum) 97 | { 98 | if (commit->framenum == framenum) 99 | { 100 | found = true; 101 | d->referenceframenum = framenum; 102 | if (developer_networkentities.integer >= 3) 103 | { 104 | for (j = 0;j < commit->numentities;j++) 105 | { 106 | entity_state_t *s = EntityFrame4_GetReferenceEntity(d, commit->entity[j].number); 107 | if (commit->entity[j].active != s->active) 108 | { 109 | if (commit->entity[j].active == ACTIVE_NETWORK) 110 | Con_Printf("commit entity %i has become active (modelindex %i)\n", commit->entity[j].number, commit->entity[j].modelindex); 111 | else 112 | Con_Printf("commit entity %i has become inactive (modelindex %i)\n", commit->entity[j].number, commit->entity[j].modelindex); 113 | } 114 | *s = commit->entity[j]; 115 | } 116 | } 117 | else 118 | for (j = 0;j < commit->numentities;j++) 119 | *EntityFrame4_GetReferenceEntity(d, commit->entity[j].number) = commit->entity[j]; 120 | } 121 | commit->numentities = 0; 122 | } 123 | } 124 | } 125 | if (developer_networkentities.integer >= 1) 126 | { 127 | Con_Printf("ack ref:%i database updated to: ref:%i commits:", framenum, d->referenceframenum); 128 | for (i = 0;i < MAX_ENTITY_HISTORY;i++) 129 | if (d->commit[i].numentities) 130 | Con_Printf(" %i", d->commit[i].framenum); 131 | Con_Print("\n"); 132 | } 133 | return found; 134 | } 135 | -------------------------------------------------------------------------------- /com_game.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2000-2021 DarkPlaces contributors 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef COM_GAME_H 22 | #define COM_GAME_H 23 | 24 | #include "qdefs.h" 25 | 26 | typedef enum gamemode_e 27 | { 28 | GAME_NORMAL, 29 | GAME_HIPNOTIC, 30 | GAME_ROGUE, 31 | GAME_QUOTH, 32 | GAME_NEHAHRA, 33 | GAME_NEXUIZ, 34 | GAME_XONOTIC, 35 | GAME_TRANSFUSION, 36 | GAME_GOODVSBAD2, 37 | GAME_TEU, 38 | GAME_BATTLEMECH, 39 | GAME_ZYMOTIC, 40 | GAME_SETHERAL, 41 | GAME_TENEBRAE, ///< full of evil hackery 42 | GAME_NEOTERIC, 43 | GAME_OPENQUARTZ, ///< this game sucks 44 | GAME_PRYDON, 45 | GAME_DELUXEQUAKE, 46 | GAME_THEHUNTED, 47 | GAME_DEFEATINDETAIL2, 48 | GAME_DARSANA, 49 | GAME_CONTAGIONTHEORY, 50 | GAME_EDU2P, 51 | GAME_PROPHECY, 52 | GAME_BLOODOMNICIDE, 53 | GAME_STEELSTORM, ///< added by motorsep 54 | GAME_STEELSTORM2, ///< added by motorsep 55 | GAME_SSAMMO, ///< added by motorsep 56 | GAME_STEELSTORMREVENANTS, ///< added by motorsep 07/19/2015 57 | GAME_TOMESOFMEPHISTOPHELES, ///< added by motorsep 58 | GAME_STRAPBOMB, ///< added by motorsep for Urre 59 | GAME_MOONHELM, 60 | GAME_VORETOURNAMENT, 61 | GAME_DOOMBRINGER, ///< added by Cloudwalk for kristus 62 | GAME_BATTLEMETAL, ///< added by Cloudwalk for Subject9x 63 | GAME_QUAKE15, ///< added by bones_was_here as it depends on an old bug and a workaround 64 | GAME_AD, ///< added by bones_was_here as it depends on old DP behaviour or csqc_lowres 65 | GAME_CTSJ2, ///< added by bones_was_here as it has a race condition that requires a workaound 66 | GAME_COUNT 67 | } 68 | gamemode_t; 69 | 70 | // Master switch for some hacks/changes that eventually should become cvars. 71 | #define IS_NEXUIZ_DERIVED(g) ((g) == GAME_NEXUIZ || (g) == GAME_XONOTIC || (g) == GAME_VORETOURNAMENT) 72 | // Pre-csqcmodels era. 73 | #define IS_OLDNEXUIZ_DERIVED(g) ((g) == GAME_NEXUIZ || (g) == GAME_VORETOURNAMENT) 74 | 75 | extern gamemode_t gamemode; 76 | extern const char *gamename; 77 | extern const char *gamenetworkfiltername; 78 | extern const char *gamedirname1; 79 | extern const char *gamedirname2; 80 | extern const char *gamescreenshotname; 81 | extern const char *gameuserdirname; 82 | extern char com_modname[MAX_OSPATH]; 83 | 84 | extern gamemode_t com_startupgamegroup; 85 | 86 | void COM_InitGameType (void); 87 | int COM_ChangeGameTypeForGameDirs(unsigned numgamedirs, const char *gamedirs[], qbool failmissing, qbool init); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /com_infostring.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006-2021 DarkPlaces contributors 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef INFOSTRING_H 22 | #define INFOSTRING_H 23 | 24 | #include "qtypes.h" 25 | #include 26 | 27 | /// Returns the number of bytes written to *value excluding the \0 terminator. 28 | size_t InfoString_GetValue(const char *buffer, const char *key, char *value, size_t valuesize); 29 | void InfoString_SetValue(char *buffer, size_t bufferlength, const char *key, const char *value); 30 | void InfoString_Print(char *buffer); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /convex.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Ashley Rose Hale (LadyHavoc) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | // This module is a variant of the QuickHull algorithm intended to create hulls 24 | // (brushes, aka n-sided polytopes or hulls) from a series of points provided by 25 | // the caller 26 | 27 | #pragma once 28 | 29 | #ifndef CONVEX_H 30 | 31 | enum convex_enums 32 | { 33 | CONVEX_MAX_CORNERS = 256, 34 | CONVEX_MAX_FACES = 1024, 35 | }; 36 | 37 | typedef struct convex_corner_s 38 | { 39 | float x; 40 | float y; 41 | float z; 42 | float w; // 1.0f 43 | } 44 | convex_corner_t; 45 | 46 | typedef struct convex_face_s 47 | { 48 | // plane equation: a * x + b * y + c * z + d * w = 0.0f 49 | float x; 50 | float y; 51 | float z; 52 | float w; 53 | } 54 | convex_face_t; 55 | 56 | typedef struct convex_builder_state_s 57 | { 58 | // axially aligned bounding box 59 | float extents[2][3]; 60 | 61 | int numcorners; 62 | convex_corner_t corners[CONVEX_MAX_CORNERS]; 63 | 64 | int numfaces; 65 | convex_face_t faces[CONVEX_MAX_FACES]; 66 | 67 | // we consider points to be equivalent if they are within this distance 68 | // suggested value is maxextent / 1048576.0f, which is a way of saying 69 | // 'equivalent within 20 bits of precision' 70 | float epsilon; 71 | } 72 | convex_builder_state_t; 73 | 74 | // set up a builer state to receive points 75 | void convex_builder_initialize(convex_builder_state_t* b, float epsilon); 76 | 77 | // this is a variant of QuickHull that relies on the caller to provide points 78 | // in a reasonable order - the result will be the same regardless of point order 79 | // but it's more efficient if the furthest points are provided first 80 | // 81 | // this could be a little more efficient if we kept track of edges during the 82 | // build, but I think it may be more numerically stable this way 83 | void convex_builder_add_point(convex_builder_state_t* b, float x, float y, float z); 84 | 85 | // returns computed faces in array of vec4 86 | // positivew=0 is for plane equations of the form a*x+b*y+c*z+w, which is the 87 | // internal format 88 | // positivew=1 is for plane equations of the form a*x+b*y+c*z-w, which tend to 89 | // be less friendly in terms of vector ops 90 | int convex_builder_get_planes4f(convex_builder_state_t* b, float* outplanes4f, int maxplanes, int positivew); 91 | 92 | // returns the points as an array of vec3 93 | // internal format is vec4, so this is just repacking the data 94 | int convex_builder_get_points3f(convex_builder_state_t* b, float* outpoints3f, int maxpoints); 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /crypto-keygen-standalone-brute.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | outfile=$1; shift 4 | hosts=$1; shift 5 | 6 | on() 7 | { 8 | case "$1" in 9 | localhost) 10 | shift 11 | exec "$@" 12 | ;; 13 | *) 14 | exec ssh "$@" 15 | ;; 16 | esac 17 | } 18 | 19 | pids= 20 | mainpid=$$ 21 | trap 'kill $pids' EXIT 22 | trap 'exit 1' INT USR1 23 | 24 | n=0 25 | for h in $hosts; do 26 | nn=`on "$h" cat /proc/cpuinfo | grep -c '^processor[ :]'` 27 | n=$(($nn + $n)) 28 | done 29 | 30 | rm -f bruteforce-* 31 | i=0 32 | for h in $hosts; do 33 | nn=`on "$h" cat /proc/cpuinfo | grep -c '^processor[ :]'` 34 | ii=$(($nn + $i)) 35 | while [ $i -lt $ii ]; do 36 | i=$(($i+1)) 37 | ( 38 | on "$h" ./crypto-keygen-standalone -n $n -o /dev/stdout "$@" > bruteforce-$i & 39 | pid=$! 40 | trap 'kill $pid' TERM 41 | wait 42 | if [ -s "bruteforce-$i" ]; then 43 | trap - TERM 44 | mv "bruteforce-$i" "$outfile" 45 | kill -USR1 $mainpid 46 | else 47 | rm -f "bruteforce-$i" 48 | fi 49 | ) & 50 | pids="$pids $!" 51 | done 52 | done 53 | wait 54 | -------------------------------------------------------------------------------- /curves.h: -------------------------------------------------------------------------------- 1 | #ifndef CURVES_H 2 | #define CURVES_H 3 | 4 | #define PATCH_LODS_NUM 2 5 | #define PATCH_LOD_COLLISION 0 6 | #define PATCH_LOD_VISUAL 1 7 | 8 | typedef struct patchinfo_s 9 | { 10 | int xsize, ysize; 11 | struct { 12 | int xtess, ytess; 13 | } lods[PATCH_LODS_NUM]; 14 | } patchinfo_t; 15 | 16 | // Calculate number of resulting vertex rows/columns by given patch size and tesselation factor 17 | // When tess=0 it means that we reduce detalization of base 3x3 patches by removing middle row and column 18 | // "DimForTess" is "DIMension FOR TESSelation factor" 19 | int Q3PatchDimForTess(int size, int tess); 20 | 21 | // usage: 22 | // to expand a 5x5 patch to 21x21 vertices (4x4 tesselation), one might use this call: 23 | // Q3PatchSubdivideFloat(3, sizeof(float[3]), outvertices, 5, 5, sizeof(float[3]), patchvertices, 4, 4); 24 | void Q3PatchTesselateFloat(int numcomponents, int outputstride, float *outputvertices, int patchwidth, int patchheight, int inputstride, float *patchvertices, int tesselationwidth, int tesselationheight); 25 | // returns how much tesselation of each segment is needed to remain under tolerance 26 | int Q3PatchTesselationOnX(int patchwidth, int patchheight, int components, const float *in, float tolerance); 27 | // returns how much tesselation of each segment is needed to remain under tolerance 28 | int Q3PatchTesselationOnY(int patchwidth, int patchheight, int components, const float *in, float tolerance); 29 | // calculates elements for a grid of vertices 30 | // (such as those produced by Q3PatchTesselate) 31 | // (note: width and height are the actual vertex size, this produces 32 | // (width-1)*(height-1)*2 triangles, 3 elements each) 33 | void Q3PatchTriangleElements(int *elements, int width, int height, int firstvertex); 34 | 35 | int Q3PatchAdjustTesselation(int numcomponents, patchinfo_t *patch1, float *patchvertices1, patchinfo_t *patch2, float *patchvertices2); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /darkplaces-vs2019.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "darkplaces-sdl2-vs2019", "darkplaces-sdl2-vs2019.vcxproj", "{72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Debug|Win32.Build.0 = Debug|Win32 18 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Debug|x64.ActiveCfg = Debug|x64 19 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Debug|x64.Build.0 = Debug|x64 20 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Release|Win32.ActiveCfg = Release|Win32 21 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Release|Win32.Build.0 = Release|Win32 22 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Release|x64.ActiveCfg = Release|x64 23 | {6E3D4311-BB84-4EB7-8C6C-10AA3D249C28}.Release|x64.Build.0 = Release|x64 24 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Debug|Win32.Build.0 = Debug|Win32 26 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Debug|x64.ActiveCfg = Debug|x64 27 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Debug|x64.Build.0 = Debug|x64 28 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Release|Win32.ActiveCfg = Release|Win32 29 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Release|Win32.Build.0 = Release|Win32 30 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Release|x64.ActiveCfg = Release|x64 31 | {389AE334-D907-4069-90B3-F0551B3EFDE9}.Release|x64.Build.0 = Release|x64 32 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Debug|Win32.Build.0 = Debug|Win32 34 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Debug|x64.ActiveCfg = Debug|x64 35 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Debug|x64.Build.0 = Debug|x64 36 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Release|Win32.ActiveCfg = Release|Win32 37 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Release|Win32.Build.0 = Release|Win32 38 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Release|x64.ActiveCfg = Release|x64 39 | {72D93E63-FDBB-4AA3-B42B-FAADA6D7F5B2}.Release|x64.Build.0 = Release|x64 40 | EndGlobalSection 41 | GlobalSection(SolutionProperties) = preSolution 42 | HideSolutionNode = FALSE 43 | EndGlobalSection 44 | EndGlobal 45 | -------------------------------------------------------------------------------- /darkplaces.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2020 Ashley Rose Hale (LadyHavoc) 3 | Copyright (C) 2020 David Knapp (Cloudwalk) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | See the GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | /* darkplaces.h - Master definitions file for Darkplaces engine */ 23 | 24 | #ifndef DARKPLACES_H 25 | #define DARKPLACES_H 26 | 27 | extern const char *buildstring; 28 | extern char engineversion[128]; 29 | 30 | #ifdef __APPLE__ 31 | # include 32 | #endif 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "sys.h" 44 | #include "qtypes.h" 45 | #include "qdefs.h" 46 | #include "zone.h" 47 | #include "thread.h" 48 | #include "com_game.h" 49 | #include "com_infostring.h" 50 | #include "common.h" 51 | #include "filematch.h" 52 | #include "fs.h" 53 | #include "host.h" 54 | #include "cvar.h" 55 | #include "cmd.h" 56 | #include "console.h" 57 | #include "lhnet.h" 58 | #include "mathlib.h" 59 | #include "matrixlib.h" 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /darkplaces.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DarkPlacesEngine/DarkPlaces/af1e5c03be8e2fd41135f9064ad8e4c4c1ccd8f4/darkplaces.ico -------------------------------------------------------------------------------- /darkplaces.rc: -------------------------------------------------------------------------------- 1 | #include // include for version info constants 2 | 3 | 107 ICON "darkplaces.ico" 4 | 5 | 1 VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | PRODUCTVERSION 1,0,0,0 8 | FILETYPE VFT_APP 9 | { 10 | BLOCK "StringFileInfo" 11 | { 12 | BLOCK "040904E4" 13 | { 14 | VALUE "CompanyName", "DarkPlaces Contributors" 15 | VALUE "FileVersion", "1.0" 16 | VALUE "FileDescription", "DarkPlaces Game Engine" 17 | VALUE "InternalName", "darkplaces.exe" 18 | VALUE "LegalCopyright", "id Software, Forest Hale, and contributors" 19 | VALUE "LegalTrademarks", "" 20 | VALUE "OriginalFilename", "darkplaces.exe" 21 | VALUE "ProductName", "DarkPlaces" 22 | VALUE "ProductVersion", "1.0" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /darkplaces.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * darkplaces_xpm[] = { 3 | "48 48 91 1", 4 | " c None", 5 | ". c #020300", 6 | "+ c #120303", 7 | "@ c #180202", 8 | "# c #200301", 9 | "$ c #340100", 10 | "% c #410000", 11 | "& c #2D0704", 12 | "* c #11120F", 13 | "= c #4F0701", 14 | "- c #3F0F00", 15 | "; c #251615", 16 | "> c #780000", 17 | ", c #2D1514", 18 | "' c #1D1C1A", 19 | ") c #680F01", 20 | "! c #431A10", 21 | "~ c #3B221D", 22 | "{ c #2B2725", 23 | "] c #601B02", 24 | "^ c #9D0A00", 25 | "/ c #55220A", 26 | "( c #3D2B25", 27 | "_ c #53291D", 28 | ": c #4E2E1B", 29 | "< c #333432", 30 | "[ c #4C2F26", 31 | "} c #812301", 32 | "| c #3F332F", 33 | "1 c #6B321A", 34 | "2 c #3F3F3D", 35 | "3 c #7E320E", 36 | "4 c #563B35", 37 | "5 c #4B3E39", 38 | "6 c #533F39", 39 | "7 c #6D3A2F", 40 | "8 c #943508", 41 | "9 c #514541", 42 | "0 c #654132", 43 | "a c #474845", 44 | "b c #6D442B", 45 | "c c #7C4328", 46 | "d c #504F4D", 47 | "e c #674A43", 48 | "f c #644F47", 49 | "g c #5E514B", 50 | "h c #B64005", 51 | "i c #91472F", 52 | "j c #575654", 53 | "k c #AD4A11", 54 | "l c #82533C", 55 | "m c #5F5E5B", 56 | "n c #745C54", 57 | "o c #6C5E5A", 58 | "p c #A25329", 59 | "q c #825C54", 60 | "r c #676664", 61 | "s c #816A62", 62 | "t c #70706E", 63 | "u c #986951", 64 | "v c #7D706C", 65 | "w c #C66935", 66 | "x c #7E7C79", 67 | "y c #FA6400", 68 | "z c #937B73", 69 | "A c #9E796A", 70 | "B c #B97557", 71 | "C c #A67B5D", 72 | "D c #878581", 73 | "E c #8F8D8B", 74 | "F c #AF8A7D", 75 | "G c #A58D83", 76 | "H c #9C8F8C", 77 | "I c #979693", 78 | "J c #B79590", 79 | "K c #A59F9C", 80 | "L c #DD9472", 81 | "M c #B39D97", 82 | "N c #EB9462", 83 | "O c #C1A391", 84 | "P c #D19F8D", 85 | "Q c #D1A184", 86 | "R c #B6B0AD", 87 | "S c #C8C2BF", 88 | "T c #DDC0BC", 89 | "U c #E1C2B0", 90 | "V c #F8BE99", 91 | "W c #DDD3CE", 92 | "X c #EFE4E0", 93 | "Y c #FEE4C7", 94 | "Z c #FDFEFA", 95 | " ", 96 | " ID ", 97 | " tvr ", 98 | " 59aI ", 99 | " 4v2t ", 100 | " 4I2r ", 101 | " E[Xaj ", 102 | " z7Xda RHrqsE ", 103 | " f2XjaD Itj93][zH ", 104 | " 92Wd2x Ixja2,pQDI ", 105 | " 92Xx2t Irjb&FIx ", 106 | " 5aZx5r Dj{,ORx ", 107 | " xsja,eXt2r t'+XIt ", 108 | " Mu/+|<<;[Xr2r j!AXjt ", 109 | " Kq3=[222a,5Xt2r 5;SSdI ", 110 | " H;0A5222j ~oZr2t t+CWjr ", 111 | " z37(2<2ax sub { (1, 1); }, 9 | GL_ZERO => sub { (0, 0); }, 10 | GL_SRC_COLOR => sub { ($_[0], $_[1]); }, 11 | GL_ONE_MINUS_SRC_COLOR => sub { (1-$_[0], 1-$_[1]); }, 12 | GL_SRC_ALPHA => sub { ($_[1], $_[1]); }, 13 | GL_ONE_MINUS_SRC_ALPHA => sub { (1-$_[1], 1-$_[1]); }, 14 | GL_DST_COLOR => sub { ($_[2], $_[3]); }, 15 | GL_ONE_MINUS_DST_COLOR => sub { (1-$_[2], 1-$_[3]); }, 16 | GL_DST_ALPHA => sub { ($_[3], $_[3]); }, 17 | GL_ONE_MINUS_DST_ALPHA => sub { (1-$_[3], 1-$_[3]); }, 18 | ); 19 | 20 | sub evalblend($$$$$$) 21 | { 22 | my ($fs, $fd, $s, $sa, $d, $da) = @_; 23 | my @fs = $fs->($s, $sa, $d, $da); 24 | my @fd = $fd->($s, $sa, $d, $da); 25 | return ( 26 | $fs[0] * $s + $fd[0] * $d, 27 | $fs[1] * $sa + $fd[1] * $da 28 | ); 29 | } 30 | 31 | sub isinvariant($$$$) 32 | { 33 | my ($fs, $fd, $s, $sa) = @_; 34 | my ($d, $da) = (rand, rand); 35 | my ($out, $outa) = evalblend $fs, $fd, $s, $sa, $d, $da; 36 | return abs($out - $d) < 0.0001 && abs($outa - $da) < 0.0001; 37 | } 38 | 39 | sub isfogfriendly($$$$$) 40 | { 41 | my ($fs, $fd, $s, $sa, $foghack) = @_; 42 | my ($d, $da) = (rand, rand); 43 | my $fogamount = rand; 44 | my $fogcolor = rand; 45 | 46 | # compare: 47 | # 1. blend(fog(s), sa, fog(d), da) 48 | # 2. fog(blend(s, sa, d, da)) 49 | 50 | my ($out1, $out1a) = evalblend $fs, $fd, $s + ((defined $foghack ? $foghack eq 'ALPHA' ? $fogcolor*$sa : $foghack : $fogcolor) - $s) * $fogamount, $sa, $d + ($fogcolor - $d) * $fogamount, $da; 51 | my ($out2, $out2a) = evalblend $fs, $fd, $s, $sa, $d, $da; 52 | $out2 = $out2 + ($fogcolor - $out2) * $fogamount; 53 | 54 | return abs($out1 - $out2) < 0.0001 && abs($out1a - $out2a) < 0.0001; 55 | } 56 | 57 | use Carp; 58 | sub decide(&) 59 | { 60 | my ($sub) = @_; 61 | my $good = 0; 62 | my $bad = 0; 63 | for(;;) 64 | { 65 | for(1..200) 66 | { 67 | my $r = $sub->(); 68 | ++$good if $r; 69 | ++$bad if not $r; 70 | } 71 | #print STDERR "decide: $good vs $bad\n"; 72 | return 1 if $good > $bad + 150; 73 | return 0 if $bad > $good + 150; 74 | warn "No clear decision, continuing to test ($good : $bad)"; 75 | } 76 | } 77 | 78 | #die isfogfriendly $blendfuncs{GL_ONE}, $blendfuncs{GL_ONE}, 1, 0, 0; 79 | # out1 = 0 + fog($d) 80 | # out2 = fog(1 + $d) 81 | 82 | sub willitblend($$) 83 | { 84 | my ($fs, $fd) = @_; 85 | for my $s(0, 0.25, 0.5, 0.75, 1) 86 | { 87 | for my $sa(0, 0.25, 0.5, 0.75, 1) 88 | { 89 | if(decide { isinvariant($fs, $fd, $s, $sa); }) 90 | { 91 | if(!decide { isinvariant($fs, $fd, 0, $sa); }) 92 | { 93 | return 0; # no colormod possible 94 | } 95 | } 96 | } 97 | } 98 | return 1; 99 | } 100 | 101 | sub willitfog($$) 102 | { 103 | my ($fs, $fd) = @_; 104 | 105 | FOGHACK: 106 | for my $foghack(undef, 0, 'ALPHA') 107 | { 108 | for my $s(0, 0.25, 0.5, 0.75, 1) 109 | { 110 | for my $sa(0, 0.25, 0.5, 0.75, 1) 111 | { 112 | if(!decide { isfogfriendly($fs, $fd, $s, $sa, $foghack); }) 113 | { 114 | next FOGHACK; 115 | } 116 | } 117 | } 118 | return (1, $foghack); 119 | } 120 | return (0, undef); 121 | } 122 | 123 | print "\tr |= BLENDFUNC_ALLOWS_COLORMOD;\n"; 124 | for my $s(sort keys %blendfuncs) 125 | { 126 | for my $d(sort keys %blendfuncs) 127 | { 128 | #print STDERR "$s $d\n"; 129 | if(!willitblend $blendfuncs{$s}, $blendfuncs{$d}) 130 | { 131 | print "\tif(src == $s && dst == $d) r &= ~BLENDFUNC_ALLOWS_COLORMOD;\n"; 132 | } 133 | my ($result, $h) = willitfog $blendfuncs{$s}, $blendfuncs{$d}; 134 | if($result) 135 | { 136 | if(defined $h) 137 | { 138 | print "\tif(src == $s && dst == $d) r |= BLENDFUNC_ALLOWS_FOG_HACK$h;\n"; 139 | } 140 | else 141 | { 142 | print "\tif(src == $s && dst == $d) r |= BLENDFUNC_ALLOWS_FOG;\n"; 143 | } 144 | } 145 | } 146 | } 147 | 148 | -------------------------------------------------------------------------------- /ft2.h: -------------------------------------------------------------------------------- 1 | /* Header for FreeType 2 and UTF-8 encoding support for 2 | * DarkPlaces 3 | */ 4 | 5 | #ifndef DP_FREETYPE2_H__ 6 | #define DP_FREETYPE2_H__ 7 | 8 | //#include 9 | 10 | #include "utf8lib.h" 11 | 12 | /* 13 | * From http://www.unicode.org/Public/UNIDATA/Blocks.txt 14 | * 15 | * E000..F8FF; Private Use Area 16 | * F0000..FFFFF; Supplementary Private Use Area-A 17 | * 18 | * We use: 19 | * Range E000 - E0FF 20 | * Contains the non-FreeType2 version of characters. 21 | */ 22 | 23 | typedef struct ft2_font_map_s ft2_font_map_t; 24 | typedef struct font_incmap_s font_incmap_t; 25 | typedef struct incmap_lookup_cache_s incmap_lookup_cache_t; 26 | typedef struct ft2_attachment_s ft2_attachment_t; 27 | #ifdef WIN64 28 | #define ft2_oldstyle_map ((ft2_font_map_t*)-1LL) 29 | #else 30 | #define ft2_oldstyle_map ((ft2_font_map_t*)-1) 31 | #endif 32 | 33 | typedef float ft2_kernvec[2]; 34 | typedef struct ft2_kerning_s 35 | { 36 | ft2_kernvec kerning[256][256]; /* kerning[left char][right char] */ 37 | } ft2_kerning_t; 38 | 39 | typedef struct ft2_font_s 40 | { 41 | char name[64]; 42 | qbool has_kerning; 43 | // last requested size loaded using Font_SetSize 44 | float currentw; 45 | float currenth; 46 | float ascend; 47 | float descend; 48 | qbool image_font; // only fallbacks are freetype fonts 49 | 50 | // TODO: clean this up and do not expose everything. 51 | 52 | const unsigned char *data; // FT2 needs it to stay 53 | //fs_offset_t datasize; 54 | void *face; 55 | 56 | // an unordered array of ordered linked lists of glyph maps for a specific size 57 | ft2_font_map_t *font_maps[MAX_FONT_SIZES]; 58 | int num_sizes; 59 | 60 | // attachments 61 | size_t attachmentcount; 62 | ft2_attachment_t *attachments; 63 | 64 | ft2_settings_t *settings; 65 | 66 | // fallback mechanism 67 | struct ft2_font_s *next; 68 | } ft2_font_t; 69 | 70 | void Font_CloseLibrary(void); 71 | void Font_Init(void); 72 | qbool Font_OpenLibrary(void); 73 | ft2_font_t* Font_Alloc(void); 74 | void Font_UnloadFont(ft2_font_t *font); 75 | // IndexForSize suggests to change the width and height if a font size is in a reasonable range 76 | // for example, you render at a size of 12.4, and a font of size 12 has been loaded 77 | // in such a case, *outw and *outh are set to 12, which is often a good alternative size 78 | int Font_IndexForSize(ft2_font_t *font, float size, float *outw, float *outh); 79 | ft2_font_map_t *Font_MapForIndex(ft2_font_t *font, int index); 80 | qbool Font_LoadFont(const char *name, dp_font_t *dpfnt); 81 | qbool Font_GetKerningForSize(ft2_font_t *font, float w, float h, Uchar left, Uchar right, float *outx, float *outy); 82 | qbool Font_GetKerningForMap(ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy); 83 | float Font_VirtualToRealSize(float sz); 84 | float Font_SnapTo(float val, float snapwidth); 85 | // since this is used on a font_map_t, let's name it FontMap_* 86 | ft2_font_map_t *FontMap_FindForChar(ft2_font_map_t *start, Uchar ch); 87 | qbool Font_GetMapForChar(ft2_font_t *font, int map_index, Uchar ch, ft2_font_map_t **outmap, int *outmapch); 88 | #endif // DP_FREETYPE2_H__ 89 | -------------------------------------------------------------------------------- /ft2_fontdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef FT2_PRIVATE_H__ 2 | #define FT2_PRIVATE_H__ 3 | 4 | // anything should work, but I recommend multiples of 8 5 | // since the texture size should be a power of 2 6 | #define FONT_CHARS_PER_LINE 16 7 | #define FONT_CHAR_LINES 16 8 | #define FONT_CHARS_PER_MAP (FONT_CHARS_PER_LINE * FONT_CHAR_LINES) 9 | 10 | // map.start value for incremental maps to hold a place 11 | #define INCMAP_START 0x110000 12 | 13 | typedef struct glyph_slot_s 14 | { 15 | qbool image; 16 | // we keep the quad coords here only currently 17 | // if you need other info, make Font_LoadMapForIndex fill it into this slot 18 | float txmin; // texture coordinate in [0,1] 19 | float txmax; 20 | float tymin; 21 | float tymax; 22 | float vxmin; 23 | float vxmax; 24 | float vymin; 25 | float vymax; 26 | float advance_x; 27 | float advance_y; 28 | } glyph_slot_t; 29 | 30 | struct ft2_font_map_s 31 | { 32 | Uchar start; 33 | float size; 34 | 35 | // the actual size used in the freetype code 36 | // by convention, the requested size is the height of the font's bounding box. 37 | float intSize; 38 | int glyphSize; 39 | 40 | ft2_font_map_t *next; 41 | cachepic_t *pic; 42 | qbool static_tex; 43 | glyph_slot_t glyphs[FONT_CHARS_PER_MAP]; 44 | Uchar glyphchars[FONT_CHARS_PER_MAP]; 45 | 46 | // saves us the trouble of calculating these over and over again 47 | double sfx, sfy; 48 | 49 | // note: float width_of[256] was moved to `struct dp_font_s` as width_of_ft2 50 | 51 | // these may only present in a startmap 52 | // contains the kerning information for the first 256 characters 53 | // for the other characters, we will lookup the kerning information 54 | ft2_kerning_t *kerning; 55 | // for accessing incremental maps for bigblock glyphs 56 | font_incmap_t *incmap; 57 | }; 58 | 59 | struct font_incmap_s 60 | { 61 | // associated fontmap; startmap of incmaps 62 | struct ft2_font_map_s *fontmap; 63 | int charcount; 64 | int newmap_start; 65 | 66 | // two rounds of merge will take place, keep those data until then 67 | unsigned char *data_tier1[FONT_CHARS_PER_LINE]; 68 | unsigned char *data_tier2[FONT_CHAR_LINES]; 69 | 70 | // count of merged maps 71 | int tier1_merged, tier2_merged; 72 | }; 73 | 74 | struct ft2_attachment_s 75 | { 76 | const unsigned char *data; 77 | fs_offset_t size; 78 | }; 79 | 80 | //qbool Font_LoadMapForIndex(ft2_font_t *font, Uchar _ch, ft2_font_map_t **outmap); 81 | qbool Font_LoadMapForIndex(ft2_font_t *font, int map_index, Uchar _ch, ft2_font_map_t **outmap); 82 | 83 | void font_start(void); 84 | void font_shutdown(void); 85 | void font_newmap(void); 86 | 87 | #endif // FT2_PRIVATE_H__ 88 | -------------------------------------------------------------------------------- /hmac.c: -------------------------------------------------------------------------------- 1 | #include "darkplaces.h" 2 | #include "hmac.h" 3 | 4 | qbool hmac( 5 | hashfunc_t hfunc, int hlen, int hblock, 6 | unsigned char *out, 7 | const unsigned char *in, int n, 8 | const unsigned char *key, int k 9 | ) 10 | { 11 | unsigned char hashbuf[32]; 12 | unsigned char k_xor_ipad[128]; 13 | unsigned char k_xor_opad[128]; 14 | unsigned char *catbuf; 15 | int i; 16 | 17 | if(sizeof(hashbuf) < (size_t) hlen) 18 | return false; 19 | if(sizeof(k_xor_ipad) < (size_t) hblock) 20 | return false; 21 | if(sizeof(k_xor_ipad) < (size_t) hlen) 22 | return false; 23 | 24 | catbuf = (unsigned char *)Mem_Alloc(tempmempool, (size_t) hblock + max((size_t) hlen, (size_t) n)); 25 | 26 | if(k > hblock) 27 | { 28 | // hash the key if it is too long 29 | hfunc(k_xor_opad, key, k); 30 | key = k_xor_opad; 31 | k = hlen; 32 | } 33 | 34 | if(k < hblock) 35 | { 36 | // zero pad the key if it is too short 37 | if(key != k_xor_opad) 38 | memcpy(k_xor_opad, key, k); 39 | for(i = k; i < hblock; ++i) 40 | k_xor_opad[i] = 0; 41 | key = k_xor_opad; 42 | k = hblock; 43 | } 44 | 45 | for(i = 0; i < hblock; ++i) 46 | { 47 | k_xor_ipad[i] = key[i] ^ 0x36; 48 | k_xor_opad[i] = key[i] ^ 0x5c; 49 | } 50 | 51 | memcpy(catbuf, k_xor_ipad, hblock); 52 | memcpy(catbuf + hblock, in, n); 53 | hfunc(hashbuf, catbuf, hblock + n); 54 | memcpy(catbuf, k_xor_opad, hblock); 55 | memcpy(catbuf + hblock, hashbuf, hlen); 56 | hfunc(out, catbuf, hblock + hlen); 57 | 58 | Mem_Free(catbuf); 59 | 60 | return true; 61 | } 62 | -------------------------------------------------------------------------------- /hmac.h: -------------------------------------------------------------------------------- 1 | #ifndef HMAC_H 2 | #define HMAC_H 3 | 4 | #include "qtypes.h" 5 | 6 | typedef void (*hashfunc_t) (unsigned char *out, const unsigned char *in, int n); 7 | qbool hmac( 8 | hashfunc_t hfunc, int hlen, int hblock, 9 | unsigned char *out, 10 | const unsigned char *in, int n, 11 | const unsigned char *key, int k 12 | ); 13 | 14 | #define HMAC_MDFOUR_16BYTES(out, in, n, key, k) hmac(mdfour, 16, 64, out, in, n, key, k) 15 | #define HMAC_SHA256_32BYTES(out, in, n, key, k) hmac(sha256, 32, 64, out, in, n, key, k) 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /host.h: -------------------------------------------------------------------------------- 1 | #ifndef HOST_H 2 | #define HOST_H 3 | 4 | #include 5 | #include "qtypes.h" 6 | #include "qdefs.h" 7 | #include "cmd.h" 8 | #include "cvar.h" 9 | 10 | extern cvar_t developer; 11 | extern cvar_t developer_entityparsing; 12 | extern cvar_t developer_extra; 13 | extern cvar_t developer_insane; 14 | extern cvar_t developer_loadfile; 15 | extern cvar_t developer_loading; 16 | extern cvar_t host_isclient; 17 | extern cvar_t sessionid; 18 | 19 | struct cmd_state_s; 20 | 21 | typedef enum host_state_e 22 | { 23 | host_init, 24 | host_loading, 25 | host_active, 26 | /// states >= host_shutdown cause graceful shutdown, see Sys_HandleCrash() comments 27 | host_shutdown, 28 | host_failing, ///< crashing (inside crash handler) 29 | host_failed ///< crashed or aborted, SDL dialog open 30 | } host_state_t; 31 | static const char * const host_state_str[] = 32 | { 33 | [host_init] = "init", 34 | [host_loading] = "loading", 35 | [host_active] = "normal operation", 36 | [host_shutdown] = "shutdown", 37 | [host_failing] = "crashing", 38 | [host_failed] = "crashed", 39 | }; 40 | 41 | typedef struct host_static_s 42 | { 43 | jmp_buf abortframe; 44 | int state; 45 | unsigned int framecount; ///< incremented every frame, never reset, >0 means Host_AbortCurrentFrame() is possible 46 | double realtime; ///< the accumulated mainloop time since application started (with filtering), without any slowmo or clamping 47 | double dirtytime; ///< the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame 48 | double sleeptime; ///< time spent sleeping after the last frame 49 | qbool restless; ///< don't sleep 50 | qbool paused; ///< global paused state, pauses both client and server 51 | cmd_buf_t *cbuf; 52 | 53 | struct 54 | { 55 | void (*ConnectLocal)(void); 56 | void (*Disconnect)(qbool, const char *, ... ); 57 | void (*ToggleMenu)(void); 58 | void (*CL_SendCvar)(struct cmd_state_s *); 59 | void (*SV_SendCvar)(struct cmd_state_s *); 60 | void (*SV_Shutdown)(void); 61 | } hook; 62 | } host_static_t; 63 | 64 | extern host_static_t host; 65 | void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN; 66 | void Host_UpdateVersion(void); 67 | void Host_LockSession(void); 68 | void Host_UnlockSession(void); 69 | void Host_AbortCurrentFrame(void) DP_FUNC_NORETURN; 70 | void Host_SaveConfig(const char *file); 71 | void Host_Init(void); 72 | double Host_Frame(double time); 73 | void Host_Shutdown(void); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /image.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef IMAGE_H 3 | #define IMAGE_H 4 | 5 | #include 6 | #include "qtypes.h" 7 | #include "cvar.h" 8 | #include "r_textures.h" 9 | 10 | extern int image_width, image_height; 11 | 12 | unsigned char *Image_GenerateNoTexture(void); 13 | 14 | // swizzle components (even converting number of components) and flip images 15 | // (warning: input must be different than output due to non-linear read/write) 16 | // (tip: component indices can contain values | 0x80000000 to tell it to 17 | // store them directly into output, so 255 | 0x80000000 would write 255) 18 | void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int inputwidth, int inputheight, qbool inputflipx, qbool inputflipy, qbool inputflipdiagonal, int numoutputcomponents, int numinputcomponents, int *outputinputcomponentindices); 19 | 20 | // applies gamma correction to RGB pixels, in can be the same as out 21 | void Image_GammaRemapRGB(const unsigned char *in, unsigned char *out, int pixels, const unsigned char *gammar, const unsigned char *gammag, const unsigned char *gammab); 22 | 23 | // converts 8bit image data to BGRA, in can not be the same as out 24 | void Image_Copy8bitBGRA(const unsigned char *in, unsigned char *out, int pixels, const unsigned int *pal); 25 | 26 | void Image_StripImageExtension (const char *in, char *out, size_t size_out); 27 | 28 | // called by conchars.tga loader in gl_draw.c, otherwise private 29 | unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize, int *miplevel); 30 | 31 | // loads a texture, as pixel data 32 | unsigned char *loadimagepixelsbgra (const char *filename, qbool complain, qbool allowFixtrans, qbool convertsRGB, int *miplevel); 33 | 34 | // searches for lmp and wad pics of the provided name and returns true and their dimensions if found 35 | qbool Image_GetStockPicSize(const char *filename, int *returnwidth, int *returnheight); 36 | 37 | // loads an 8bit pcx image into a 296x194x8bit buffer, with cropping as needed 38 | qbool LoadPCX_QWSkin(const unsigned char *f, int filesize, unsigned char *pixels, int outwidth, int outheight); 39 | 40 | // loads the palette from an 8bit pcx image into your provided array 41 | qbool LoadPCX_PaletteOnly(const unsigned char *f, int filesize, unsigned char *palette768b); 42 | 43 | // get the metadata from a Quake2 wal file 44 | qbool LoadWAL_GetMetadata(const unsigned char *f, int filesize, int *retwidth, int *retheight, int *retflags, int *retvalue, int *retcontents, char *retanimname32c); 45 | 46 | // loads a texture, as a texture 47 | rtexture_t *loadtextureimage (rtexturepool_t *pool, const char *filename, qbool complain, int flags, qbool allowFixtrans, qbool sRGB); 48 | 49 | // writes an upside down BGR image into a TGA 50 | qbool Image_WriteTGABGR_preflipped (const char *filename, int width, int height, const unsigned char *data); 51 | 52 | // writes a BGRA image into a TGA file 53 | qbool Image_WriteTGABGRA (const char *filename, int width, int height, const unsigned char *data); 54 | 55 | // resizes the image (in can not be the same as out) 56 | void Image_Resample32(const void *indata, int inwidth, int inheight, int indepth, void *outdata, int outwidth, int outheight, int outdepth, int quality); 57 | 58 | // scales the image down by a power of 2 (in can be the same as out) 59 | void Image_MipReduce32(const unsigned char *in, unsigned char *out, int *width, int *height, int *depth, int destwidth, int destheight, int destdepth); 60 | 61 | void Image_HeightmapToNormalmap_BGRA(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale); 62 | 63 | // console command to fix the colors of transparent pixels (to prevent weird borders) 64 | void Image_FixTransparentPixels_f(cmd_state_t *cmd); 65 | extern cvar_t r_fixtrans_auto; 66 | 67 | #define Image_LinearFloatFromsRGBFloat(c) (((c) <= 0.04045f) ? (c) * (1.0f / 12.92f) : (float)pow(((c) + 0.055f)*(1.0f/1.055f), 2.4f)) 68 | #define Image_sRGBFloatFromLinearFloat(c) (((c) < 0.0031308f) ? (c) * 12.92f : 1.055f * (float)pow((c), 1.0f/2.4f) - 0.055f) 69 | #define Image_LinearFloatFromsRGB(c) Image_LinearFloatFromsRGBFloat((c) * (1.0f / 255.0f)) 70 | #define Image_sRGBFloatFromLinear(c) Image_sRGBFloatFromLinearFloat((c) * (1.0f / 255.0f)) 71 | #define Image_sRGBFloatFromLinear_Lightmap(c) Image_sRGBFloatFromLinearFloat((c) * (2.0f / 255.0f)) * 0.5f 72 | 73 | void Image_MakeLinearColorsFromsRGB(unsigned char *pout, const unsigned char *pin, int numpixels); 74 | void Image_MakesRGBColorsFromLinear_Lightmap(unsigned char *pout, const unsigned char *pin, int numpixels); 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /image_png.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006 Serge "(515)" Ziryukin 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to: 17 | 18 | Free Software Foundation, Inc. 19 | 59 Temple Place - Suite 330 20 | Boston, MA 02111-1307, USA 21 | 22 | */ 23 | 24 | #ifndef PNG_H 25 | #define PNG_H 26 | 27 | #include "qtypes.h" 28 | 29 | qbool PNG_OpenLibrary (void); 30 | void PNG_CloseLibrary (void); 31 | unsigned char* PNG_LoadImage_BGRA (const unsigned char *f, int filesize, int *miplevel); 32 | qbool PNG_SaveImage_preflipped (const char *filename, int width, int height, qbool has_alpha, unsigned char *data); 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /// \file input.h -- external (non-keyboard) input devices 21 | 22 | #ifndef INPUT_H 23 | #define INPUT_H 24 | 25 | #include "qtypes.h" 26 | #include "cvar.h" 27 | 28 | extern cvar_t in_pitch_min; 29 | extern cvar_t in_pitch_max; 30 | 31 | extern qbool in_client_mouse; 32 | extern float in_windowmouse_x, in_windowmouse_y; 33 | extern float in_mouse_x, in_mouse_y; 34 | 35 | //enum input_dest_e {input_game,input_message,input_menu} input_dest; 36 | 37 | void IN_Move (void); 38 | // add additional movement on top of the keyboard move cmd 39 | 40 | #define IN_BESTWEAPON_MAX 32 41 | typedef struct 42 | { 43 | char name[32]; 44 | int impulse; 45 | int activeweaponcode; 46 | int weaponbit; 47 | int ammostat; 48 | int ammomin; 49 | /// \TODO add a parameter for the picture to be used by the sbar, and use it there 50 | } 51 | in_bestweapon_info_t; 52 | extern in_bestweapon_info_t in_bestweapon_info[IN_BESTWEAPON_MAX]; 53 | void IN_BestWeapon_ResetData(void); ///< call before each map so QC can start from a clean state 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /jpeg.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Mathieu Olivier 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to: 17 | 18 | Free Software Foundation, Inc. 19 | 59 Temple Place - Suite 330 20 | Boston, MA 02111-1307, USA 21 | 22 | */ 23 | 24 | #ifndef JPEG_H 25 | #define JPEG_H 26 | 27 | #include 28 | #include "qtypes.h" 29 | 30 | qbool JPEG_OpenLibrary (void); 31 | void JPEG_CloseLibrary (void); 32 | unsigned char* JPEG_LoadImage_BGRA (const unsigned char *f, int filesize, int *miplevel); 33 | qbool JPEG_SaveImage_preflipped (const char *filename, int width, int height, unsigned char *data); 34 | 35 | /*! \returns 0 if failed, or the size actually used. 36 | */ 37 | size_t JPEG_SaveImage_to_Buffer (char *jpegbuf, size_t jpegsize, int width, int height, unsigned char *data); 38 | qbool Image_Compress(const char *imagename, size_t maxsize, void **buf, size_t *size); 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lhnet.h: -------------------------------------------------------------------------------- 1 | 2 | // Written by Ashley Rose Hale (LadyHavoc) 2003-06-15 and placed into public domain. 3 | 4 | #ifndef LHNET_H 5 | #define LHNET_H 6 | 7 | #include 8 | #include "com_list.h" 9 | 10 | typedef enum lhnetaddresstype_e 11 | { 12 | LHNETADDRESSTYPE_NONE, 13 | LHNETADDRESSTYPE_LOOP, 14 | LHNETADDRESSTYPE_INET4, 15 | LHNETADDRESSTYPE_INET6 16 | } 17 | lhnetaddresstype_t; 18 | 19 | typedef struct lhnetaddress_s 20 | { 21 | lhnetaddresstype_t addresstype; 22 | int port; // used by LHNETADDRESSTYPE_LOOP 23 | unsigned char storage[256]; // sockaddr_in or sockaddr_in6 24 | } 25 | lhnetaddress_t; 26 | 27 | int LHNETADDRESS_FromPort(lhnetaddress_t *address, lhnetaddresstype_t addresstype, int port); 28 | int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int defaultport); 29 | /// Returns the number of bytes written to *string excluding the \0 terminator. 30 | int LHNETADDRESS_ToString(const lhnetaddress_t *address, char *string, int stringbuffersize, int includeport); 31 | static inline lhnetaddresstype_t LHNETADDRESS_GetAddressType(const lhnetaddress_t *address) 32 | { 33 | if (address) 34 | return address->addresstype; 35 | else 36 | return LHNETADDRESSTYPE_NONE; 37 | } 38 | const char *LHNETADDRESS_GetInterfaceName(const lhnetaddress_t *address, char *ifname, size_t ifnamelength); 39 | int LHNETADDRESS_GetPort(const lhnetaddress_t *address); 40 | int LHNETADDRESS_SetPort(lhnetaddress_t *address, int port); 41 | int LHNETADDRESS_Compare(const lhnetaddress_t *address1, const lhnetaddress_t *address2); 42 | 43 | typedef struct lhnetsocket_s 44 | { 45 | lhnetaddress_t address; 46 | int inetsocket; 47 | llist_t list; 48 | } 49 | lhnetsocket_t; 50 | extern lhnetsocket_t lhnet_socketlist; 51 | 52 | void LHNET_Init(void); 53 | void LHNET_Shutdown(void); 54 | int LHNET_DefaultDSCP(int dscp); // < 0: query; >= 0: set (returns previous value) 55 | void LHNET_SleepUntilPacket_Microseconds(int microseconds); 56 | lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address); 57 | void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket); 58 | lhnetaddress_t *LHNET_AddressFromSocket(lhnetsocket_t *sock); 59 | int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, lhnetaddress_t *address); 60 | int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentlength, const lhnetaddress_t *address); 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /libcurl.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qtypes.h" 3 | #include "qdefs.h" 4 | 5 | enum 6 | { 7 | CURLCBSTATUS_OK = 0, 8 | CURLCBSTATUS_FAILED = -1, // failed for generic reason (e.g. buffer too small) 9 | CURLCBSTATUS_ABORTED = -2, // aborted by curl --cancel 10 | CURLCBSTATUS_SERVERERROR = -3, // only used if no HTTP status code is available 11 | CURLCBSTATUS_UNKNOWN = -4 // should never happen 12 | }; 13 | typedef void (*curl_callback_t) (int status, size_t length_received, unsigned char *buffer, void *cbdata); 14 | // code is one of the CURLCBSTATUS constants, or the HTTP error code (when > 0). 15 | 16 | void Curl_Frame(void); 17 | bool Curl_Select(int timeout_ms); 18 | qbool Curl_Running(void); 19 | qbool Curl_Begin_ToFile(const char *URL, double maxspeed, const char *name, int loadtype, qbool forthismap); 20 | 21 | qbool Curl_Begin_ToMemory(const char *URL, double maxspeed, unsigned char *buf, size_t bufsize, curl_callback_t callback, void *cbdata); 22 | qbool Curl_Begin_ToMemory_POST(const char *URL, const char *extraheaders, double maxspeed, const char *post_content_type, const unsigned char *postbuf, size_t postbufsize, unsigned char *buf, size_t bufsize, curl_callback_t callback, void *cbdata); 23 | void Curl_Cancel_ToMemory(curl_callback_t callback, void* cbdata); 24 | 25 | void Curl_Init(void); 26 | void Curl_Init_Commands(void); 27 | void Curl_Shutdown(void); 28 | qbool Curl_Available(void); 29 | void Curl_CancelAll(void); 30 | void Curl_Clear_forthismap(void); 31 | qbool Curl_Have_forthismap(void); 32 | void Curl_Register_predownload(void); 33 | 34 | void Curl_ClearRequirements(void); 35 | void Curl_RequireFile(const char *filename); 36 | void Curl_SendRequirements(void); 37 | 38 | typedef struct Curl_downloadinfo_s 39 | { 40 | char filename[MAX_QPATH]; 41 | double progress; 42 | double speed; 43 | qbool queued; 44 | } 45 | Curl_downloadinfo_t; 46 | Curl_downloadinfo_t *Curl_GetDownloadInfo(int *nDownloads, const char **additional_info, char *addinfo, size_t addinfolength); 47 | // this may and should be Z_Free()ed 48 | // the result is actually an array 49 | // an additional info string may be returned in additional_info as a 50 | // pointer to a static string (but the argument may be NULL if the caller 51 | // does not care) 52 | -------------------------------------------------------------------------------- /mdfour.h: -------------------------------------------------------------------------------- 1 | /* 2 | mdfour.h 3 | 4 | an implementation of MD4 designed for use in the SMB authentication 5 | protocol 6 | 7 | Copyright (C) Andrew Tridgell 1997-1998 8 | 9 | This program is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU General Public License 11 | as published by the Free Software Foundation; either version 2 12 | of the License, or (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | 18 | See the GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program; if not, write to: 22 | 23 | Free Software Foundation, Inc. 24 | 59 Temple Place - Suite 330 25 | Boston, MA 02111-1307, USA 26 | */ 27 | 28 | #ifndef _MDFOUR_H 29 | #define _MDFOUR_H 30 | 31 | #include 32 | 33 | struct mdfour_s { 34 | uint32_t A, B, C, D; 35 | uint32_t totalN; 36 | }; 37 | 38 | void mdfour_begin(struct mdfour_s *md); // old: MD4Init 39 | void mdfour_update(struct mdfour_s *md, const unsigned char *in, int n); //old: MD4Update 40 | void mdfour_result(struct mdfour_s *md, unsigned char *out); // old: MD4Final 41 | void mdfour(unsigned char *out, const unsigned char *in, int n); 42 | 43 | #endif // _MDFOUR_H 44 | 45 | -------------------------------------------------------------------------------- /menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef MENU_H 22 | #define MENU_H 23 | 24 | #include "qtypes.h" 25 | struct serverlist_entry_s; 26 | 27 | enum m_state_e { 28 | m_none, 29 | m_main, 30 | m_demo, 31 | m_singleplayer, 32 | m_transfusion_episode, 33 | m_transfusion_skill, 34 | m_load, 35 | m_save, 36 | m_multiplayer, 37 | m_setup, 38 | m_options, 39 | m_video, 40 | m_keys, 41 | m_help, 42 | m_credits, 43 | m_quit, 44 | m_lanconfig, 45 | m_gameoptions, 46 | m_slist, 47 | m_options_effects, 48 | m_options_graphics, 49 | m_options_colorcontrol, 50 | m_reset, 51 | m_modlist 52 | }; 53 | 54 | extern enum m_state_e m_state; 55 | 56 | 57 | /* 58 | // hard-coded menus 59 | // 60 | void M_Init (void); 61 | void M_KeyEvent (int key); 62 | void M_Draw (void); 63 | void M_ToggleMenu (int mode); 64 | 65 | // 66 | // menu prog menu 67 | // 68 | void MP_Init (void); 69 | void MP_KeyEvent (int key); 70 | void MP_Draw (void); 71 | void MP_ToggleMenu (int mode); 72 | void MP_Shutdown (void);*/ 73 | 74 | qbool MP_ConsoleCommand(const char *text, size_t textlen); 75 | 76 | // 77 | // menu router 78 | // 79 | 80 | void MR_Init_Commands (void); 81 | void MR_Init (void); 82 | void MR_Restart (void); 83 | extern void (*MR_KeyEvent) (int key, int ascii, qbool downevent); 84 | extern void (*MR_Draw) (void); 85 | extern void (*MR_ToggleMenu) (int mode); 86 | extern void (*MR_Shutdown) (void); 87 | extern void (*MR_NewMap) (void); 88 | extern int (*MR_GetServerListEntryCategory) (const struct serverlist_entry_s *entry); 89 | 90 | // menu QC error handling 91 | extern jmp_buf mp_abort; 92 | 93 | typedef struct video_resolution_s 94 | { 95 | const char *type; 96 | int width, height; 97 | int conwidth, conheight; 98 | double pixelheight; ///< pixel aspect 99 | } 100 | video_resolution_t; 101 | extern video_resolution_t *video_resolutions; 102 | extern int video_resolutions_count; 103 | extern video_resolution_t video_resolutions_hardcoded[]; 104 | extern int video_resolutions_hardcoded_count; 105 | #endif 106 | 107 | -------------------------------------------------------------------------------- /meshqueue.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MESHQUEUE_H 3 | #define MESHQUEUE_H 4 | 5 | // VorteX: seems this value is hardcoded in other several defines as it's changing makes mess 6 | #define MESHQUEUE_TRANSPARENT_BATCHSIZE 256 7 | 8 | void R_MeshQueue_BeginScene(void); 9 | void R_MeshQueue_AddTransparent(dptransparentsortcategory_t category, const vec3_t center, void (*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight); 10 | void R_MeshQueue_RenderTransparent(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /mingw_note.txt: -------------------------------------------------------------------------------- 1 | For compiling Darkplaces with MinGW, you need the following files which do not 2 | come in the standard MinGW installation: 3 | - include/ddraw.h 4 | - include/dinput.h 5 | - include/dsound.h 6 | They are part of the DirectX SDK but can also be found in the original release 7 | of Quake 1 source code (ftp://ftp.idsoftware.com/idstuff/source/q1source.zip). 8 | 9 | Assuming the MinGW binaries are in your PATH, you compile Darkplaces by typing 10 | "make release". Note that "make" may be named "mingw32-make", so you may want 11 | to try "mingw32-make release" if the first command fails to run. 12 | 13 | For cross-compiling Win32 binaries on Linux using MinGW, you need to force the 14 | makefile to use the MinGW compilation parameters, otherwise it will autodetect 15 | the operating system it runs on and will use the corresponding parameters. You 16 | can force it by appending "DP_MAKE_TARGET=mingw" at the end of the command line. 17 | -------------------------------------------------------------------------------- /mod_skeletal_animatevertices_generic.h: -------------------------------------------------------------------------------- 1 | #ifndef MOD_SKELETAL_ANIMATEVERTICES_GENERIC_H 2 | #define MOD_H 3 | 4 | #include "quakedef.h" 5 | 6 | void Mod_Skeletal_AnimateVertices_Generic(const model_t * RESTRICT model, const frameblend_t * RESTRICT frameblend, const skeleton_t *skeleton, float * RESTRICT vertex3f, float * RESTRICT normal3f, float * RESTRICT svector3f, float * RESTRICT tvector3f); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /mod_skeletal_animatevertices_sse.h: -------------------------------------------------------------------------------- 1 | #ifndef MOD_SKELTAL_ANIMATEVERTICES_SSE_H 2 | #define MOD_SKELTAL_ANIMATEVERTICES_SSE_H 3 | 4 | #include "quakedef.h" 5 | 6 | #ifdef SSE_POSSIBLE 7 | void Mod_Skeletal_AnimateVertices_SSE(const model_t * RESTRICT model, const frameblend_t * RESTRICT frameblend, const skeleton_t *skeleton, float * RESTRICT vertex3f, float * RESTRICT normal3f, float * RESTRICT svector3f, float * RESTRICT tvector3f); 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /model_iqm.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODEL_IQM_H__ 2 | #define __MODEL_IQM_H__ 3 | 4 | typedef struct iqmheader_s 5 | { 6 | char id[16]; 7 | unsigned int version; 8 | unsigned int filesize; 9 | unsigned int flags; 10 | unsigned int num_text, ofs_text; 11 | unsigned int num_meshes, ofs_meshes; 12 | unsigned int num_vertexarrays, num_vertexes, ofs_vertexarrays; 13 | unsigned int num_triangles, ofs_triangles, ofs_neighbors; 14 | unsigned int num_joints, ofs_joints; 15 | unsigned int num_poses, ofs_poses; 16 | unsigned int num_anims, ofs_anims; 17 | unsigned int num_frames, num_framechannels, ofs_frames, ofs_bounds; 18 | unsigned int num_comment, ofs_comment; 19 | unsigned int num_extensions, ofs_extensions; 20 | } 21 | iqmheader_t; 22 | 23 | typedef struct iqmmesh_s 24 | { 25 | unsigned int name; 26 | unsigned int material; 27 | unsigned int first_vertex, num_vertexes; 28 | unsigned int first_triangle, num_triangles; 29 | } 30 | iqmmesh_t; 31 | 32 | #define IQM_POSITION 0 33 | #define IQM_TEXCOORD 1 34 | #define IQM_NORMAL 2 35 | #define IQM_TANGENT 3 36 | #define IQM_BLENDINDEXES 4 37 | #define IQM_BLENDWEIGHTS 5 38 | #define IQM_COLOR 6 39 | #define IQM_CUSTOM 0x10 40 | 41 | #define IQM_BYTE 0 42 | #define IQM_UBYTE 1 43 | #define IQM_SHORT 2 44 | #define IQM_USHORT 3 45 | #define IQM_INT 4 46 | #define IQM_UINT 5 47 | #define IQM_HALF 6 48 | #define IQM_FLOAT 7 49 | #define IQM_DOUBLE 8 50 | 51 | // animflags 52 | #define IQM_LOOP 1 53 | 54 | typedef struct iqmtriangle_s 55 | { 56 | unsigned int vertex[3]; 57 | } 58 | iqmtriangle_t; 59 | 60 | typedef struct iqmjoint1_s 61 | { 62 | unsigned int name; 63 | signed int parent; 64 | float origin[3], rotation[3], scale[3]; 65 | } 66 | iqmjoint1_t; 67 | 68 | typedef struct iqmjoint_s 69 | { 70 | unsigned int name; 71 | signed int parent; 72 | float origin[3], rotation[4], scale[3]; 73 | } 74 | iqmjoint_t; 75 | 76 | typedef struct iqmpose1_s 77 | { 78 | signed int parent; 79 | unsigned int channelmask; 80 | float channeloffset[9], channelscale[9]; 81 | } 82 | iqmpose1_t; 83 | 84 | typedef struct iqmpose_s 85 | { 86 | signed int parent; 87 | unsigned int channelmask; 88 | float channeloffset[10], channelscale[10]; 89 | } 90 | iqmpose_t; 91 | 92 | typedef struct iqmanim_s 93 | { 94 | unsigned int name; 95 | unsigned int first_frame, num_frames; 96 | float framerate; 97 | unsigned int flags; 98 | } 99 | iqmanim_t; 100 | 101 | typedef struct iqmvertexarray_s 102 | { 103 | unsigned int type; 104 | unsigned int flags; 105 | unsigned int format; 106 | unsigned int size; 107 | unsigned int offset; 108 | } 109 | iqmvertexarray_t; 110 | 111 | typedef struct iqmextension_s 112 | { 113 | unsigned int name; 114 | unsigned int num_data, ofs_data; 115 | unsigned int ofs_extensions; // pointer to next extension 116 | } 117 | iqmextension_t; 118 | 119 | typedef struct iqmbounds_s 120 | { 121 | float mins[3], maxs[3]; 122 | float xyradius, radius; 123 | } 124 | iqmbounds_t; 125 | 126 | #endif 127 | 128 | -------------------------------------------------------------------------------- /model_psk.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MODEL_PSK_H 3 | #define MODEL_PSK_H 4 | 5 | typedef struct pskchunk_s 6 | { 7 | // id is one of the following: 8 | // .psk: 9 | // ACTRHEAD (recordsize = 0, numrecords = 0) 10 | // PNTS0000 (recordsize = 12, pskpnts_t) 11 | // VTXW0000 (recordsize = 16, pskvtxw_t) 12 | // FACE0000 (recordsize = 12, pskface_t) 13 | // MATT0000 (recordsize = 88, pskmatt_t) 14 | // REFSKELT (recordsize = 120, pskboneinfo_t) 15 | // RAWWEIGHTS (recordsize = 12, pskrawweights_t) 16 | // .psa: 17 | // ANIMHEAD (recordsize = 0, numrecords = 0) 18 | // BONENAMES (recordsize = 120, pskboneinfo_t) 19 | // ANIMINFO (recordsize = 168, pskaniminfo_t) 20 | // ANIMKEYS (recordsize = 32, pskanimkeys_t) 21 | char id[20]; 22 | // in .psk always 0x1e83b9 23 | // in .psa always 0x2e 24 | int version; 25 | int recordsize; 26 | int numrecords; 27 | } 28 | pskchunk_t; 29 | 30 | typedef struct pskpnts_s 31 | { 32 | float origin[3]; 33 | } 34 | pskpnts_t; 35 | 36 | typedef struct pskvtxw_s 37 | { 38 | unsigned short pntsindex; // index into PNTS0000 chunk 39 | unsigned char unknown1[2]; // seems to be garbage 40 | float texcoord[2]; 41 | unsigned char mattindex; // index into MATT0000 chunk 42 | unsigned char unknown2; // always 0? 43 | unsigned char unknown3[2]; // seems to be garbage 44 | } 45 | pskvtxw_t; 46 | 47 | typedef struct pskface_s 48 | { 49 | unsigned short vtxwindex[3]; // triangle 50 | unsigned char mattindex; // index into MATT0000 chunk 51 | unsigned char unknown; // seems to be garbage 52 | unsigned int group; // faces seem to be grouped, possibly for smoothing? 53 | } 54 | pskface_t; 55 | 56 | typedef struct pskmatt_s 57 | { 58 | char name[64]; 59 | int unknown[6]; // observed 0 0 0 0 5 0 60 | } 61 | pskmatt_t; 62 | 63 | typedef struct pskpose_s 64 | { 65 | float quat[4]; 66 | float origin[3]; 67 | float unknown; // probably a float, always seems to be 0 68 | float size[3]; 69 | } 70 | pskpose_t; 71 | 72 | typedef struct pskboneinfo_s 73 | { 74 | char name[64]; 75 | int unknown1; 76 | int numchildren; 77 | int parent; // root bones have 0 here 78 | pskpose_t basepose; 79 | } 80 | pskboneinfo_t; 81 | 82 | typedef struct pskrawweights_s 83 | { 84 | float weight; 85 | int pntsindex; 86 | int boneindex; 87 | } 88 | pskrawweights_t; 89 | 90 | typedef struct pskaniminfo_s 91 | { 92 | char name[64]; 93 | char group[64]; 94 | int numbones; 95 | int unknown1; 96 | int unknown2; 97 | int unknown3; 98 | float unknown4; 99 | float playtime; // not really needed 100 | float fps; // frames per second 101 | int unknown5; 102 | int firstframe; 103 | int numframes; 104 | // firstanimkeys = (firstframe + frameindex) * numbones 105 | } 106 | pskaniminfo_t; 107 | 108 | typedef struct pskanimkeys_s 109 | { 110 | float origin[3]; 111 | float quat[4]; 112 | float frametime; 113 | } 114 | pskanimkeys_t; 115 | 116 | #endif 117 | 118 | -------------------------------------------------------------------------------- /model_q1bsp.h: -------------------------------------------------------------------------------- 1 | #ifndef MODEL_Q1BSP_H 2 | #define MODEL_Q1BSP_H 3 | 4 | #include "qtypes.h" 5 | #include "model_brush.h" 6 | 7 | typedef struct model_brushq1_s 8 | { 9 | mmodel_t *submodels; 10 | 11 | int numvertexes; 12 | mvertex_t *vertexes; 13 | 14 | int numedges; 15 | medge_t *edges; 16 | 17 | int numtexinfo; 18 | struct mtexinfo_s *texinfo; 19 | 20 | int numsurfedges; 21 | int *surfedges; 22 | 23 | int numclipnodes; 24 | mclipnode_t *clipnodes; 25 | 26 | hull_t hulls[MAX_MAP_HULLS]; 27 | 28 | int num_compressedpvs; 29 | unsigned char *data_compressedpvs; 30 | 31 | int num_lightdata; 32 | unsigned char *lightdata; 33 | unsigned char *nmaplightdata; // deluxemap file 34 | 35 | // lightmap update chains for light styles 36 | int num_lightstyles; 37 | model_brush_lightstyleinfo_t *data_lightstyleinfo; 38 | 39 | // this contains bytes that are 1 if a surface needs its lightmap rebuilt 40 | unsigned char *lightmapupdateflags; 41 | qbool firstrender; // causes all surface lightmaps to be loaded in first frame 42 | } 43 | model_brushq1_t; 44 | 45 | #endif -------------------------------------------------------------------------------- /model_sprite.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef MODEL_SPRITE_H 22 | #define MODEL_SPRITE_H 23 | 24 | /* 25 | ============================================================================== 26 | 27 | SPRITE MODELS 28 | 29 | ============================================================================== 30 | */ 31 | 32 | #include "spritegn.h" 33 | 34 | // FIXME: shorten these? 35 | typedef struct mspriteframe_s 36 | { 37 | float up, down, left, right; 38 | } mspriteframe_t; 39 | 40 | typedef struct model_sprite_s 41 | { 42 | int sprnum_type; 43 | mspriteframe_t *sprdata_frames; 44 | } 45 | model_sprite_t; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /model_zymotic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MODEL_ZYMOTIC_H 3 | #define MODEL_ZYMOTIC_H 4 | 5 | typedef struct zymlump_s 6 | { 7 | int start; 8 | int length; 9 | } zymlump_t; 10 | 11 | typedef struct zymtype1header_s 12 | { 13 | char id[12]; // "ZYMOTICMODEL", length 12, no termination 14 | int type; // 0 (vertex morph) 1 (skeletal pose) or 2 (skeletal scripted) 15 | int filesize; // size of entire model file 16 | float mins[3], maxs[3], radius; // for clipping uses 17 | int numverts; 18 | int numtris; 19 | int numshaders; 20 | int numbones; // this may be zero in the vertex morph format (undecided) 21 | int numscenes; // 0 in skeletal scripted models 22 | 23 | // skeletal pose header 24 | // lump offsets are relative to the file 25 | zymlump_t lump_scenes; // zymscene_t scene[numscenes]; // name and other information for each scene (see zymscene struct) 26 | zymlump_t lump_poses; // float pose[numposes][numbones][6]; // animation data 27 | zymlump_t lump_bones; // zymbone_t bone[numbones]; 28 | zymlump_t lump_vertbonecounts; // int vertbonecounts[numvertices]; // how many bones influence each vertex (separate mainly to make this compress better) 29 | zymlump_t lump_verts; // zymvertex_t vert[numvertices]; // see vertex struct 30 | zymlump_t lump_texcoords; // float texcoords[numvertices][2]; 31 | zymlump_t lump_render; // int renderlist[rendersize]; // sorted by shader with run lengths (int count), shaders are sequentially used, each run can be used with glDrawElements (each triangle is 3 int indices) 32 | zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model 33 | zymlump_t lump_trizone; // byte trizone[numtris]; // see trizone explanation 34 | } 35 | zymtype1header_t; 36 | 37 | #define ZYMBONEFLAG_SHARED 1 38 | 39 | typedef struct zymbone_s 40 | { 41 | char name[32]; 42 | int flags; 43 | int parent; // parent bone number 44 | } 45 | zymbone_t; 46 | 47 | // normally the scene will loop, if this is set it will stay on the final frame 48 | #define ZYMSCENEFLAG_NOLOOP 1 49 | 50 | typedef struct zymscene_s 51 | { 52 | char name[32]; 53 | float mins[3], maxs[3], radius; // for clipping 54 | float framerate; // the scene will animate at this framerate (in frames per second) 55 | int flags; 56 | int start, length; // range of poses 57 | } 58 | zymscene_t; 59 | 60 | typedef struct zymvertex_s 61 | { 62 | int bonenum; 63 | float origin[3]; 64 | } 65 | zymvertex_t; 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /modelgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // modelgen.h: header file for model generation program 22 | // 23 | 24 | // ********************************************************* 25 | // * This file must be identical in the modelgen directory * 26 | // * and in the Quake directory, because it's used to * 27 | // * pass data from one to the other via model files. * 28 | // ********************************************************* 29 | 30 | #ifndef MODELGEN_H 31 | #define MODELGEN_H 32 | 33 | #include "qtypes.h" 34 | 35 | #define ALIAS_VERSION 6 36 | 37 | #define ALIAS_ONSEAM 0x0020 38 | 39 | typedef enum aliasframetype_e { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t; 40 | 41 | typedef enum aliasskintype_e { ALIAS_SKIN_SINGLE=0, ALIAS_SKIN_GROUP } aliasskintype_t; 42 | 43 | typedef struct mdl_s 44 | { 45 | int ident; 46 | int version; 47 | vec3_t scale; 48 | vec3_t scale_origin; 49 | float boundingradius; 50 | vec3_t eyeposition; 51 | int numskins; 52 | int skinwidth; 53 | int skinheight; 54 | int numverts; 55 | int numtris; 56 | int numframes; 57 | int synctype; 58 | int flags; 59 | float size; 60 | } 61 | mdl_t; 62 | 63 | // TODO: could be shorts 64 | 65 | typedef struct stvert_s 66 | { 67 | int onseam; 68 | int s; 69 | int t; 70 | } 71 | stvert_t; 72 | 73 | typedef struct dtriangle_s 74 | { 75 | int facesfront; 76 | int vertindex[3]; 77 | } 78 | dtriangle_t; 79 | 80 | #define DT_FACES_FRONT 0x0010 81 | 82 | // This mirrors trivert_t in trilib.h, is present so Quake knows how to 83 | // load this data 84 | 85 | typedef struct trivertx_s 86 | { 87 | unsigned char v[3]; 88 | unsigned char lightnormalindex; 89 | } 90 | trivertx_t; 91 | 92 | typedef struct daliasframe_s 93 | { 94 | trivertx_t bboxmin; // lightnormal isn't used 95 | trivertx_t bboxmax; // lightnormal isn't used 96 | char name[16]; // frame name from grabbing 97 | } 98 | daliasframe_t; 99 | 100 | typedef struct daliasgroup_s 101 | { 102 | int numframes; 103 | trivertx_t bboxmin; // lightnormal isn't used 104 | trivertx_t bboxmax; // lightnormal isn't used 105 | } 106 | daliasgroup_t; 107 | 108 | typedef struct daliasskingroup_s 109 | { 110 | int numskins; 111 | } 112 | daliasskingroup_t; 113 | 114 | typedef struct daliasinterval_s 115 | { 116 | float interval; 117 | } 118 | daliasinterval_t; 119 | 120 | typedef struct daliasskininterval_s 121 | { 122 | float interval; 123 | } 124 | daliasskininterval_t; 125 | 126 | typedef struct daliasframetype_s 127 | { 128 | aliasframetype_t type; 129 | } 130 | daliasframetype_t; 131 | 132 | typedef struct daliasskintype_s 133 | { 134 | aliasskintype_t type; 135 | } 136 | daliasskintype_t; 137 | 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /mprogdefs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MPROGDEFS_H 3 | #define MPROGDEFS_H 4 | 5 | /* file generated by qcc, do not modify */ 6 | 7 | /* 8 | typedef struct m_globalvars_s 9 | { 10 | int pad[28]; 11 | int self; 12 | } m_globalvars_t; 13 | 14 | typedef struct m_entvars_s 15 | { 16 | } m_entvars_t; 17 | 18 | #define M_PROGHEADER_CRC 10020 19 | 20 | */ 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /nexuiz.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DarkPlacesEngine/DarkPlaces/af1e5c03be8e2fd41135f9064ad8e4c4c1ccd8f4/nexuiz.ico -------------------------------------------------------------------------------- /nexuiz.rc: -------------------------------------------------------------------------------- 1 | #include // include for version info constants 2 | 3 | A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "nexuiz.ico" 4 | 5 | 1 VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | PRODUCTVERSION 1,0,0,0 8 | FILETYPE VFT_APP 9 | { 10 | BLOCK "StringFileInfo" 11 | { 12 | BLOCK "040904E4" 13 | { 14 | VALUE "CompanyName", "Forest Hale Digital Services" 15 | VALUE "FileVersion", "1.0" 16 | VALUE "FileDescription", "Nexuiz" 17 | VALUE "InternalName", "nexuiz.exe" 18 | VALUE "LegalCopyright", "id Software, Forest Hale, and contributors" 19 | VALUE "LegalTrademarks", "" 20 | VALUE "OriginalFilename", "nexuiz.exe" 21 | VALUE "ProductName", "Nexuiz" 22 | VALUE "ProductVersion", "1.0" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /nexuiz.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * nexuiz_xpm[] = { 3 | "48 48 91 1", 4 | " c None", 5 | ". c #0E100D", 6 | "+ c #131412", 7 | "@ c #1D1E1C", 8 | "# c #1F211E", 9 | "$ c #212320", 10 | "% c #232522", 11 | "& c #252724", 12 | "* c #272826", 13 | "= c #2A2C29", 14 | "- c #2D2E2C", 15 | "; c #2F312E", 16 | "> c #323331", 17 | ", c #343633", 18 | "' c #363735", 19 | ") c #383937", 20 | "! c #393B38", 21 | "~ c #3C3D3B", 22 | "{ c #3D3F3C", 23 | "] c #3F403E", 24 | "^ c #40413F", 25 | "/ c #414340", 26 | "( c #444643", 27 | "_ c #454744", 28 | ": c #464845", 29 | "< c #474946", 30 | "[ c #484947", 31 | "} c #494B48", 32 | "| c #4A4C4A", 33 | "1 c #4C4E4B", 34 | "2 c #4D4F4C", 35 | "3 c #4F514E", 36 | "4 c #50524F", 37 | "5 c #525351", 38 | "6 c #545653", 39 | "7 c #575956", 40 | "8 c #5A5C59", 41 | "9 c #5C5E5B", 42 | "0 c #5F615E", 43 | "a c #616360", 44 | "b c #636562", 45 | "c c #656764", 46 | "d c #686A67", 47 | "e c #6B6D6A", 48 | "f c #6E6F6D", 49 | "g c #70726F", 50 | "h c #727471", 51 | "i c #757774", 52 | "j c #787977", 53 | "k c #7B7D7A", 54 | "l c #7E807D", 55 | "m c #818380", 56 | "n c #838582", 57 | "o c #858784", 58 | "p c #878986", 59 | "q c #898B88", 60 | "r c #8C8E8B", 61 | "s c #8E908D", 62 | "t c #90928F", 63 | "u c #939592", 64 | "v c #959794", 65 | "w c #979996", 66 | "x c #9A9C99", 67 | "y c #9FA19E", 68 | "z c #A5A7A4", 69 | "A c #AAACA9", 70 | "B c #B0B2AF", 71 | "C c #B5B7B4", 72 | "D c #B9BBB8", 73 | "E c #BEC0BD", 74 | "F c #C3C5C2", 75 | "G c #C7CAC6", 76 | "H c #CDCFCB", 77 | "I c #D2D4D1", 78 | "J c #D5D8D4", 79 | "K c #D8DAD7", 80 | "L c #DBDDDA", 81 | "M c #DEE0DD", 82 | "N c #E1E3E0", 83 | "O c #E4E6E2", 84 | "P c #E7E9E6", 85 | "Q c #EAECE8", 86 | "R c #EDEFEC", 87 | "S c #F1F3EF", 88 | "T c #F3F5F2", 89 | "U c #F5F7F4", 90 | "V c #F7F9F6", 91 | "W c #F8FBF7", 92 | "X c #FAFCF9", 93 | "Y c #FBFDFA", 94 | "Z c #FDFFFC", 95 | " #%=--=&# ", 96 | " #'3ekoqrrrokd2,# ", 97 | " *3ke60kuxwuuvwxwtk6= ", 98 | " &7pxs[Cxb[6juuttttuvxr0= ", 99 | " @_nwutu2AZZLx8}quttttttuxq2# ", 100 | " %cuusssum}QZZZWw_stsssssssuwg= ", 101 | " =kvssssssv3yZYYZZgcussstuutssvn' ", 102 | " >murrrrrrrucjZXXYZy4vutqkc0iptuup! ", 103 | " -mtrrrrrrrrt0oZWWXZu}i81}8lpb11alur' ", 104 | " %isqqqqqqqqqs2AZWWYSe(drDMWZZYOCk4 ", 113 | " !a000000aa94({^]zWSSRi!80aa00048SSSSSPb}a000b^ ", 114 | " /97777777788887'DWRSJ228777778:eVRRRSI[487778[ ", 115 | "#:65555555555553(LSRSB!45555556{mWRRRSB!455555}$", 116 | "$_1}}}}}}}}}}}1]0SQRQk)2}}}}}}2'wVQQRRp)1}}}}1[&", 117 | "%/_(((((((((((_>pUQRJ4{(((((((_>AUQQQOa!_((((((&", 118 | "%{^]]]]]]]]]]]]>CSPRB){]]]]]]]{'ESPPRG_~]]]]]]]&", 119 | "$=============*/LQPPm&========*!JRPPRA;========%", 120 | "#..............eSPQJ6+.........(MPPPPo@........@", 121 | "$&***********&&zSOQB'&********%8PPOPL0%&*******$", 122 | "$=-----------=(LPPMi=---------&gROOPF^=-------=$", 123 | " =>>>>>>>>>>>*oSNPC{;>>>>>>>>>=rRNOPy;>>>>>>>>-$", 124 | " =!)))))))))'{IPOKe;!)))))))));BQNOMg;)))))))!- ", 125 | " &{{{{{{{{{{-oRNNv,{{{{{{{{{{~{HOMOG<){{{{{{{{= ", 126 | " $~(///////{(JOOB(!//////////!7OMMOw,///////({$ ", 127 | " >[::::::<;xQNE4)<:::::::::<,nQMMJ0!<::::::[' ", 128 | " &<}}}}}})0ONE8'}}}}}}}}}}}}'COLNA!:}}}}}}}}* ", 129 | " !2}}}2(^HOC6'11}}}}}}}}}1/3LMMJd!2}}}}}}2{# ", 130 | " &}222}>APz}!2222222222223,rPLMA~}22222221= ", 131 | " >322>rLn{{3222222222223_(IMLIa!22222224) ", 132 | " #]3!iE0'(21111111112:~);xOJLv)}1111112($ ", 133 | " &{}l/)[}}}}}}}}}}}})qrlMJLE2{}}}}}}}<* ", 134 | " &!)^<____________:)hQMJJIi,:_____:_= ", 135 | " =^(//////////////{!DLJJx){//////^= ", 136 | " &){~!!!!!!!!!!!!~;hMKC},~!!!!~!* ", 137 | " %;'',,,,,,,,,,,,>)DG0-',,,''>% ", 138 | " #*-;;;;;;;;;;;;;=ek--;;;;-*$ ", 139 | " $&=============;>=====*% ", 140 | " $$%%%%%%%%%%%%%%%%%$# ", 141 | " $##############$ ", 142 | " $######$$ "}; 143 | -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /palette.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PALLETE_H 3 | #define PALLETE_H 4 | 5 | #define PALETTEFEATURE_STANDARD 1 6 | #define PALETTEFEATURE_REVERSED 2 7 | #define PALETTEFEATURE_PANTS 4 8 | #define PALETTEFEATURE_SHIRT 8 9 | #define PALETTEFEATURE_GLOW 16 10 | #define PALETTEFEATURE_ZERO 32 11 | #define PALETTEFEATURE_TRANSPARENT 128 12 | 13 | extern unsigned char palette_rgb[256][3]; 14 | extern unsigned char palette_rgb_pantscolormap[16][3]; 15 | extern unsigned char palette_rgb_shirtcolormap[16][3]; 16 | extern unsigned char palette_rgb_pantsscoreboard[16][3]; 17 | extern unsigned char palette_rgb_shirtscoreboard[16][3]; 18 | 19 | extern unsigned int palette_bgra_complete[256]; 20 | extern unsigned int palette_bgra_font[256]; 21 | extern unsigned int palette_bgra_alpha[256]; 22 | extern unsigned int palette_bgra_nocolormap[256]; 23 | extern unsigned int palette_bgra_nocolormapnofullbrights[256]; 24 | extern unsigned int palette_bgra_nofullbrights[256]; 25 | extern unsigned int palette_bgra_nofullbrights_transparent[256]; 26 | extern unsigned int palette_bgra_onlyfullbrights[256]; 27 | extern unsigned int palette_bgra_onlyfullbrights_transparent[256]; 28 | extern unsigned int palette_bgra_pantsaswhite[256]; 29 | extern unsigned int palette_bgra_shirtaswhite[256]; 30 | extern unsigned int palette_bgra_transparent[256]; 31 | extern unsigned int palette_bgra_embeddedpic[256]; 32 | extern unsigned char palette_featureflags[256]; 33 | 34 | extern unsigned int q2palette_bgra_complete[256]; 35 | 36 | // used by hardware gamma functions in vid_* files 37 | void BuildGammaTable8(float prescale, float gamma, float scale, float base, float contrastboost, unsigned char *out, int rampsize); 38 | void BuildGammaTable16(float prescale, float gamma, float scale, float base, float contrastboost, unsigned short *out, int rampsize); 39 | 40 | void Palette_Init(void); 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /phys.h: -------------------------------------------------------------------------------- 1 | #ifndef PHYS_H 2 | #define PHYS_H 3 | 4 | #include "quakedef.h" 5 | 6 | 7 | qbool PHYS_TestEntityPosition (prvm_prog_t *prog, prvm_edict_t *ent, vec3_t offset); 8 | 9 | typedef enum unstickresult_e 10 | { 11 | // matching the DP_QC_NUDGEOUTOFSOLID return values 12 | UNSTICK_STUCK = 0, 13 | UNSTICK_GOOD = -1, ///< didn't need to be unstuck 14 | UNSTICK_UNSTUCK = 1 15 | } 16 | unstickresult_t; 17 | /*! move an entity that is stuck by small amounts in various directions to try to nudge it back into the collision hull 18 | * returns 1 if it found a better place, 0 if it remains stuck, -1 if it wasn't stuck. 19 | * Replaces SV_TryUnstick() and SV_CheckStuck() which in Quake applied to players only. 20 | */ 21 | unstickresult_t PHYS_UnstickEntityReturnOffset (prvm_prog_t *prog, prvm_edict_t *ent, vec3_t offset); 22 | /*! move an entity that is stuck out of the surface it is stuck in (can move large amounts) 23 | * with consideration to the properties of the surface and support for multiple surfaces. 24 | * returns 1 if it found a better place, 0 if it remains stuck, -1 if it wasn't stuck. 25 | * Replaces PHYS_UnstickEntityReturnOffset() but falls back to it when using cliphulls. 26 | */ 27 | unstickresult_t PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent); 28 | extern cvar_t cl_gameplayfix_nudgeoutofsolid_separation; 29 | 30 | 31 | #endif // PHYS_H guard 32 | -------------------------------------------------------------------------------- /pmove.h: -------------------------------------------------------------------------------- 1 | #ifndef PMOVE_H 2 | #define PMOVE_H 3 | 4 | #include "qtypes.h" 5 | #include "protocol.h" 6 | 7 | typedef enum waterlevel_e 8 | { 9 | WATERLEVEL_NONE, 10 | WATERLEVEL_WETFEET, 11 | WATERLEVEL_SWIMMING, 12 | WATERLEVEL_SUBMERGED 13 | } 14 | waterlevel_t; 15 | 16 | typedef struct playermove_s 17 | { 18 | // entity to be ignored for movement 19 | struct prvm_edict_s *self; 20 | // position 21 | vec3_t origin; 22 | vec3_t velocity; 23 | vec3_t angles; 24 | vec3_t movedir; 25 | // current bounding box (different if crouched vs standing) 26 | vec3_t mins; 27 | vec3_t maxs; 28 | // currently on the ground 29 | qbool onground; 30 | // currently crouching 31 | qbool crouched; 32 | // what kind of water (SUPERCONTENTS_LAVA for instance) 33 | int watertype; 34 | // how deep 35 | waterlevel_t waterlevel; 36 | // weird hacks when jumping out of water 37 | // (this is in seconds and counts down to 0) 38 | float waterjumptime; 39 | 40 | int movetype; 41 | 42 | // user command 43 | usercmd_t cmd; 44 | } 45 | playermove_t; 46 | 47 | typedef struct movevars_s 48 | { 49 | unsigned int moveflags; 50 | float wallfriction; 51 | float waterfriction; 52 | float friction; 53 | float timescale; 54 | float gravity; 55 | float stopspeed; 56 | float maxspeed; 57 | float spectatormaxspeed; 58 | float accelerate; 59 | float airaccelerate; 60 | float wateraccelerate; 61 | float entgravity; 62 | float jumpvelocity; 63 | float edgefriction; 64 | float maxairspeed; 65 | float stepheight; 66 | float airaccel_qw; 67 | float airaccel_qw_stretchfactor; 68 | float airaccel_sideways_friction; 69 | float airstopaccelerate; 70 | float airstrafeaccelerate; 71 | float maxairstrafespeed; 72 | float airstrafeaccel_qw; 73 | float aircontrol; 74 | float aircontrol_power; 75 | float aircontrol_penalty; 76 | float warsowbunny_airforwardaccel; 77 | float warsowbunny_accel; 78 | float warsowbunny_topspeed; 79 | float warsowbunny_turnaccel; 80 | float warsowbunny_backtosideratio; 81 | float ticrate; 82 | float airspeedlimit_nonqw; 83 | } movevars_t; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /polygon.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef POLYGON_H 3 | #define POLYGON_H 4 | 5 | /* 6 | Polygon clipping routines written by Ashley Rose Hale (LadyHavoc) and placed into public domain. 7 | */ 8 | 9 | void PolygonF_QuadForPlane(float *outpoints, float planenormalx, float planenormaly, float planenormalz, float planedist, float quadsize); 10 | void PolygonD_QuadForPlane(double *outpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double quadsize); 11 | int PolygonF_Clip(int innumpoints, const float *inpoints, float planenormalx, float planenormaly, float planenormalz, float planedist, float epsilon, int outfrontmaxpoints, float *outfrontpoints); 12 | int PolygonD_Clip(int innumpoints, const double *inpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double epsilon, int outfrontmaxpoints, double *outfrontpoints); 13 | void PolygonF_Divide(int innumpoints, const float *inpoints, float planenormalx, float planenormaly, float planenormalz, float planedist, float epsilon, int outfrontmaxpoints, float *outfrontpoints, int *neededfrontpoints, int outbackmaxpoints, float *outbackpoints, int *neededbackpoints, int *oncountpointer); 14 | void PolygonD_Divide(int innumpoints, const double *inpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double epsilon, int outfrontmaxpoints, double *outfrontpoints, int *neededfrontpoints, int outbackmaxpoints, double *outbackpoints, int *neededbackpoints, int *oncountpointer); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /portals.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PORTALS_H 3 | #define PORTALS_H 4 | 5 | int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpoints); 6 | int Portal_CheckBox(model_t *model, vec3_t eye, vec3_t a, vec3_t b); 7 | void Portal_Visibility(model_t *model, const vec3_t eye, int *leaflist, unsigned char *leafpvs, int *numleafspointer, int *surfacelist, unsigned char *surfacepvs, int *numsurfacespointer, const mplane_t *frustumplanes, int numfrustumplanes, int exact, const float *boxmins, const float *boxmaxs, float *updateleafsmins, float *updateleafsmaxs, unsigned char *shadowtrispvs, unsigned char *lighttrispvs, unsigned char *visitingleafpvs); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /progdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | /* file generated by qcc, do not modify */ 22 | 23 | #ifndef PROGDEFS_H 24 | #define PROGDEFS_H 25 | 26 | typedef struct globalvars_s 27 | { 28 | int pad[28]; 29 | int self; 30 | int other; 31 | int world; 32 | float time; 33 | float frametime; 34 | float force_retouch; 35 | string_t mapname; 36 | float deathmatch; 37 | float coop; 38 | float teamplay; 39 | float serverflags; 40 | float total_secrets; 41 | float total_monsters; 42 | float found_secrets; 43 | float killed_monsters; 44 | float parm1; 45 | float parm2; 46 | float parm3; 47 | float parm4; 48 | float parm5; 49 | float parm6; 50 | float parm7; 51 | float parm8; 52 | float parm9; 53 | float parm10; 54 | float parm11; 55 | float parm12; 56 | float parm13; 57 | float parm14; 58 | float parm15; 59 | float parm16; 60 | vec3_t v_forward; 61 | vec3_t v_up; 62 | vec3_t v_right; 63 | float trace_allsolid; 64 | float trace_startsolid; 65 | float trace_fraction; 66 | vec3_t trace_endpos; 67 | vec3_t trace_plane_normal; 68 | float trace_plane_dist; 69 | int trace_ent; 70 | float trace_inopen; 71 | float trace_inwater; 72 | int msg_entity; 73 | func_t main; 74 | func_t StartFrame; 75 | func_t PlayerPreThink; 76 | func_t PlayerPostThink; 77 | func_t ClientKill; 78 | func_t ClientConnect; 79 | func_t PutClientInServer; 80 | func_t ClientDisconnect; 81 | func_t SetNewParms; 82 | func_t SetChangeParms; 83 | } globalvars_t; 84 | 85 | typedef struct entvars_s 86 | { 87 | float modelindex; 88 | vec3_t absmin; 89 | vec3_t absmax; 90 | float ltime; 91 | float movetype; 92 | float solid; 93 | vec3_t origin; 94 | vec3_t oldorigin; 95 | vec3_t velocity; 96 | vec3_t angles; 97 | vec3_t avelocity; 98 | vec3_t punchangle; 99 | string_t classname; 100 | string_t model; 101 | float frame; 102 | float skin; 103 | float effects; 104 | vec3_t mins; 105 | vec3_t maxs; 106 | vec3_t size; 107 | func_t touch; 108 | func_t use; 109 | func_t think; 110 | func_t blocked; 111 | float nextthink; 112 | int groundentity; 113 | float health; 114 | float frags; 115 | float weapon; 116 | string_t weaponmodel; 117 | float weaponframe; 118 | float currentammo; 119 | float ammo_shells; 120 | float ammo_nails; 121 | float ammo_rockets; 122 | float ammo_cells; 123 | float items; 124 | float takedamage; 125 | int chain; 126 | float deadflag; 127 | vec3_t view_ofs; 128 | float button0; 129 | float button1; 130 | float button2; 131 | float impulse; 132 | float fixangle; 133 | vec3_t v_angle; 134 | float idealpitch; 135 | string_t netname; 136 | int enemy; 137 | float flags; 138 | float colormap; 139 | float team; 140 | float max_health; 141 | float teleport_time; 142 | float armortype; 143 | float armorvalue; 144 | float waterlevel; 145 | float watertype; 146 | float ideal_yaw; 147 | float yaw_speed; 148 | int aiment; 149 | int goalentity; 150 | float spawnflags; 151 | string_t target; 152 | string_t targetname; 153 | float dmg_take; 154 | float dmg_save; 155 | int dmg_inflictor; 156 | int owner; 157 | vec3_t movedir; 158 | string_t message; 159 | float sounds; 160 | string_t noise; 161 | string_t noise1; 162 | string_t noise2; 163 | string_t noise3; 164 | } entvars_t; 165 | 166 | #define PROGHEADER_CRC 5927 167 | #define PROGHEADER_CRC_TENEBRAE 32401 168 | 169 | #endif 170 | 171 | -------------------------------------------------------------------------------- /qstats.h: -------------------------------------------------------------------------------- 1 | #ifndef QSTATS_H 2 | #define QSTATS_H 3 | 4 | // 5 | // stats are integers communicated to the client by the server 6 | // 7 | #define MAX_CL_STATS 256 8 | #define STAT_HEALTH 0 9 | //#define STAT_FRAGS 1 10 | #define STAT_WEAPON 2 11 | #define STAT_AMMO 3 12 | #define STAT_ARMOR 4 13 | #define STAT_WEAPONFRAME 5 14 | #define STAT_SHELLS 6 15 | #define STAT_NAILS 7 16 | #define STAT_ROCKETS 8 17 | #define STAT_CELLS 9 18 | #define STAT_ACTIVEWEAPON 10 19 | #define STAT_TOTALSECRETS 11 20 | #define STAT_TOTALMONSTERS 12 21 | #define STAT_SECRETS 13 ///< bumped on client side by svc_foundsecret 22 | #define STAT_MONSTERS 14 ///< bumped by svc_killedmonster 23 | #define STAT_ITEMS 15 ///< FTE, DP 24 | #define STAT_VIEWHEIGHT 16 ///< FTE, DP 25 | //#define STAT_TIME 17 ///< FTE 26 | //#define STAT_VIEW2 20 ///< FTE 27 | #define STAT_VIEWZOOM 21 ///< DP 28 | #define MIN_VM_STAT 32 ///< stat range available to VM_SV_AddStat 29 | #define MAX_VM_STAT 220 ///< stat range available to VM_SV_AddStat 30 | #define STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR 220 ///< DP 31 | #define STAT_MOVEVARS_AIRCONTROL_PENALTY 221 ///< DP 32 | #define STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW 222 ///< DP 33 | #define STAT_MOVEVARS_AIRSTRAFEACCEL_QW 223 ///< DP 34 | #define STAT_MOVEVARS_AIRCONTROL_POWER 224 ///< DP 35 | #define STAT_MOVEFLAGS 225 ///< DP 36 | #define STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL 226 ///< DP 37 | #define STAT_MOVEVARS_WARSOWBUNNY_ACCEL 227 ///< DP 38 | #define STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED 228 ///< DP 39 | #define STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL 229 ///< DP 40 | #define STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO 230 ///< DP 41 | #define STAT_MOVEVARS_AIRSTOPACCELERATE 231 ///< DP 42 | #define STAT_MOVEVARS_AIRSTRAFEACCELERATE 232 ///< DP 43 | #define STAT_MOVEVARS_MAXAIRSTRAFESPEED 233 ///< DP 44 | #define STAT_MOVEVARS_AIRCONTROL 234 ///< DP 45 | #define STAT_FRAGLIMIT 235 ///< DP 46 | #define STAT_TIMELIMIT 236 ///< DP 47 | #define STAT_MOVEVARS_WALLFRICTION 237 ///< DP 48 | #define STAT_MOVEVARS_FRICTION 238 ///< DP 49 | #define STAT_MOVEVARS_WATERFRICTION 239 ///< DP 50 | #define STAT_MOVEVARS_TICRATE 240 ///< DP 51 | #define STAT_MOVEVARS_TIMESCALE 241 ///< DP 52 | #define STAT_MOVEVARS_GRAVITY 242 ///< DP 53 | #define STAT_MOVEVARS_STOPSPEED 243 ///< DP 54 | #define STAT_MOVEVARS_MAXSPEED 244 ///< DP 55 | #define STAT_MOVEVARS_SPECTATORMAXSPEED 245 ///< DP 56 | #define STAT_MOVEVARS_ACCELERATE 246 ///< DP 57 | #define STAT_MOVEVARS_AIRACCELERATE 247 ///< DP 58 | #define STAT_MOVEVARS_WATERACCELERATE 248 ///< DP 59 | #define STAT_MOVEVARS_ENTGRAVITY 249 ///< DP 60 | #define STAT_MOVEVARS_JUMPVELOCITY 250 ///< DP 61 | #define STAT_MOVEVARS_EDGEFRICTION 251 ///< DP 62 | #define STAT_MOVEVARS_MAXAIRSPEED 252 ///< DP 63 | #define STAT_MOVEVARS_STEPHEIGHT 253 ///< DP 64 | #define STAT_MOVEVARS_AIRACCEL_QW 254 ///< DP 65 | #define STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION 255 ///< DP 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /qtypes.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef QTYPES_H 3 | #define QTYPES_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | typedef bool qbool; 10 | 11 | #ifndef NULL 12 | #define NULL ((void *)0) 13 | #endif 14 | 15 | // up / down 16 | #define PITCH 0 17 | 18 | // left / right 19 | #define YAW 1 20 | 21 | // fall over 22 | #define ROLL 2 23 | 24 | #if defined(__GNUC__) || (__clang__) || (__TINYC__) || (_MSC_VER >= 1400) 25 | #define RESTRICT __restrict 26 | #else 27 | #define RESTRICT 28 | #endif 29 | 30 | typedef int8_t i8; 31 | typedef int16_t i16; 32 | typedef int32_t i32; 33 | typedef int64_t i64; 34 | 35 | typedef uint8_t u8; 36 | typedef uint16_t u16; 37 | typedef uint32_t u32; 38 | typedef uint64_t u64; 39 | 40 | typedef intptr_t iptr; 41 | typedef uintptr_t uptr; 42 | 43 | // LadyHavoc: upgrade the prvm to double precision for better time values 44 | // LadyHavoc: to be enabled when bugs are worked out... 45 | //#define PRVM_64 46 | #ifdef PRVM_64 47 | typedef double prvm_vec_t; 48 | typedef int64_t prvm_int_t; 49 | typedef uint64_t prvm_uint_t; 50 | #define PRVM_PRIi PRIi64 51 | #define PRVM_PRIu PRIu64 52 | #define PRVM_INT_MIN INT64_MIN 53 | #define PRVM_INT_MAX INT64_MAX 54 | #else 55 | typedef float prvm_vec_t; 56 | typedef int32_t prvm_int_t; 57 | typedef uint32_t prvm_uint_t; 58 | #define PRVM_PRIi PRIi32 59 | #define PRVM_PRIu PRIu32 60 | #define PRVM_INT_MIN INT32_MIN 61 | #define PRVM_INT_MAX INT32_MAX 62 | #endif 63 | typedef prvm_vec_t prvm_vec3_t[3]; 64 | 65 | #ifdef VEC_64 66 | typedef double vec_t; 67 | #else 68 | typedef float vec_t; 69 | #endif 70 | typedef vec_t vec2_t[2]; 71 | typedef vec_t vec3_t[3]; 72 | typedef vec_t vec4_t[4]; 73 | #endif 74 | -------------------------------------------------------------------------------- /r_modules.c: -------------------------------------------------------------------------------- 1 | 2 | #include "quakedef.h" 3 | 4 | #define MAXRENDERMODULES 20 5 | 6 | typedef struct rendermodule_s 7 | { 8 | int active; // set by start, cleared by shutdown 9 | const char *name; 10 | void(*start)(void); 11 | void(*shutdown)(void); 12 | void(*newmap)(void); 13 | void(*devicelost)(void); 14 | void(*devicerestored)(void); 15 | } 16 | rendermodule_t; 17 | 18 | rendermodule_t rendermodule[MAXRENDERMODULES]; 19 | 20 | void R_Modules_Init(void) 21 | { 22 | Cmd_AddCommand(CF_CLIENT, "r_restart", R_Modules_Restart_f, "restarts renderer"); 23 | } 24 | 25 | void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void)) 26 | { 27 | int i; 28 | for (i = 0;i < MAXRENDERMODULES;i++) 29 | { 30 | if (rendermodule[i].name == NULL) 31 | break; 32 | if (!strcmp(name, rendermodule[i].name)) 33 | { 34 | Con_Printf("R_RegisterModule: module \"%s\" registered twice\n", name); 35 | return; 36 | } 37 | } 38 | if (i >= MAXRENDERMODULES) 39 | Sys_Error("R_RegisterModule: ran out of renderer module slots (%i)", MAXRENDERMODULES); 40 | rendermodule[i].active = 0; 41 | rendermodule[i].name = name; 42 | rendermodule[i].start = start; 43 | rendermodule[i].shutdown = shutdown; 44 | rendermodule[i].newmap = newmap; 45 | rendermodule[i].devicelost = devicelost; 46 | rendermodule[i].devicerestored = devicerestored; 47 | } 48 | 49 | void R_Modules_Start(void) 50 | { 51 | int i; 52 | for (i = 0;i < MAXRENDERMODULES;i++) 53 | { 54 | if (rendermodule[i].name == NULL) 55 | continue; 56 | if (rendermodule[i].active) 57 | { 58 | Con_Printf ("R_Modules_Start: module \"%s\" already active\n", rendermodule[i].name); 59 | continue; 60 | } 61 | Con_DPrintf("Starting render module \"%s\"\n", rendermodule[i].name); 62 | rendermodule[i].active = 1; 63 | rendermodule[i].start(); 64 | } 65 | } 66 | 67 | void R_Modules_Shutdown(void) 68 | { 69 | int i; 70 | // shutdown in reverse 71 | for (i = MAXRENDERMODULES - 1;i >= 0;i--) 72 | { 73 | if (rendermodule[i].name == NULL) 74 | continue; 75 | if (!rendermodule[i].active) 76 | continue; 77 | Con_DPrintf("Stopping render module \"%s\"\n", rendermodule[i].name); 78 | rendermodule[i].active = 0; 79 | rendermodule[i].shutdown(); 80 | } 81 | } 82 | 83 | void R_Modules_Restart_f(cmd_state_t *cmd) 84 | { 85 | CL_StartVideo(); 86 | Con_Print("Restarting renderer\n"); 87 | SCR_BeginLoadingPlaque(false); 88 | R_Modules_Shutdown(); 89 | R_Modules_Start(); 90 | } 91 | 92 | void R_Modules_NewMap(void) 93 | { 94 | int i; 95 | R_SkinFrame_PrepareForPurge(); 96 | for (i = 0;i < MAXRENDERMODULES;i++) 97 | { 98 | if (rendermodule[i].name == NULL) 99 | continue; 100 | if (!rendermodule[i].active) 101 | continue; 102 | rendermodule[i].newmap(); 103 | } 104 | R_SkinFrame_Purge(); 105 | } 106 | 107 | void R_Modules_DeviceLost(void) 108 | { 109 | int i; 110 | for (i = 0;i < MAXRENDERMODULES;i++) 111 | { 112 | if (rendermodule[i].name == NULL) 113 | continue; 114 | if (!rendermodule[i].active) 115 | continue; 116 | if (!rendermodule[i].devicelost) 117 | continue; 118 | rendermodule[i].devicelost(); 119 | } 120 | } 121 | 122 | 123 | void R_Modules_DeviceRestored(void) 124 | { 125 | int i; 126 | for (i = 0;i < MAXRENDERMODULES;i++) 127 | { 128 | if (rendermodule[i].name == NULL) 129 | continue; 130 | if (!rendermodule[i].active) 131 | continue; 132 | if (!rendermodule[i].devicerestored) 133 | continue; 134 | rendermodule[i].devicerestored(); 135 | } 136 | } 137 | 138 | -------------------------------------------------------------------------------- /r_modules.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef R_MODULES_H 3 | #define R_MODULES_H 4 | 5 | void R_Modules_Init(void); 6 | void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void)); 7 | void R_Modules_Start(void); 8 | void R_Modules_Shutdown(void); 9 | void R_Modules_NewMap(void); 10 | void R_Modules_Restart_f(struct cmd_state_s *cmd); 11 | void R_Modules_DeviceLost(void); 12 | void R_Modules_DeviceRestored(void); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by darkplaces.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1000 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /sbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef SBAR_H 22 | #define SBAR_H 23 | 24 | #define SBAR_HEIGHT 24 25 | 26 | extern int sb_lines; ///< scan lines to draw 27 | extern struct cvar_s sbar_alpha_bg; 28 | extern struct cvar_s sbar_alpha_fg; 29 | 30 | void Sbar_Init (void); 31 | 32 | /// called every frame by screen 33 | void Sbar_Draw (void); 34 | 35 | void Sbar_ShowFPS(void); 36 | void Sbar_ShowFPS_Update(void); 37 | 38 | int Sbar_GetSortedPlayerIndex (int index); 39 | void Sbar_SortFrags (void); 40 | 41 | extern cvar_t cl_deathscoreboard; 42 | void Sbar_DeathmatchOverlay (void); 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /screen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // screen.h 21 | 22 | #ifndef SCREEN_H 23 | #define SCREEN_H 24 | 25 | #include 26 | #include "qtypes.h" 27 | struct portable_samplepair_s; 28 | 29 | void CL_Screen_Init (void); 30 | void CL_UpdateScreen (void); 31 | void SCR_CenterPrint(const char *str); 32 | 33 | void SCR_BeginLoadingPlaque (qbool startup); 34 | void SCR_DeferLoadingPlaque (qbool startup); 35 | void SCR_EndLoadingPlaque (void); 36 | 37 | // pushes an item on the loading screen 38 | void SCR_PushLoadingScreen (const char *msg, float len_in_parent); 39 | void SCR_PopLoadingScreen (qbool redraw); 40 | void SCR_ClearLoadingScreen (qbool redraw); 41 | 42 | void SCR_CaptureVideo_SoundFrame(const struct portable_samplepair_s *paintbuffer, size_t length); 43 | 44 | extern unsigned int scr_con_current; // current height of displayed console 45 | 46 | extern int sb_lines; 47 | 48 | extern struct cvar_s scr_viewsize; 49 | extern struct cvar_s scr_fov; 50 | extern struct cvar_s cl_showfps; 51 | extern struct cvar_s cl_showtime; 52 | extern struct cvar_s cl_showdate; 53 | 54 | extern struct cvar_s crosshair; 55 | extern struct cvar_s crosshair_size; 56 | 57 | extern struct cvar_s scr_conalpha; 58 | extern struct cvar_s scr_conalphafactor; 59 | extern struct cvar_s scr_conalpha2factor; 60 | extern struct cvar_s scr_conalpha3factor; 61 | extern struct cvar_s scr_conscroll_x; 62 | extern struct cvar_s scr_conscroll_y; 63 | extern struct cvar_s scr_conscroll2_x; 64 | extern struct cvar_s scr_conscroll2_y; 65 | extern struct cvar_s scr_conscroll3_x; 66 | extern struct cvar_s scr_conscroll3_y; 67 | extern struct cvar_s scr_conbrightness; 68 | extern struct cvar_s r_letterbox; 69 | 70 | extern struct cvar_s scr_refresh; 71 | extern struct cvar_s scr_stipple; 72 | 73 | extern struct cvar_s r_stereo_separation; 74 | extern struct cvar_s r_stereo_angle; 75 | qbool R_Stereo_Active(void); 76 | extern int r_stereo_side; 77 | 78 | typedef struct scr_touchscreenarea_s 79 | { 80 | const char *pic; 81 | const char *text; 82 | float rect[4]; 83 | float textheight; 84 | float active; 85 | float activealpha; 86 | float inactivealpha; 87 | } 88 | scr_touchscreenarea_t; 89 | 90 | // FIXME: should resize dynamically? 91 | extern int scr_numtouchscreenareas; 92 | extern scr_touchscreenarea_t scr_touchscreenareas[128]; 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /snd_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // snd_null.c -- include this instead of all the other snd_* files to have 21 | // no sound code whatsoever 22 | 23 | #include "quakedef.h" 24 | 25 | cvar_t bgmvolume = {CF_CLIENT | CF_ARCHIVE, "bgmvolume", "1", "volume of background music (such as CD music or replacement files such as sound/cdtracks/track002.ogg)"}; 26 | cvar_t snd_initialized = {CF_CLIENT | CF_READONLY, "snd_initialized", "0", "indicates the sound subsystem is active"}; 27 | 28 | void S_Init (void) 29 | { 30 | } 31 | 32 | void S_Terminate (void) 33 | { 34 | } 35 | 36 | void S_Startup (void) 37 | { 38 | } 39 | 40 | void S_Shutdown (void) 41 | { 42 | } 43 | 44 | void S_ClearUsed (void) 45 | { 46 | } 47 | 48 | void S_PurgeUnused (void) 49 | { 50 | } 51 | 52 | 53 | void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation) 54 | { 55 | } 56 | 57 | int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation) 58 | { 59 | return -1; 60 | } 61 | 62 | int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed) 63 | { 64 | return -1; 65 | } 66 | 67 | void S_StopChannel (unsigned int channel_ind, qbool lockmutex, qbool freesfx) 68 | { 69 | } 70 | 71 | qbool S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qbool value) 72 | { 73 | return false; 74 | } 75 | 76 | void S_StopSound (int entnum, int entchannel) 77 | { 78 | } 79 | 80 | void S_PauseGameSounds (qbool toggle) 81 | { 82 | } 83 | 84 | void S_SetChannelVolume (unsigned int ch_ind, float fvol) 85 | { 86 | } 87 | 88 | sfx_t *S_PrecacheSound (const char *sample, qbool complain, qbool levelsound) 89 | { 90 | return NULL; 91 | } 92 | 93 | float S_SoundLength(const char *name) 94 | { 95 | return -1; 96 | } 97 | 98 | qbool S_IsSoundPrecached (const sfx_t *sfx) 99 | { 100 | return false; 101 | } 102 | 103 | void S_UnloadAllSounds_f (cmd_state_t *cmd) 104 | { 105 | } 106 | 107 | sfx_t *S_FindName (const char *name) 108 | { 109 | return NULL; 110 | } 111 | 112 | void S_Update(const matrix4x4_t *matrix) 113 | { 114 | } 115 | 116 | void S_StopAllSounds (void) 117 | { 118 | } 119 | 120 | qbool S_LocalSound (const char *s) 121 | { 122 | return false; 123 | } 124 | 125 | qbool S_LocalSoundEx (const char *s, int chan, float fvol) 126 | { 127 | return false; 128 | } 129 | 130 | int S_GetSoundRate(void) 131 | { 132 | return 0; 133 | } 134 | 135 | int S_GetSoundChannels(void) 136 | { 137 | return 0; 138 | } 139 | 140 | float S_GetChannelPosition (unsigned int ch_ind) 141 | { 142 | return -1; 143 | } 144 | 145 | float S_GetEntChannelPosition(int entnum, int entchannel) 146 | { 147 | return -1; 148 | } 149 | 150 | void SndSys_SendKeyEvents(void) 151 | { 152 | } 153 | -------------------------------------------------------------------------------- /snd_ogg.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Mathieu Olivier 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to: 17 | 18 | Free Software Foundation, Inc. 19 | 59 Temple Place - Suite 330 20 | Boston, MA 02111-1307, USA 21 | 22 | */ 23 | 24 | #ifndef SND_OGG_H 25 | #define SND_OGG_H 26 | 27 | #include "qtypes.h" 28 | struct sfx_s; 29 | 30 | qbool OGG_OpenLibrary (void); 31 | void OGG_CloseLibrary (void); 32 | qbool OGG_LoadVorbisFile (const char *filename, struct sfx_s *sfx); 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /snd_wav.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to: 17 | 18 | Free Software Foundation, Inc. 19 | 59 Temple Place - Suite 330 20 | Boston, MA 02111-1307, USA 21 | 22 | */ 23 | 24 | 25 | #ifndef SND_WAV_H 26 | #define SND_WAV_H 27 | 28 | #include "qtypes.h" 29 | struct sfx_s; 30 | 31 | extern const struct snd_fetcher_s wav_fetcher; 32 | 33 | qbool S_LoadWavFile (const char *filename, struct sfx_s *sfx); 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /snd_xmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 nyov 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | 20 | #ifndef SND_XMP_H 21 | #define SND_XMP_H 22 | 23 | #include "qtypes.h" 24 | struct sfx_s; 25 | 26 | qbool XMP_OpenLibrary (void); 27 | void XMP_CloseLibrary (void); 28 | qbool XMP_LoadModFile (const char *filename, struct sfx_s *sfx); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /sound.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef SOUND_H 22 | #define SOUND_H 23 | 24 | #include "matrixlib.h" 25 | struct cmd_state_s; 26 | 27 | 28 | // ==================================================================== 29 | // Constants 30 | // ==================================================================== 31 | 32 | #define DEFAULT_SOUND_PACKET_VOLUME 255 33 | #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 34 | 35 | // Channel flags 36 | // These channel flags can be used for sound() builtins, with SOUNDFLAG_* names 37 | #define CHANNELFLAG_NONE 0 38 | #define CHANNELFLAG_RELIABLE (1 << 0) // send as reliable message (only used on server) 39 | #define CHANNELFLAG_FORCELOOP (1 << 1) // force looping even if the sound is not looped 40 | #define CHANNELFLAG_LOCALSOUND (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag 41 | #define CHANNELFLAG_PAUSED (1 << 3) // pause status 42 | #define CHANNELFLAG_FULLVOLUME (1 << 4) // isn't affected by the general volume 43 | 44 | // ==================================================================== 45 | // Types and variables 46 | // ==================================================================== 47 | 48 | typedef struct sfx_s sfx_t; 49 | 50 | extern cvar_t bgmvolume; 51 | extern cvar_t volume; 52 | extern cvar_t snd_initialized; 53 | 54 | 55 | // ==================================================================== 56 | // Functions 57 | // ==================================================================== 58 | 59 | void S_Init (void); 60 | void S_Terminate (void); 61 | 62 | void S_Startup (void); 63 | void S_Shutdown (void); 64 | void S_UnloadAllSounds_f(struct cmd_state_s *cmd); 65 | 66 | void S_Update(const matrix4x4_t *listenermatrix); 67 | 68 | sfx_t *S_PrecacheSound (const char *sample, qbool complain, qbool levelsound); 69 | float S_SoundLength(const char *name); 70 | void S_ClearUsed (void); 71 | void S_PurgeUnused (void); 72 | qbool S_IsSoundPrecached (const sfx_t *sfx); 73 | sfx_t *S_FindName(const char *name); 74 | 75 | // these define the "engine" channel namespace 76 | #define CHAN_MIN_AUTO -128 77 | #define CHAN_MAX_AUTO 0 78 | #define CHAN_MIN_SINGLE 1 79 | #define CHAN_MAX_SINGLE 127 80 | #define IS_CHAN_AUTO(n) ((n) >= CHAN_MIN_AUTO && (n) <= CHAN_MAX_AUTO) 81 | #define IS_CHAN_SINGLE(n) ((n) >= CHAN_MIN_SINGLE && (n) <= CHAN_MAX_SINGLE) 82 | #define IS_CHAN(n) (IS_CHAN_AUTO(n) || IS_CHAN_SINGLE(n)) 83 | 84 | // engine channel == network channel 85 | #define CHAN_ENGINE2NET(c) (c) 86 | #define CHAN_NET2ENGINE(c) (c) 87 | 88 | // engine view of channel encodes the auto flag into the channel number (see CHAN_ constants below) 89 | // user view uses the flags bitmask for it 90 | #define CHAN_USER2ENGINE(c) (c) 91 | #define CHAN_ENGINE2USER(c) (c) 92 | #define CHAN_ENGINE2CVAR(c) (abs(c)) 93 | 94 | /// S_StartSound returns the channel index, or -1 if an error occurred 95 | int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); 96 | int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed); 97 | qbool S_LocalSoundEx (const char *s, int chan, float fvol); 98 | qbool S_LocalSound (const char *s); 99 | 100 | void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation); 101 | void S_StopSound (int entnum, int entchannel); 102 | void S_StopAllSounds (void); 103 | void S_StopAllSounds_f(struct cmd_state_s *cmd); 104 | void S_PauseGameSounds (qbool toggle); 105 | 106 | void S_StopChannel (unsigned int channel_ind, qbool lockmutex, qbool freesfx); 107 | qbool S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qbool value); 108 | void S_SetChannelVolume (unsigned int ch_ind, float fvol); 109 | void S_SetChannelSpeed (unsigned int ch_ind, float fspeed); 110 | float S_GetChannelPosition (unsigned int ch_ind); 111 | float S_GetEntChannelPosition(int entnum, int entchannel); 112 | 113 | void S_BlockSound (void); 114 | void S_UnblockSound (void); 115 | 116 | int S_GetSoundRate (void); 117 | int S_GetSoundChannels (void); 118 | int S_GetSoundWidth (void); 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /spritegn.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // spritegn.h: header file for sprite generation program 22 | // 23 | 24 | // ********************************************************** 25 | // * This file must be identical in the spritegen directory * 26 | // * and in the Quake directory, because it's used to * 27 | // * pass data from one to the other via .spr files. * 28 | // ********************************************************** 29 | 30 | #ifndef SPRITEGEN_H 31 | #define SPRITEGEN_H 32 | 33 | //------------------------------------------------------- 34 | // This program generates .spr sprite package files. 35 | // The format of the files is as follows: 36 | // 37 | // dsprite_t file header structure 38 | // 39 | // 40 | // dspriteframe_t frame header structure 41 | // sprite bitmap 42 | // 43 | // dspriteframe_t frame header structure 44 | // sprite bitmap 45 | // 46 | //------------------------------------------------------- 47 | 48 | #define SPRITE_VERSION 1 49 | #define SPRITEHL_VERSION 2 50 | #define SPRITE32_VERSION 32 51 | 52 | #define SPRITE2_VERSION 2 53 | 54 | typedef struct dsprite_s 55 | { 56 | int ident; 57 | int version; 58 | int type; 59 | float boundingradius; 60 | int width; 61 | int height; 62 | int numframes; 63 | float beamlength; 64 | int synctype; 65 | } dsprite_t; 66 | 67 | typedef struct dspritehl_s 68 | { 69 | int ident; 70 | int version; 71 | int type; 72 | int rendermode; 73 | float boundingradius; 74 | int width; 75 | int height; 76 | int numframes; 77 | float beamlength; 78 | int synctype; 79 | } dspritehl_t; 80 | 81 | typedef struct dsprite2frame_s 82 | { 83 | int width, height; 84 | int origin_x, origin_y; // raster coordinates inside pic 85 | char name[64]; // name of pcx file 86 | } dsprite2frame_t; 87 | 88 | typedef struct dsprite2_s 89 | { 90 | int ident; 91 | int version; 92 | int numframes; 93 | dsprite2frame_t frames[1]; // variable sized 94 | } dsprite2_t; 95 | 96 | #define SPR_VP_PARALLEL_UPRIGHT 0 97 | #define SPR_FACING_UPRIGHT 1 98 | #define SPR_VP_PARALLEL 2 99 | #define SPR_ORIENTED 3 100 | #define SPR_VP_PARALLEL_ORIENTED 4 101 | #define SPR_LABEL 5 102 | #define SPR_LABEL_SCALE 6 103 | #define SPR_OVERHEAD 7 104 | 105 | #define SPRHL_OPAQUE 0 106 | #define SPRHL_ADDITIVE 1 107 | #define SPRHL_INDEXALPHA 2 108 | #define SPRHL_ALPHATEST 3 109 | 110 | typedef struct dspriteframe_s { 111 | int origin[2]; 112 | int width; 113 | int height; 114 | } dspriteframe_t; 115 | 116 | typedef struct dspritegroup_s { 117 | int numframes; 118 | } dspritegroup_t; 119 | 120 | typedef struct dspriteinterval_s { 121 | float interval; 122 | } dspriteinterval_t; 123 | 124 | typedef enum spriteframetype_e { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t; 125 | 126 | typedef struct dspriteframetype_s { 127 | spriteframetype_t type; 128 | } dspriteframetype_t; 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /sv_demo.c: -------------------------------------------------------------------------------- 1 | #include "quakedef.h" 2 | #include "sv_demo.h" 3 | 4 | extern cvar_t sv_autodemo_perclient_discardable; 5 | 6 | void SV_StartDemoRecording(client_t *client, const char *filename, int forcetrack) 7 | { 8 | prvm_prog_t *prog = SVVM_prog; 9 | char name[MAX_QPATH]; 10 | 11 | if(client->sv_demo_file != NULL) 12 | return; // we already have a demo 13 | 14 | dp_strlcpy(name, filename, sizeof(name)); 15 | FS_DefaultExtension(name, ".dem", sizeof(name)); 16 | 17 | Con_Printf("Recording demo for # %d (%s) to %s\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress, name); 18 | 19 | // Reset discardable flag for every new demo. 20 | PRVM_serveredictfloat(client->edict, discardabledemo) = 0; 21 | 22 | client->sv_demo_file = FS_OpenRealFile(name, "wb", false); 23 | if(!client->sv_demo_file) 24 | { 25 | Con_Print(CON_ERROR "ERROR: couldn't open.\n"); 26 | return; 27 | } 28 | 29 | FS_Printf(client->sv_demo_file, "%i\n", forcetrack); 30 | } 31 | 32 | void SV_WriteDemoMessage(client_t *client, sizebuf_t *sendbuffer, qbool clienttoserver) 33 | { 34 | prvm_prog_t *prog = SVVM_prog; 35 | int len, i; 36 | float f; 37 | int temp; 38 | 39 | if(client->sv_demo_file == NULL) 40 | return; 41 | if(sendbuffer->cursize == 0) 42 | return; 43 | 44 | temp = sendbuffer->cursize | (clienttoserver ? DEMOMSG_CLIENT_TO_SERVER : 0); 45 | len = LittleLong(temp); 46 | FS_Write(client->sv_demo_file, &len, 4); 47 | for(i = 0; i < 3; ++i) 48 | { 49 | f = LittleFloat(PRVM_serveredictvector(client->edict, v_angle)[i]); 50 | FS_Write(client->sv_demo_file, &f, 4); 51 | } 52 | FS_Write(client->sv_demo_file, sendbuffer->data, sendbuffer->cursize); 53 | } 54 | 55 | void SV_StopDemoRecording(client_t *client) 56 | { 57 | prvm_prog_t *prog = SVVM_prog; 58 | sizebuf_t buf; 59 | unsigned char bufdata[64]; 60 | 61 | if(client->sv_demo_file == NULL) 62 | return; 63 | 64 | buf.data = bufdata; 65 | buf.maxsize = sizeof(bufdata); 66 | SZ_Clear(&buf); 67 | MSG_WriteByte(&buf, svc_disconnect); 68 | SV_WriteDemoMessage(client, &buf, false); 69 | 70 | if (sv_autodemo_perclient_discardable.integer && PRVM_serveredictfloat(client->edict, discardabledemo)) 71 | { 72 | FS_RemoveOnClose(client->sv_demo_file); 73 | Con_Printf("Stopped recording discardable demo for # %d (%s)\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress); 74 | } 75 | else 76 | Con_Printf("Stopped recording demo for # %d (%s)\n", PRVM_NUM_FOR_EDICT(client->edict), client->netaddress); 77 | 78 | FS_Close(client->sv_demo_file); 79 | client->sv_demo_file = NULL; 80 | } 81 | 82 | void SV_WriteNetnameIntoDemo(client_t *client) 83 | { 84 | // This "pseudo packet" is written so a program can easily find out whose demo this is 85 | sizebuf_t buf; 86 | unsigned char bufdata[MAX_SCOREBOARDNAME + 64]; 87 | 88 | if(client->sv_demo_file == NULL) 89 | return; 90 | 91 | buf.data = bufdata; 92 | buf.maxsize = sizeof(bufdata); 93 | SZ_Clear(&buf); 94 | MSG_WriteByte(&buf, svc_stufftext); 95 | MSG_WriteUnterminatedString(&buf, "\n// this demo contains the point of view of: "); 96 | MSG_WriteUnterminatedString(&buf, client->name); 97 | MSG_WriteString(&buf, "\n"); 98 | SV_WriteDemoMessage(client, &buf, false); 99 | } 100 | -------------------------------------------------------------------------------- /sv_demo.h: -------------------------------------------------------------------------------- 1 | #ifndef SV_DEMO_H 2 | #define SV_DEMO_H 3 | 4 | #include "qtypes.h" 5 | struct sizebuf_s; 6 | struct client_s; 7 | 8 | void SV_StartDemoRecording(struct client_s *client, const char *filename, int forcetrack); 9 | void SV_WriteDemoMessage(struct client_s *client, struct sizebuf_s *sendbuffer, qbool clienttoserver); 10 | void SV_StopDemoRecording(struct client_s *client); 11 | void SV_WriteNetnameIntoDemo(struct client_s *client); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /sv_ents4.c: -------------------------------------------------------------------------------- 1 | #include "quakedef.h" 2 | #include "protocol.h" 3 | 4 | qbool EntityFrame4_WriteFrame(sizebuf_t *msg, int maxsize, entityframe4_database_t *d, int numstates, const entity_state_t **states) 5 | { 6 | prvm_prog_t *prog = SVVM_prog; 7 | const entity_state_t *e, *s; 8 | entity_state_t inactiveentitystate; 9 | int i, n, startnumber; 10 | sizebuf_t buf; 11 | unsigned char data[128]; 12 | 13 | // if there isn't enough space to accomplish anything, skip it 14 | if (msg->cursize + 24 > maxsize) 15 | return false; 16 | 17 | // prepare the buffer 18 | memset(&buf, 0, sizeof(buf)); 19 | buf.data = data; 20 | buf.maxsize = sizeof(data); 21 | 22 | for (i = 0;i < MAX_ENTITY_HISTORY;i++) 23 | if (!d->commit[i].numentities) 24 | break; 25 | // if commit buffer full, just don't bother writing an update this frame 26 | if (i == MAX_ENTITY_HISTORY) 27 | return false; 28 | d->currentcommit = d->commit + i; 29 | 30 | // this state's number gets played around with later 31 | inactiveentitystate = defaultstate; 32 | 33 | d->currentcommit->numentities = 0; 34 | d->currentcommit->framenum = ++d->latestframenumber; 35 | MSG_WriteByte(msg, svc_entities); 36 | MSG_WriteLong(msg, d->referenceframenum); 37 | MSG_WriteLong(msg, d->currentcommit->framenum); 38 | if (developer_networkentities.integer >= 10) 39 | { 40 | Con_Printf("send svc_entities num:%i ref:%i (database: ref:%i commits:", d->currentcommit->framenum, d->referenceframenum, d->referenceframenum); 41 | for (i = 0;i < MAX_ENTITY_HISTORY;i++) 42 | if (d->commit[i].numentities) 43 | Con_Printf(" %i", d->commit[i].framenum); 44 | Con_Print(")\n"); 45 | } 46 | if (d->currententitynumber >= prog->max_edicts) 47 | startnumber = 1; 48 | else 49 | startnumber = bound(1, d->currententitynumber, prog->max_edicts - 1); 50 | MSG_WriteShort(msg, startnumber); 51 | // reset currententitynumber so if the loop does not break it we will 52 | // start at beginning next frame (if it does break, it will set it) 53 | d->currententitynumber = 1; 54 | for (i = 0, n = startnumber;n < prog->max_edicts;n++) 55 | { 56 | if (PRVM_serveredictfunction((&prog->edicts[n]), SendEntity)) 57 | continue; 58 | // find the old state to delta from 59 | e = EntityFrame4_GetReferenceEntity(d, n); 60 | // prepare the buffer 61 | SZ_Clear(&buf); 62 | // entity exists, build an update (if empty there is no change) 63 | // find the state in the list 64 | for (;i < numstates && states[i]->number < n;i++); 65 | // make the message 66 | s = states[i]; 67 | if (s->number == n) 68 | { 69 | // build the update 70 | EntityState_WriteUpdate(s, &buf, e); 71 | } 72 | else 73 | { 74 | inactiveentitystate.number = n; 75 | s = &inactiveentitystate; 76 | if (e->active == ACTIVE_NETWORK) 77 | { 78 | // entity used to exist but doesn't anymore, send remove 79 | MSG_WriteShort(&buf, n | 0x8000); 80 | } 81 | } 82 | // if the commit is full, we're done this frame 83 | if (msg->cursize + buf.cursize > maxsize - 4) 84 | { 85 | // next frame we will continue where we left off 86 | break; 87 | } 88 | // add the entity to the commit 89 | EntityFrame4_AddCommitEntity(d, s); 90 | // if the message is empty, skip out now 91 | if (buf.cursize) 92 | { 93 | // write the message to the packet 94 | SZ_Write(msg, buf.data, buf.cursize); 95 | } 96 | } 97 | d->currententitynumber = n; 98 | 99 | // remove world message (invalid, and thus a good terminator) 100 | MSG_WriteShort(msg, 0x8000); 101 | // write the number of the end entity 102 | MSG_WriteShort(msg, d->currententitynumber); 103 | // just to be sure 104 | d->currentcommit = NULL; 105 | 106 | return true; 107 | } 108 | -------------------------------------------------------------------------------- /svbsp.h: -------------------------------------------------------------------------------- 1 | 2 | // Shadow Volume BSP code written by Ashley Rose Hale (LadyHavoc) on 2003-11-06 and placed into public domain. 3 | // Modified by LadyHavoc (to make it work and other nice things like that) on 2007-01-24 and 2007-01-25 4 | 5 | #ifndef SVBSP_H 6 | #define SVBSP_H 7 | 8 | typedef struct svbsp_node_s 9 | { 10 | // notes: 11 | // leaf nodes are not stored, these are always structural nodes 12 | // (they always have a plane and two children) 13 | // children[] can be -1 for empty leaf or -2 for shadow leaf, >= 0 is node 14 | // parent can be -1 if this is the root node, >= 0 is a node 15 | int parent, children[2], padding; 16 | // node plane, splits space 17 | float plane[4]; 18 | } 19 | svbsp_node_t; 20 | 21 | typedef struct svbsp_s 22 | { 23 | // lightsource or view origin 24 | float origin[3]; 25 | // current number of nodes in the svbsp 26 | int numnodes; 27 | // how big the nodes array is 28 | int maxnodes; 29 | // first node is the root node 30 | svbsp_node_t *nodes; 31 | // non-zero indicates that an insertion failed because of lack of nodes 32 | int ranoutofnodes; 33 | // tree statistics 34 | // note: do not use multithreading when gathering statistics! 35 | // (the code updating these counters is not thread-safe, increments may 36 | // sometimes fail when multithreaded) 37 | int stat_occluders_rejected; 38 | int stat_occluders_accepted; 39 | int stat_occluders_fragments_rejected; 40 | int stat_occluders_fragments_accepted; 41 | int stat_queries_rejected; 42 | int stat_queries_accepted; 43 | int stat_queries_fragments_rejected; 44 | int stat_queries_fragments_accepted; 45 | } 46 | svbsp_t; 47 | 48 | // this function initializes a tree to prepare for polygon insertions 49 | // 50 | // the maxnodes needed for a given polygon set can vary wildly, if there are 51 | // not enough maxnodes then later polygons will not be inserted and the field 52 | // svbsp_t->ranoutofnodes will be non-zero 53 | // 54 | // as a rule of thumb the minimum nodes needed for a polygon set is 55 | // numpolygons * (averagepolygonvertices + 1) 56 | void SVBSP_Init(svbsp_t *b, const float *origin, int maxnodes, svbsp_node_t *nodes); 57 | 58 | // this function tests if any part of a polygon is not in shadow, and returns 59 | // non-zero if the polygon is not completely shadowed 60 | // 61 | // returns 0 if the polygon was rejected (not facing origin or no points) 62 | // returns 1 if all of the polygon is in shadow 63 | // returns 2 if all of the polygon is unshadowed 64 | // returns 3 if some of the polygon is shadowed and some unshadowed 65 | // 66 | // it also can add a new shadow volume (insertoccluder parameter) 67 | // 68 | // additionally it calls your fragmentcallback on each unshadowed clipped 69 | // part of the polygon 70 | // (beware that polygons often get split heavily, even if entirely unshadowed) 71 | // 72 | // thread-safety notes: do not multi-thread insertions! 73 | int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int insertoccluder, void (*fragmentcallback)(void *fragmentcallback_pointer1, int fragmentcallback_number1, svbsp_t *b, int numpoints, const float *points), void *fragmentcallback_pointer1, int fragmentcallback_number1); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /svn-eol-style-from-gitattributes.sh: -------------------------------------------------------------------------------- 1 | for F in *; do 2 | exec 3<.gitattributes 3 | while read <&3 -r L S; do 4 | if [ -z "${F##$L}" ]; then 5 | s=$S 6 | fi 7 | done 8 | case "$s" in 9 | '-diff -crlf') 10 | svn propdel svn:eol-style "$F" 11 | ;; 12 | '-crlf') 13 | svn propdel svn:eol-style "$F" 14 | ;; 15 | 'crlf=input') 16 | svn propset svn:eol-style native "$F" 17 | ;; 18 | *) 19 | echo "UNKNOWN: $s" 20 | ;; 21 | esac 22 | done 23 | -------------------------------------------------------------------------------- /sys_null.c: -------------------------------------------------------------------------------- 1 | 2 | #include "darkplaces.h" 3 | 4 | 5 | // ======================================================================= 6 | // General routines 7 | // ======================================================================= 8 | 9 | void Sys_SDL_Shutdown(void) 10 | { 11 | } 12 | 13 | void Sys_SDL_Dialog(const char *title, const char *string) 14 | { 15 | } 16 | 17 | char *Sys_SDL_GetClipboardData (void) 18 | { 19 | return NULL; 20 | } 21 | 22 | void Sys_SDL_Init(void) 23 | { 24 | } 25 | 26 | qbool sys_supportsdlgetticks = false; 27 | unsigned int Sys_SDL_GetTicks (void) 28 | { 29 | Sys_Error("Called Sys_SDL_GetTicks on non-SDL target"); 30 | return 0; 31 | } 32 | void Sys_SDL_Delay (unsigned int milliseconds) 33 | { 34 | Sys_Error("Called Sys_SDL_Delay on non-SDL target"); 35 | } 36 | 37 | int main(int argc, char *argv[]) 38 | { 39 | return Sys_Main(argc, argv); 40 | } 41 | -------------------------------------------------------------------------------- /sys_sdl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Include this BEFORE darkplaces.h because it breaks wrapping 3 | * _Static_assert. Cloudwalk has no idea how or why so don't ask. 4 | */ 5 | #include 6 | 7 | #include "darkplaces.h" 8 | 9 | #ifdef WIN32 10 | #ifdef _MSC_VER 11 | #pragma comment(lib, "sdl2.lib") 12 | #pragma comment(lib, "sdl2main.lib") 13 | #endif 14 | #endif 15 | 16 | 17 | // ======================================================================= 18 | // General routines 19 | // ======================================================================= 20 | 21 | void Sys_SDL_Shutdown(void) 22 | { 23 | SDL_Quit(); 24 | } 25 | 26 | // Sys_Error early in startup might screw with automated 27 | // workflows or something if we show the dialog by default. 28 | static qbool nocrashdialog = true; 29 | void Sys_SDL_Dialog(const char *title, const char *string) 30 | { 31 | if(!nocrashdialog) 32 | SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, string, NULL); 33 | } 34 | 35 | char *Sys_SDL_GetClipboardData (void) 36 | { 37 | char *data = NULL; 38 | char *cliptext; 39 | 40 | cliptext = SDL_GetClipboardText(); 41 | if (cliptext != NULL) { 42 | size_t allocsize; 43 | allocsize = min(MAX_INPUTLINE, strlen(cliptext) + 1); 44 | data = (char *)Z_Malloc (allocsize); 45 | dp_strlcpy (data, cliptext, allocsize); 46 | SDL_free(cliptext); 47 | } 48 | 49 | return data; 50 | } 51 | 52 | void Sys_SDL_Init(void) 53 | { 54 | // we don't know which systems we'll want to init, yet... 55 | if (SDL_Init(0) < 0) 56 | Sys_Error("SDL_Init failed: %s\n", SDL_GetError()); 57 | 58 | // COMMANDLINEOPTION: sdl: -nocrashdialog disables "Engine Error" crash dialog boxes 59 | if(!Sys_CheckParm("-nocrashdialog")) 60 | nocrashdialog = false; 61 | } 62 | 63 | qbool sys_supportsdlgetticks = true; 64 | unsigned int Sys_SDL_GetTicks (void) 65 | { 66 | return SDL_GetTicks(); 67 | } 68 | void Sys_SDL_Delay (unsigned int milliseconds) 69 | { 70 | SDL_Delay(milliseconds); 71 | } 72 | 73 | int main(int argc, char *argv[]) 74 | { 75 | return Sys_Main(argc, argv); 76 | } 77 | -------------------------------------------------------------------------------- /taskqueue.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef TASKQUEUE_H 3 | #define TASKQUEUE_H 4 | 5 | #include 6 | #include "qtypes.h" 7 | 8 | typedef struct taskqueue_task_s 9 | { 10 | // if not NULL, this task must be done before this one will dequeue (faster than simply calling TaskQueue_Yield immediately) 11 | struct taskqueue_task_s *preceding; 12 | 13 | // use TaskQueue_IsDone() to poll done status 14 | volatile int done; 15 | 16 | // function to call, and parameters for it to use 17 | void(*func)(struct taskqueue_task_s *task); 18 | // general purpose parameters 19 | void *p[2]; 20 | size_t i[2]; 21 | 22 | unsigned int yieldcount; // number of times this task has been requeued - each task counts only once for purposes of tasksperthread averaging 23 | } 24 | taskqueue_task_t; 25 | 26 | // queue the tasks to be executed, but does not start them (until TaskQueue_WaitforTaskDone is called) 27 | void TaskQueue_Enqueue(int numtasks, taskqueue_task_t *tasks); 28 | 29 | // if the task can not be completed due yet to preconditions, just enqueue it again... 30 | void TaskQueue_Yield(taskqueue_task_t *t); 31 | 32 | // polls for status of task and returns the result, does not cause tasks to be executed (see TaskQueue_WaitForTaskDone for that) 33 | qbool TaskQueue_IsDone(taskqueue_task_t *t); 34 | 35 | // triggers execution of queued tasks, and waits for the specified task to be done 36 | void TaskQueue_WaitForTaskDone(taskqueue_task_t *t); 37 | 38 | // convenience function for setting up a task structure. Does not do the Enqueue, just fills in the struct. 39 | void TaskQueue_Setup(taskqueue_task_t *t, taskqueue_task_t *preceding, void(*func)(taskqueue_task_t *), size_t i0, size_t i1, void *p0, void *p1); 40 | 41 | // general purpose tasks 42 | // t->i[0] = number of tasks in array 43 | // t->p[0] = array of taskqueue_task_t to check 44 | void TaskQueue_Task_CheckTasksDone(taskqueue_task_t *t); 45 | 46 | void TaskQueue_Init(void); 47 | void TaskQueue_Shutdown(void); 48 | void TaskQueue_Frame(qbool shutdown); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /thread.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_H 2 | #define THREAD_H 3 | 4 | #include "qtypes.h" 5 | 6 | // enable Sys_Printf calls on nearly every threading call 7 | //#define THREADDEBUG 8 | //#define THREADDISABLE 9 | // use recursive mutex (non-posix) extensions in thread_pthread 10 | #define THREADRECURSIVE 11 | 12 | typedef int Thread_SpinLock; 13 | typedef struct {int value;} Thread_Atomic; 14 | 15 | #define Thread_CreateMutex() (_Thread_CreateMutex(__FILE__, __LINE__)) 16 | #define Thread_DestroyMutex(m) (_Thread_DestroyMutex(m, __FILE__, __LINE__)) 17 | #define Thread_LockMutex(m) (_Thread_LockMutex(m, __FILE__, __LINE__)) 18 | #define Thread_UnlockMutex(m) (_Thread_UnlockMutex(m, __FILE__, __LINE__)) 19 | #define Thread_CreateCond() (_Thread_CreateCond(__FILE__, __LINE__)) 20 | #define Thread_DestroyCond(cond) (_Thread_DestroyCond(cond, __FILE__, __LINE__)) 21 | #define Thread_CondSignal(cond) (_Thread_CondSignal(cond, __FILE__, __LINE__)) 22 | #define Thread_CondBroadcast(cond) (_Thread_CondBroadcast(cond, __FILE__, __LINE__)) 23 | #define Thread_CondWait(cond, mutex) (_Thread_CondWait(cond, mutex, __FILE__, __LINE__)) 24 | #define Thread_CreateThread(fn, data) (_Thread_CreateThread(fn, data, __FILE__, __LINE__)) 25 | #define Thread_WaitThread(thread, retval) (_Thread_WaitThread(thread, retval, __FILE__, __LINE__)) 26 | #define Thread_CreateBarrier(count) (_Thread_CreateBarrier(count, __FILE__, __LINE__)) 27 | #define Thread_DestroyBarrier(barrier) (_Thread_DestroyBarrier(barrier, __FILE__, __LINE__)) 28 | #define Thread_WaitBarrier(barrier) (_Thread_WaitBarrier(barrier, __FILE__, __LINE__)) 29 | #define Thread_AtomicGet(a) (_Thread_AtomicGet(a, __FILE__, __LINE__)) 30 | #define Thread_AtomicSet(a, v) (_Thread_AtomicSet(a, v, __FILE__, __LINE__)) 31 | #define Thread_AtomicAdd(a, v) (_Thread_AtomicAdd(a, v, __FILE__, __LINE__)) 32 | #define Thread_AtomicIncRef(a) (_Thread_AtomicIncRef(a, __FILE__, __LINE__)) 33 | #define Thread_AtomicDecRef(a) (_Thread_AtomicDecRef(a, __FILE__, __LINE__)) 34 | #define Thread_AtomicTryLock(lock) (_Thread_AtomicTryLock(lock, __FILE__, __LINE__)) 35 | #define Thread_AtomicLock(lock) (_Thread_AtomicLock(lock, __FILE__, __LINE__)) 36 | #define Thread_AtomicUnlock(lock) (_Thread_AtomicUnlock(lock, __FILE__, __LINE__)) 37 | 38 | int Thread_Init(void); 39 | void Thread_Shutdown(void); 40 | qbool Thread_HasThreads(void); 41 | void *_Thread_CreateMutex(const char *filename, int fileline); 42 | void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline); 43 | int _Thread_LockMutex(void *mutex, const char *filename, int fileline); 44 | int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline); 45 | void *_Thread_CreateCond(const char *filename, int fileline); 46 | void _Thread_DestroyCond(void *cond, const char *filename, int fileline); 47 | int _Thread_CondSignal(void *cond, const char *filename, int fileline); 48 | int _Thread_CondBroadcast(void *cond, const char *filename, int fileline); 49 | int _Thread_CondWait(void *cond, void *mutex, const char *filename, int fileline); 50 | void *_Thread_CreateThread(int (*fn)(void *), void *data, const char *filename, int fileline); 51 | int _Thread_WaitThread(void *thread, int retval, const char *filename, int fileline); 52 | void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline); 53 | void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline); 54 | void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline); 55 | int _Thread_AtomicGet(Thread_Atomic *ref, const char *filename, int fileline); 56 | int _Thread_AtomicSet(Thread_Atomic *ref, int v, const char *filename, int fileline); 57 | int _Thread_AtomicAdd(Thread_Atomic *ref, int v, const char *filename, int fileline); 58 | void _Thread_AtomicIncRef(Thread_Atomic *ref, const char *filename, int fileline); 59 | qbool _Thread_AtomicDecRef(Thread_Atomic *ref, const char *filename, int fileline); 60 | qbool _Thread_AtomicTryLock(Thread_SpinLock *lock, const char *filename, int fileline); 61 | void _Thread_AtomicLock(Thread_SpinLock *lock, const char *filename, int fileline); 62 | void _Thread_AtomicUnlock(Thread_SpinLock *lock, const char *filename, int fileline); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /thread_null.c: -------------------------------------------------------------------------------- 1 | #include "quakedef.h" 2 | #include "thread.h" 3 | 4 | int Thread_Init(void) 5 | { 6 | return 0; 7 | } 8 | 9 | void Thread_Shutdown(void) 10 | { 11 | } 12 | 13 | qbool Thread_HasThreads(void) 14 | { 15 | return false; 16 | } 17 | 18 | void *_Thread_CreateMutex(const char *filename, int fileline) 19 | { 20 | return NULL; 21 | } 22 | 23 | void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline) 24 | { 25 | } 26 | 27 | int _Thread_LockMutex(void *mutex, const char *filename, int fileline) 28 | { 29 | return -1; 30 | } 31 | 32 | int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline) 33 | { 34 | return -1; 35 | } 36 | 37 | void *_Thread_CreateCond(const char *filename, int fileline) 38 | { 39 | return NULL; 40 | } 41 | 42 | void _Thread_DestroyCond(void *cond, const char *filename, int fileline) 43 | { 44 | } 45 | 46 | int _Thread_CondSignal(void *cond, const char *filename, int fileline) 47 | { 48 | return -1; 49 | } 50 | 51 | int _Thread_CondBroadcast(void *cond, const char *filename, int fileline) 52 | { 53 | return -1; 54 | } 55 | 56 | int _Thread_CondWait(void *cond, void *mutex, const char *filename, int fileline) 57 | { 58 | return -1; 59 | } 60 | 61 | void *_Thread_CreateThread(int (*fn)(void *), void *data, const char *filename, int fileline) 62 | { 63 | return NULL; 64 | } 65 | 66 | int _Thread_WaitThread(void *thread, int retval, const char *filename, int fileline) 67 | { 68 | return retval; 69 | } 70 | 71 | void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline) 72 | { 73 | return NULL; 74 | } 75 | 76 | void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline) 77 | { 78 | } 79 | 80 | void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline) 81 | { 82 | } 83 | 84 | int _Thread_AtomicGet(Thread_Atomic *a, const char *filename, int fileline) 85 | { 86 | return a->value; 87 | } 88 | 89 | int _Thread_AtomicSet(Thread_Atomic *a, int v, const char *filename, int fileline) 90 | { 91 | int value = a->value; 92 | a->value = v; 93 | return value; 94 | } 95 | 96 | int _Thread_AtomicAdd(Thread_Atomic *a, int v, const char *filename, int fileline) 97 | { 98 | int value = a->value; 99 | a->value += v; 100 | return value; 101 | } 102 | 103 | void _Thread_AtomicIncRef(Thread_Atomic *a, const char *filename, int fileline) 104 | { 105 | a->value++; 106 | } 107 | 108 | qbool _Thread_AtomicDecRef(Thread_Atomic *a, const char *filename, int fileline) 109 | { 110 | return a->value++ == 1; 111 | } 112 | 113 | qbool _Thread_AtomicTryLock(Thread_SpinLock *lock, const char *filename, int fileline) 114 | { 115 | return true; 116 | } 117 | 118 | void _Thread_AtomicLock(Thread_SpinLock *lock, const char *filename, int fileline) 119 | { 120 | } 121 | 122 | void _Thread_AtomicUnlock(Thread_SpinLock *lock, const char *filename, int fileline) 123 | { 124 | } 125 | -------------------------------------------------------------------------------- /timing.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple helper macros to time blocks or statements. 3 | 4 | Copyright (C) 2007 Frank Richter 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | */ 22 | 23 | #ifndef __TIMING_H__ 24 | #define __TIMING_H__ 25 | 26 | #if defined(DO_TIMING) 27 | 28 | #define TIMING_BEGIN double _timing_end_, _timing_start_ = Sys_DirtyTime(); 29 | #define TIMING_END_STR(S) \ 30 | _timing_end_ = Sys_DirtyTime(); \ 31 | Con_Printf ("%s: %.3g s\n", S, _timing_end_ - _timing_start_); 32 | #define TIMING_END TIMING_END_STR(__FUNCTION__) 33 | 34 | #define TIMING_INTERMEDIATE(S) \ 35 | { \ 36 | double currentTime = Sys_DirtyTime(); \ 37 | Con_Printf ("%s: %.3g s\n", S, currentTime - _timing_start_); \ 38 | } 39 | 40 | #define TIMING_TIMESTATEMENT(Stmt) \ 41 | { \ 42 | TIMING_BEGIN \ 43 | Stmt; \ 44 | TIMING_END_STR(#Stmt); \ 45 | } 46 | 47 | #else 48 | 49 | #define TIMING_BEGIN 50 | #define TIMING_END_STR(S) 51 | #define TIMING_END 52 | #define TIMING_INTERMEDIATE(S) 53 | #define TIMING_TIMESTATEMENT(Stmt) Stmt 54 | 55 | #endif 56 | 57 | #endif // __TIMING_H__ 58 | 59 | -------------------------------------------------------------------------------- /vid_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #include "quakedef.h" 21 | 22 | #include 23 | 24 | int cl_available = false; 25 | 26 | qbool vid_supportrefreshrate = false; 27 | 28 | void VID_Shutdown(void) 29 | { 30 | } 31 | 32 | void VID_Finish (void) 33 | { 34 | } 35 | 36 | void VID_Init(void) 37 | { 38 | } 39 | 40 | qbool VID_InitMode(const viddef_mode_t *mode) 41 | { 42 | return false; 43 | } 44 | 45 | void *GL_GetProcAddress(const char *name) 46 | { 47 | return NULL; 48 | } 49 | 50 | void Sys_SDL_HandleEvents(void) 51 | { 52 | } 53 | 54 | void VID_BuildJoyState(vid_joystate_t *joystate) 55 | { 56 | } 57 | 58 | void IN_Move(void) 59 | { 60 | } 61 | 62 | size_t VID_ListModes(vid_mode_t *modes, size_t maxcount) 63 | { 64 | return 0; 65 | } 66 | 67 | qbool GL_ExtensionSupported(const char *name) 68 | { 69 | return false; 70 | } 71 | -------------------------------------------------------------------------------- /view.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEW_H 2 | #define VIEW_H 3 | 4 | #include "qtypes.h" 5 | #include "matrixlib.h" 6 | struct cmd_state_s; 7 | 8 | void V_Init (void); 9 | void V_UpdateBlends (void); 10 | void V_ParseDamage (void); 11 | void V_DriftPitch(void); 12 | void V_FadeViewFlashs(void); 13 | void V_CalcViewBlend(void); 14 | void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qbool teleported, qbool clonground, qbool clcmdjump, float clstatsviewheight, qbool cldead, const vec3_t clvelocity); 15 | void V_CalcRefdef(void); 16 | void V_MakeViewIsometric(void); 17 | void V_StartPitchDrift(void); 18 | void V_StopPitchDrift (void); 19 | void V_StartPitchDrift_f(struct cmd_state_s *cmd); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /vpk.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2020-2021 David Knapp (Cloudwalk) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #ifndef VPK_H 22 | #define VPK_H 23 | 24 | #include 25 | 26 | /* 27 | * The VPK format is Valve's package format for Source engine games, 28 | * used to store game content. 29 | * 30 | * Game content is spread across multiple VPK files. A single, special 31 | * VPK file, ending in _dir.vpk, contains a centralized directory 32 | * tree for all of the other files, and has its own header. 33 | * Although content can be stored in the directory file. 34 | * 35 | * This is useful for navigating game content without having 36 | * to guess which VPK some file belongs to, while also 37 | * making game updates more efficient by spreading content 38 | * across multiple files, where opening and closing thousands 39 | * of loose files to update them is less efficient. 40 | */ 41 | 42 | const uint32_t VPK_SIGNATURE = 0x55aa1234; 43 | 44 | typedef struct dvpk_header_v1_s 45 | { 46 | const uint32_t signature; // Should always be VPK_SIGNATURE 47 | const uint32_t version; // Should always be 1 48 | 49 | // Size of directory tree 50 | uint32_t tree_size; 51 | } dvpk_header_v1_t; 52 | 53 | typedef struct dvpk_header_v2_s 54 | { 55 | const uint32_t signature; // Should always be VPK_SIGNATURE 56 | const uint32_t version; // Should always be 2 57 | 58 | // Size of directory tree 59 | uint32_t tree_size; 60 | 61 | // Section sizes 62 | uint32_t filedata_size; 63 | uint32_t archivemd5_size; 64 | uint32_t othermd5_size; 65 | uint32_t signature_size; 66 | } dvpk_header_v2_t; 67 | 68 | typedef struct dvpk_dir_entry_s 69 | { 70 | uint32_t crc32; 71 | uint16_t preloadbytes; 72 | 73 | uint16_t archiveindex; 74 | uint32_t entryoffset; 75 | uint32_t entrylength; 76 | const uint16_t terminator; // Should always be 0xFFFF 77 | } dvpk_dir_entry_t; 78 | 79 | typedef struct dvpk_archive_md5_entry_s 80 | { 81 | uint32_t archiveindex; 82 | uint32_t startingoffset; 83 | uint32_t count; 84 | int8_t md5sum[16]; 85 | } dvpk_archive_md5_entry_t; 86 | 87 | typedef struct dvpk_other_md5_entry_s 88 | { 89 | int8_t treesum[16]; 90 | int8_t archivemd5sum[16]; 91 | int8_t unknown[16]; // ?? 92 | } dvpk_other_md5_entry_t; 93 | 94 | typedef struct dvpk_signature_entry_s 95 | { 96 | uint32_t pubkeysize; // Always 160 97 | int8_t pubkey[160]; 98 | uint32_t signaturesize; // Always 128 99 | int8_t signature[128]; 100 | } dvpk_signature_entry_t; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /wad.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // wad.h 21 | 22 | #ifndef WAD_H 23 | #define WAD_H 24 | 25 | #include 26 | struct sizebuf_s; 27 | 28 | //=============== 29 | // TYPES 30 | //=============== 31 | 32 | #define CMP_NONE 0 33 | #define CMP_LZSS 1 34 | 35 | #define TYP_NONE 0 36 | #define TYP_LABEL 1 37 | 38 | #define TYP_LUMPY 64 // 64 + grab command number 39 | #define TYP_PALETTE 64 40 | #define TYP_QTEX 65 41 | #define TYP_QPIC 66 42 | #define TYP_SOUND 67 43 | #define TYP_MIPTEX 68 44 | 45 | typedef struct qpic_s 46 | { 47 | int width, height; 48 | unsigned char data[4]; // variably sized 49 | } qpic_t; 50 | 51 | 52 | 53 | typedef struct wadinfo_s 54 | { 55 | char identification[4]; // should be WAD2 or 2DAW 56 | int numlumps; 57 | int infotableofs; 58 | } wadinfo_t; 59 | 60 | typedef struct lumpinfo_s 61 | { 62 | int filepos; 63 | int disksize; 64 | int size; // uncompressed 65 | char type; 66 | char compression; 67 | char pad1, pad2; 68 | char name[16]; // must be null terminated 69 | } lumpinfo_t; 70 | 71 | void W_UnloadAll(void); 72 | unsigned char *W_GetLumpName(const char *name, int64_t *returnfilesize); 73 | 74 | // halflife texture wads 75 | void W_LoadTextureWadFile(char *filename, int complain); 76 | unsigned char *W_GetTextureBGRA(char *name); // returns tempmempool allocated image data, width and height are in image_width and image_height 77 | unsigned char *W_ConvertWAD3TextureBGRA(struct sizebuf_s *sb); // returns tempmempool allocated image data, width and height are in image_width and image_height 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /wasm/autoexec.cfg: -------------------------------------------------------------------------------- 1 | cl_particles_quake "1" 2 | 3 | -------------------------------------------------------------------------------- /wasm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DarkPlaces Quake WASM 6 | 7 | 8 | 9 | 15 | 16 | 17 | 18 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /wasm/pre.js: -------------------------------------------------------------------------------- 1 | if (!Object.hasOwn(Module, 'arguments')) { 2 | Module['arguments'] = ['-basedir', '/game']; 3 | } 4 | else { 5 | Module['arguments'] = ['-basedir', '/game'].concat(Module['arguments']); 6 | } 7 | 8 | Module['print'] = function(text) { 9 | console.log(text); 10 | } 11 | 12 | Module['printErr'] = function(text) { 13 | console.error(text); 14 | } 15 | 16 | 17 | Module['preRun'] = [ 18 | function() 19 | { 20 | function stdin(){ 21 | return '\n'; // Return a newline/line feed character so the user is not prompted for input 22 | }; 23 | FS.init(stdin, null, null); // null for both stdout and stderr 24 | 25 | function createParentDirectory(filePath) { 26 | // 27 | // Split a filePath into parts, create the directory hierarchy 28 | // 29 | parts = filePath.split('/'); 30 | for (let i = parts.length - 1; i > 0; i--) { 31 | localDir = '/game/' + parts.slice(0, -i).join('/') 32 | try { 33 | FS.mkdir(localDir); 34 | } 35 | catch { 36 | // Directory already exists 37 | } 38 | } 39 | } 40 | 41 | function startDownload(localPath, remotePath) { 42 | // 43 | // Return a promise of a file download 44 | // 45 | Module['addRunDependency'](localPath); // Tell Emscripten about the dependency 46 | 47 | return fetch(remotePath) 48 | .then(response => { 49 | return response.arrayBuffer(); 50 | }) 51 | .then(arrayBuffer => { 52 | const buffer = new Uint8Array(arrayBuffer); 53 | stream = FS.open("/game/" + localPath, "w"); 54 | FS.write(stream, buffer, 0, buffer.byteLength); 55 | FS.close(stream); 56 | console.log("Downloaded " + localPath); 57 | Module['removeRunDependency'](localPath); // Tells Emscripten we've finished the download 58 | }); 59 | } 60 | 61 | function createBaseDir() { 62 | // 63 | // Creates the Quake basedir and mounts it to IDBFS 64 | // 65 | FS.mkdir('/game'); 66 | //mounts IDBFS to where the game would save 67 | FS.mount(IDBFS, {}, '/home/web_user/'); 68 | } 69 | 70 | function downloadGameFiles() { 71 | // 72 | // Download files specified in the Module.files object 73 | // 74 | createBaseDir(); 75 | 76 | let downloads = []; 77 | for (const [localPath, remotePath] of Object.entries(Module.files)) { 78 | console.log("Downloading " + remotePath + " to " + localPath); 79 | 80 | createParentDirectory(localPath); 81 | 82 | downloads.push( 83 | startDownload(localPath, remotePath) 84 | ); 85 | } 86 | 87 | // Wait for downloads to finish, sync the filesystem, start the game 88 | Promise.all(downloads) 89 | .then(function(results) { 90 | FS.syncfs(true, function (err) { 91 | assert(!err); 92 | Module.callMain(Module.arguments); 93 | }); 94 | }); 95 | } 96 | 97 | downloadGameFiles(); 98 | } 99 | ]; 100 | 101 | Module['noInitialRun'] = true; 102 | -------------------------------------------------------------------------------- /wasm/preload/runhere: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DarkPlacesEngine/DarkPlaces/af1e5c03be8e2fd41135f9064ad8e4c4c1ccd8f4/wasm/preload/runhere -------------------------------------------------------------------------------- /wasm/standalone-shell.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | DarkPlaces 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 60 | 61 | 62 | {{{ SCRIPT }}} 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /wasm/standaloneprejs.js: -------------------------------------------------------------------------------- 1 | //current command in ascii decimal 2 | let currentcmd = [0,0,0] 3 | let currentfile = ""; 4 | const sleep = ms => new Promise(r => setTimeout(r, ms)); 5 | 6 | Module['print'] = function(text) { console.log(text); } 7 | 8 | Module['preRun'] = function() 9 | { 10 | function stdin() { return 10 }; 11 | var stdout = null; 12 | var stderr = null; 13 | FS.init(stdin, stdout, stderr); 14 | FS.mount(IDBFS, {}, "/home/web_user/"); 15 | FS.symlink("/home/web_user", "/save"); 16 | } 17 | 18 | Module['noInitialRun'] = true 19 | 20 | document.addEventListener('click', (ev) => { 21 | console.log("event is captured only once."); 22 | args = [] 23 | if(window.location.href.indexOf("file://") > -1) 24 | { 25 | try 26 | { 27 | args = args.concat(prompt("Enter command line arguments").split(" ")) 28 | } 29 | catch (error) 30 | { 31 | console.log("Error: ", error); 32 | console.log("Failed to concat extra arguments (likely passed nothing for the argument)") 33 | } 34 | } 35 | else 36 | { 37 | parms = new URLSearchParams(window.location.search); 38 | try 39 | { 40 | args = args.concat(parms.get("args").split(" ")) 41 | } 42 | catch (error) 43 | { 44 | console.log("Error: ", error); 45 | console.log("Failed to concat extra arguments (likely passed nothing for the argument)") 46 | } 47 | } 48 | 49 | FS.syncfs(true, function() 50 | { 51 | if(FS.analyzePath("/preload/runhere").exists) 52 | { 53 | FS.symlink("/preload", "/home/web_user/games"); 54 | args = args.concat(["-basedir", "/home/web_user/games"]) 55 | } 56 | else 57 | { 58 | args = args.concat(["-basedir", "/home/web_user/"]) 59 | } 60 | 61 | Module.callMain(args); 62 | }); 63 | }, { once: true }); 64 | -------------------------------------------------------------------------------- /world.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // world.h 21 | 22 | #ifndef WORLD_H 23 | #define WORLD_H 24 | 25 | #include "qtypes.h" 26 | #include "collision.h" 27 | 28 | #define MOVE_NORMAL 0 29 | #define MOVE_NOMONSTERS 1 30 | #define MOVE_MISSILE 2 31 | #define MOVE_WORLDONLY 3 32 | #define MOVE_HITMODEL 4 33 | 34 | #define AREA_GRID 128 35 | #define AREA_GRIDNODES (AREA_GRID * AREA_GRID) 36 | 37 | typedef struct link_s 38 | { 39 | llist_t list; 40 | int entitynumber; 41 | } link_t; 42 | 43 | typedef struct world_physics_s 44 | { 45 | // for ODE physics engine 46 | qbool ode; // if true then ode is activated 47 | void *ode_world; 48 | void *ode_space; 49 | void *ode_contactgroup; 50 | // number of constraint solver iterations to use (for dWorldQuickStep) 51 | int ode_iterations; 52 | // actual step (server frametime / ode_iterations) 53 | vec_t ode_step; 54 | // time we need to simulate, for constantstep 55 | vec_t ode_time; 56 | // stats 57 | int ode_numobjects; // total objects cound 58 | int ode_activeovjects; // active objects count 59 | // max velocity for a 1-unit radius object at current step to prevent 60 | // missed collisions 61 | vec_t ode_movelimit; 62 | } 63 | world_physics_t; 64 | 65 | struct prvm_prog_s; 66 | 67 | typedef struct world_s 68 | { 69 | // convenient fields 70 | char filename[MAX_QPATH]; 71 | vec3_t mins; 72 | vec3_t maxs; 73 | struct prvm_prog_s *prog; 74 | 75 | int areagrid_stats_calls; 76 | int areagrid_stats_nodechecks; 77 | int areagrid_stats_entitychecks; 78 | 79 | link_t areagrid[AREA_GRIDNODES]; 80 | link_t areagrid_outside; 81 | vec3_t areagrid_bias; 82 | vec3_t areagrid_scale; 83 | vec3_t areagrid_mins; 84 | vec3_t areagrid_maxs; 85 | vec3_t areagrid_size; 86 | int areagrid_marknumber; 87 | 88 | // if the QC uses a physics engine, the data for it is here 89 | world_physics_t physics; 90 | } 91 | world_t; 92 | 93 | struct prvm_edict_s; 94 | 95 | // cyclic doubly-linked list functions 96 | void World_ClearLink(link_t *l); 97 | void World_RemoveLink(link_t *l); 98 | void World_InsertLinkBefore(link_t *l, link_t *before, int entitynumber); 99 | 100 | void World_Init(void); 101 | void World_Shutdown(void); 102 | 103 | /// called after the world model has been loaded, before linking any entities 104 | void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs, struct prvm_prog_s *prog); 105 | /// unlinks all entities (used before reallocation of edicts) 106 | void World_UnlinkAll(world_t *world); 107 | 108 | void World_PrintAreaStats(world_t *world, const char *worldname); 109 | 110 | /// call before removing an entity, and before trying to move one, 111 | /// so it doesn't clip against itself 112 | void World_UnlinkEdict(struct prvm_edict_s *ent); 113 | 114 | /// Needs to be called any time an entity changes origin, mins, maxs 115 | void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs, qbool link_solid_not); 116 | 117 | /// \returns list of entities touching a box 118 | int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, struct prvm_edict_s **list); 119 | 120 | void World_Start(world_t *world); 121 | void World_End(world_t *world); 122 | 123 | // update physics 124 | // this is called by SV_Physics 125 | void World_Physics_Frame(world_t *world, double frametime, double gravity); 126 | 127 | // change physics properties of entity 128 | struct prvm_edict_s; 129 | struct edict_odefunc_s; 130 | void World_Physics_ApplyCmd(struct prvm_edict_s *ed, struct edict_odefunc_s *f); 131 | 132 | // remove physics data from entity 133 | // this is called by entity removal 134 | void World_Physics_RemoveFromEntity(world_t *world, struct prvm_edict_s *ed); 135 | void World_Physics_RemoveJointFromEntity(world_t *world, struct prvm_edict_s *ed); 136 | 137 | #endif 138 | 139 | --------------------------------------------------------------------------------