mirror of https://github.com/FWGS/xash3d-fwgs
Compare commits
No commits in common. "master" and "continuous-nswitch-link-fixes" have entirely different histories.
master
...
continuous
|
@ -1,27 +0,0 @@
|
|||
image: alpine/latest
|
||||
packages:
|
||||
- build-base
|
||||
- sdl2-dev
|
||||
- freetype-dev
|
||||
- fontconfig-dev
|
||||
- opus-dev
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
- client: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
|
||||
- server: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure --reconfigure --dedicated build install --destdir=bin
|
||||
- run-tests: |
|
||||
cd xash3d-fwgs/bin
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
./xash3d -runtests
|
||||
./xash -runtests
|
||||
rm -rf valve/gameinfo.txt test_*
|
||||
- package: |
|
||||
cd xash3d-fwgs/bin
|
||||
tar -cjvf xash3d-fwgs-alpine-amd64.tar.bz2 *
|
||||
artifacts:
|
||||
- xash3d-fwgs/bin/xash3d-fwgs-alpine-amd64.tar.bz2
|
|
@ -1,30 +0,0 @@
|
|||
image: debian/sid
|
||||
arch: amd64
|
||||
packages:
|
||||
- build-essential
|
||||
- python-is-python3
|
||||
- libsdl2-dev
|
||||
- libfreetype-dev
|
||||
- libfontconfig-dev
|
||||
- libopus-dev
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
- client: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
|
||||
- server: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure --reconfigure --dedicated build install --destdir=bin
|
||||
- run-tests: |
|
||||
cd xash3d-fwgs/bin
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
./xash3d -runtests
|
||||
./xash -runtests
|
||||
rm -rf valve/gameinfo.txt test_*
|
||||
- package: |
|
||||
cd xash3d-fwgs/bin
|
||||
tar -cjvf xash3d-fwgs-debian-arm64.tar.bz2 *
|
||||
artifacts:
|
||||
- xash3d-fwgs/bin/xash3d-fwgs-debian-arm64.tar.bz2
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
image: debian/sid
|
||||
packages:
|
||||
- build-essential
|
||||
- python-is-python3
|
||||
- libsdl2-dev
|
||||
- libfreetype-dev
|
||||
- libfontconfig-dev
|
||||
- libopus-dev
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
- client: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
|
||||
- server: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure --reconfigure --dedicated build install --destdir=bin
|
||||
- run-tests: |
|
||||
cd xash3d-fwgs/bin
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
./xash3d -runtests
|
||||
./xash -runtests
|
||||
rm -rf valve/gameinfo.txt test_*
|
||||
- package: |
|
||||
cd xash3d-fwgs/bin
|
||||
tar -cjvf xash3d-fwgs-debian-amd64.tar.bz2 *
|
||||
artifacts:
|
||||
- xash3d-fwgs/bin/xash3d-fwgs-debian-amd64.tar.bz2
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
image: freebsd/latest
|
||||
packages:
|
||||
- lang/python
|
||||
- devel/pkgconf
|
||||
- devel/sdl20
|
||||
- print/freetype2
|
||||
- x11-fonts/fontconfig
|
||||
- audio/opus
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
- client: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure --enable-tests --enable-engine-tests build install --destdir=bin
|
||||
- server: |
|
||||
cd xash3d-fwgs
|
||||
./waf configure --reconfigure --dedicated build install --destdir=bin
|
||||
- run-tests: |
|
||||
cd xash3d-fwgs/bin
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
./xash3d -runtests
|
||||
./xash -runtests
|
||||
rm -rf valve/gameinfo.txt test_*
|
||||
- package: |
|
||||
cd xash3d-fwgs/bin
|
||||
tar -cjvf xash3d-fwgs-freebsd-amd64.tar.bz2 *
|
||||
artifacts:
|
||||
- xash3d-fwgs/bin/xash3d-fwgs-freebsd-amd64.tar.bz2
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
image: netbsd/latest
|
||||
packages:
|
||||
- python311
|
||||
- SDL2
|
||||
- freetype2
|
||||
- fontconfig
|
||||
- libopus
|
||||
- pkgconf
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
- client: |
|
||||
cd xash3d-fwgs
|
||||
python3.11 waf configure --enable-tests --enable-engine-tests build install --destdir=bin
|
||||
- server: |
|
||||
cd xash3d-fwgs
|
||||
python3.11 waf configure --reconfigure --dedicated build install --destdir=bin
|
||||
- run-tests: |
|
||||
cd xash3d-fwgs/bin
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
./xash3d -runtests
|
||||
./xash -runtests
|
||||
rm -rf valve/gameinfo.txt test_*
|
||||
- package: |
|
||||
cd xash3d-fwgs/bin
|
||||
tar -cjvf xash3d-fwgs-netbsd-amd64.tar.bz2 *
|
||||
artifacts:
|
||||
- xash3d-fwgs/bin/xash3d-fwgs-netbsd-amd64.tar.bz2
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
image: openbsd/latest
|
||||
packages:
|
||||
- python3
|
||||
- sdl2
|
||||
- opus
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
- client: |
|
||||
cd xash3d-fwgs
|
||||
python3 waf configure --enable-tests --enable-engine-tests build install --destdir=bin
|
||||
- server: |
|
||||
cd xash3d-fwgs
|
||||
python3 waf configure --reconfigure --dedicated build install --destdir=bin
|
||||
- run-tests: |
|
||||
cd xash3d-fwgs/bin
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
./xash3d -runtests
|
||||
./xash -runtests
|
||||
rm -rf valve/gameinfo.txt test_*
|
||||
- package: |
|
||||
cd xash3d-fwgs/bin
|
||||
tar -cjvf xash3d-fwgs-openbsd-amd64.tar.bz2 *
|
||||
artifacts:
|
||||
- xash3d-fwgs/bin/xash3d-fwgs-openbsd-amd64.tar.bz2
|
||||
|
26
.cirrus.yml
26
.cirrus.yml
|
@ -1,7 +1,31 @@
|
|||
task:
|
||||
name: freebsd-12-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-4
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
- ./scripts/cirrus/build_freebsd.sh full
|
||||
|
||||
task:
|
||||
name: freebsd-13-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-2
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
- ./scripts/cirrus/build_freebsd.sh full
|
||||
|
||||
task:
|
||||
name: freebsd-14-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-0
|
||||
image_family: freebsd-14-0-snap
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
custom: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/donate.md
|
|
@ -24,9 +24,14 @@ jobs:
|
|||
# - os: ubuntu-aarch64-20.04
|
||||
# targetos: linux
|
||||
# targetarch: aarch64
|
||||
- os: ubuntu-20.04
|
||||
targetos: android
|
||||
targetarch: multiarch
|
||||
|
||||
# - os: ubuntu-20.04
|
||||
# targetos: android
|
||||
# targetarch: 32
|
||||
# - os: ubuntu-20.04
|
||||
# targetos: android
|
||||
# targetarch: 64
|
||||
|
||||
# - os: ubuntu-20.04
|
||||
# targetos: motomagx
|
||||
# targetarch: armv6
|
||||
|
@ -40,12 +45,13 @@ jobs:
|
|||
- os: windows-latest
|
||||
targetos: win32
|
||||
targetarch: amd64
|
||||
- os: windows-2019 # always use the oldest possible for 32-bit because of older compilers, and better support of certain legacy OSes
|
||||
- os: windows-latest
|
||||
targetos: win32
|
||||
targetarch: i386
|
||||
env:
|
||||
SDL_VERSION: 2.30.3
|
||||
SDL_VERSION: 2.28.1
|
||||
GH_CPU_ARCH: ${{ matrix.targetarch }}
|
||||
ANDROID_SDK_TOOLS_VER: 4333796
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
|
|
@ -54,11 +54,6 @@ CMakeFiles
|
|||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
CMakeLists.txt*
|
||||
CMakeScripts
|
||||
Testing
|
||||
compile_commands.json
|
||||
_deps
|
||||
# makedepend
|
||||
Makefile.dep
|
||||
*.bak
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2d9b5afe109ab9f1f7f39754a5ba550e8cffa80a
|
||||
Subproject commit 7ba4631bf5e921284100d10923b6980af66d98e8
|
|
@ -1 +1 @@
|
|||
Subproject commit e39434a2b17d12be569a1406f3bd23ac6a231347
|
||||
Subproject commit 5226f5f9370eebe874dae0525ad5d878a3b66faf
|
|
@ -18,7 +18,7 @@ def build(bld):
|
|||
target = 'gl4es',
|
||||
features = 'c',
|
||||
includes = ['gl4es/src', 'gl4es/src/gl', 'gl4es/src/glx', 'gl4es/include'],
|
||||
defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'NO_LOADER', 'STATICLIB'],
|
||||
defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'EXTERNAL_GETPROCADDRESS=GL4ES_GetProcAddress', 'NO_LOADER', 'STATICLIB'],
|
||||
cflags = ['-w', '-fvisibility=hidden', '-std=gnu99'],
|
||||
subsystem = bld.env.MSVC_SUBSYSTEM,
|
||||
export_includes = '.')
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b4e7041c9687079450218786aa4f62273a874a1a
|
||||
Subproject commit d2544938fad58126af486e99845e9be105b9fdd3
|
|
@ -1 +1 @@
|
|||
Subproject commit e75792de037ee141f7d596b95cf17bef23b119e2
|
||||
Subproject commit 6b6a947ee0c32abceea3e111364b0225af36df61
|
|
@ -1 +1 @@
|
|||
Subproject commit 7276993f3f4103af3f19f8313ebb2f69416f7cac
|
||||
Subproject commit f85d64c1490b0ee74d146adca5811251d6ee1deb
|
|
@ -1,16 +1,17 @@
|
|||
# Bug-compatibility in Xash3D FWGS
|
||||
|
||||
Xash3D FWGS has special mode for games that rely on original engine bugs. In this mode, we emulate the behaviour of selected functions that may help running mods relying on engine bugs, but enabling them by default may break majority of other games.
|
||||
Xash3D FWGS has special mode for games that rely on original engine bugs.
|
||||
|
||||
In this mode, we emulate the behaviour of selected functions that may help running mods relying on engine bugs, but enabling them by default may break majority of other games.
|
||||
|
||||
At this time, we only have implemented GoldSrc bug-compatibility. It can be enabled with `-bugcomp` command line switch.
|
||||
|
||||
When `-bugcomp` is specified without argument, it enables everything. This behavior might be changed or removed in future versions.
|
||||
|
||||
When `-bugcomp` is specified with argument, it interpreted as flags separated with `+`. This way it's possible to combine multiple levels of bug-compatibility.
|
||||
|
||||
## GoldSrc bug-compatibility
|
||||
|
||||
| Flag | Description | Games that require this flag |
|
||||
| ------- | ----------- | ---------------------------- |
|
||||
| `peoei` | Reverts `pfnPEntityOfEntIndex` behavior to GoldSrc, where it returns NULL for last player due to incorrect player index comparison | * Counter-Strike: Condition Zero - Deleted Scenes |
|
||||
| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol. Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods |
|
||||
### Emulated bugs
|
||||
|
||||
* `pfnPEntityOfEntIndex` in GoldSrc returns NULL for last player due to incorrect player index comparison
|
||||
|
||||
### Games and mods that require this
|
||||
|
||||
* Counter-Strike: Condition Zero - Deleted Scenes
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
## Environment variables
|
||||
|
||||
#### Xash3D FWGS
|
||||
|
||||
The engine respects these environment variables:
|
||||
|
||||
| Variable | Type | Description |
|
||||
| --------------------- | ---------- | ----------- |
|
||||
| `XASH3D_GAME` | _string_ | Overrides default game directory. Ignored if `-game` command line argument is set |
|
||||
| `XASH3D_BASEDIR` | _string_ | Sets path to base (root) directory, instead of current working directory |
|
||||
| `XASH3D_RODIR` | _string_ | Sets path to read-only base (root) directory. Ignored if `-rodir` command line argument is set |
|
||||
| `XASH3D_EXTRAS_PAK1` | _string_ | Archive file from specified path will be added to virtual filesystem search path in the lowest possible priority |
|
||||
| `XASH3D_EXTRAS_PAK2` | _string_ | Similar to `XASH3D_EXTRAS_PAK1` but next to it in priority list |
|
||||
|
||||
Environment variables NOT listed in the table above are used internally, and aren't considered as stable interface.
|
||||
|
||||
#### mdldec
|
||||
|
||||
| Variable | Type | Description |
|
||||
| --------------------- | ---------- | ----------- |
|
||||
| `MDLDEC_ACT_PATH` | _string_ | If set, will read activities list from this path |
|
|
@ -1,25 +0,0 @@
|
|||
# GetNativeObject API
|
||||
|
||||
To be able to use platform-specific features or get optional engine interfaces, we've added a simple call to MobilityAPI on client DLL and PhysicsAPI for server DLL and extended MenuAPI for menu DLL.
|
||||
|
||||
It's defined like this:
|
||||
|
||||
```
|
||||
void *pfnGetNativeObject( const char *name );
|
||||
```
|
||||
|
||||
#### Cross-platform objects
|
||||
|
||||
Only these objects are guaranteed to be available on all targets.
|
||||
|
||||
| Object name | Interface |
|
||||
|-------------|-----------|
|
||||
| `VFileSystem009` | Provides C++ interface to filesystem, binary-compatible with Valve's VFileSystem009. |
|
||||
| `XashFileSystemXXX` | Provides C interface to filesystem. This interface is unstable and not recommended for generic use, outside of engine internals. For more info about current version look into `filesystem.h`. |
|
||||
|
||||
#### Android-specific objects
|
||||
|
||||
| Object name | Interface |
|
||||
|-------------|-----------|
|
||||
| `JNIEnv` | Allows interfacing with Java Native Interface. |
|
||||
| `ActivityClass` | Returns JNI object for engine Android activity class. |
|
|
@ -1,65 +0,0 @@
|
|||
# sounds.lst.md
|
||||
|
||||
Using sounds.lst located in scripts folder, modder can override some of the hardcoded sounds in temp entities and server physics.
|
||||
|
||||
File format:
|
||||
```
|
||||
<group name>
|
||||
{
|
||||
<path1>
|
||||
<path2>
|
||||
<path3>
|
||||
}
|
||||
|
||||
<group2 name> <path with %d> <min number> <max number>
|
||||
```
|
||||
|
||||
* Sounds can use any supported sound format (WAV or MP3).
|
||||
* The path must be relative to the sounds/ folder in the game or base directory root, addon folder, or archive root.
|
||||
* Groups can be empty or omitted from the file to load no sound.
|
||||
* Groups can either list a set of files or specify a format string and a range.
|
||||
* Anything after // will be considered a comment and ignored.
|
||||
* Behavior is undefined if the group was listed multiple times.
|
||||
|
||||
Currently supported groups are:
|
||||
|Group name|Usage|
|
||||
|----------|-----|
|
||||
|`BouncePlayerShell`|Used for BOUNCE_SHELL tempentity hitsound|
|
||||
|`BounceWeaponShell`|Used for BOUCNE_SHOTSHELL tempentity hitsound|
|
||||
|`BounceConcrete`|Used for BOUNCE_CONCRETE tempentity hitsound|
|
||||
|`BounceGlass`|Used for BOUCNE_GLASS|
|
||||
|`BounceMetal`|Used for BOUNCE_METAL|
|
||||
|`BounceFlesh`|Used for BOUNCE_FLESH|
|
||||
|`BounceWood`|Used for BOUNCE_WOOD|
|
||||
|`Ricochet`|Used for BOUNCE_SHRAP and ricochet tempentities|
|
||||
|`Explode`|Used for tempentity explosions|
|
||||
|`EntityWaterEnter`|Used for entity entering water|
|
||||
|`EntityWaterExit`|Used for entity exiting water|
|
||||
|`PlayerWaterEnter`|Used for player entering water|
|
||||
|`PlayerWaterExit`|Used for player exiting water|
|
||||
|
||||
## Example
|
||||
|
||||
This example is based on defaults sounds used in Half-Life:
|
||||
|
||||
```
|
||||
BouncePlayerShell "player/pl_shell%d.wav" 1 3
|
||||
BounceWeaponShell "weapons/sshell%d.wav" 1 3
|
||||
BounceConcrete "debris/concrete%d.wav" 1 3
|
||||
BounceGlass "debris/glass%d.wav" 1 4
|
||||
BounceMetal "debris/metal%d.wav" 1 6
|
||||
BounceFlesh "debris/flesh%d.wav" 1 7
|
||||
BounceWood "debris/wood%d.wav" 1 4
|
||||
Ricochet "weapons/ric%d.wav" 1 5
|
||||
Explode "weapons/explode%d.wav" 3 5
|
||||
EntityWaterEnter "player/pl_wade%d.wav" 1 4
|
||||
EntityWaterExit "player/pl_wade%d.wav" 1 4
|
||||
PlayerWaterEnter
|
||||
{
|
||||
"player/pl_wade1.wav"
|
||||
}
|
||||
PlayerWaterExit
|
||||
{
|
||||
"player/pl_wade2.wav"
|
||||
}
|
||||
```
|
|
@ -1,40 +0,0 @@
|
|||
### HD (external) textures support
|
||||
|
||||
Xash3D supports loading texture replacements in TGA format for almost all types of models in the game, except alias models at this time.
|
||||
|
||||
Textures are expected to be located at:
|
||||
* `modfolder/materials/<mapname>` - for a specific map
|
||||
* `modfolder/materials/common` - common for all maps
|
||||
* `modfolder/materials/decals` - for decals
|
||||
* `modfolder/materials/models/<model>` - for models (texture name must match the internal texture name in the model)
|
||||
|
||||
Support for high-resolution textures is enabled setting `host_allow_materials` cvar to `1` or in the menu, in "Video options" section.
|
||||
|
||||
#### Xash3D FWGS additions
|
||||
|
||||
In addition to paths above, Xash3D FWGS checks following paths:
|
||||
|
||||
* `modfolder/materials/sprites/<sprite>` - for sprites, except HUD sprites
|
||||
|
||||
Also, to check which texture replacements are loaded successfully, failed or weren't found, a mod developer can set `host_allow_materials` cvar value to `2`. The engine will spew log at any developer level in the following format:
|
||||
|
||||
```
|
||||
Looking for <replacement> replacement... <status code> (<path relative to mod directory>)
|
||||
```
|
||||
|
||||
Status codes:
|
||||
* `OK` - texture replacement file was found and loaded into GPU memory successfully
|
||||
* `FAIL` - texture file was found but hasn't been parsed or loaded successfully. Refer to engine log for more details.
|
||||
* `MISS` - texture file wasn't found
|
||||
|
||||
Example:
|
||||
```
|
||||
Looking for maps/bounce.bsp:!waterblue tex replacement...OK (materials/common/!waterblue.tga)
|
||||
Looking for maps/bounce.bsp:!waterblue_luma tex replacement...MISS (not found)
|
||||
Looking for {shot2 decal replacement...MISS (materials/decals/{shot2.tga)
|
||||
Looking for {shot4 decal replacement...MISS (materials/decals/{shot4.tga)
|
||||
Looking for {shot3 decal replacement...MISS (materials/decals/{shot3.tga)
|
||||
Looking for models/gman tex replacement...FAIL (materials/models/gman/GMan_Case1.tga)
|
||||
Looking for models/gman tex replacement...FAIL (materials/models/gman/inside_1.tga)
|
||||
```
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# Xash3D FWGS on `musl`
|
||||
|
||||
Xash3D FWGS works on `musl` out of the box. However, the engine doesn't try to differentiate glibc and musl anymore. If you see error similar to:
|
||||
|
||||
```
|
||||
Host_InitError: can't initialize cl_dlls/client.so: Error relocating valve/cl_dlls/client.so: __sprintf_chk: symbol not found
|
||||
```
|
||||
|
||||
... or you know that the game you're running is linked against glibc, you can try using `libgcompat`, like this:
|
||||
|
||||
```
|
||||
$ LD_PRELOAD=/lib/libgcompat.so.0 ./xash3d ...
|
||||
```
|
||||
|
||||
It will automatically add the missing symbols that glibc binaries usually need. In the future we might automatically link engine against `libgcompat` for better compatibility with prebuilt or closed-source games, if there will be any use for this.
|
|
@ -240,8 +240,6 @@ CSO-like Xash3D-based mod, CSMoE - https://github.com/MoeMod/CSMoE
|
|||
## Crack-Life: Campaign Mode
|
||||
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_life
|
||||
|
||||
Reverse-engineered code: branch **clcampaign** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/clcampaign
|
||||
|
||||
## Escape from the Darkness
|
||||
malortie's recreation - https://github.com/malortie/hl-eftd
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Xash3D FWGS Engine <img align="right" width="128" height="128" src="https://github.com/FWGS/xash3d-fwgs/raw/master/game_launch/icon-xash-material.png" alt="Xash3D FWGS icon" />
|
||||
[![builds.sr.ht status](https://builds.sr.ht/~a1batross/xash3d-fwgs.svg)](https://builds.sr.ht/~a1batross/xash3d-fwgs?) [![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
|
||||
[![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
|
||||
[![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
|
||||
|
||||
Xash3D FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
boneinfo.h - structure that send delta-compressed bones across network
|
||||
Copyright (C) 2018 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef BONEINFO_H
|
||||
#define BONEINFO_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t angles;
|
||||
vec3_t origin;
|
||||
} boneinfo_t;
|
||||
|
||||
#endif//BONEINFO_H
|
|
@ -534,14 +534,5 @@ typedef struct
|
|||
#define MAX_EFRAGS 8192 // Arcane Dimensions required
|
||||
#define MAX_REQUESTS 64
|
||||
|
||||
#if ! XASH_64BIT
|
||||
STATIC_ASSERT( sizeof( mextrasurf_t ) == 324, "mextrasurf_t unexpected size" );
|
||||
STATIC_ASSERT( sizeof( decal_t ) == 60, "decal_t unexpected size");
|
||||
STATIC_ASSERT( sizeof( mfaceinfo_t ) == 176, "mfaceinfo_t unexpected size");
|
||||
#else
|
||||
STATIC_ASSERT( sizeof( mextrasurf_t) == 496, "mextrasurf_t unexpected size");
|
||||
STATIC_ASSERT( sizeof( decal_t ) == 88, "decal_t unexpected size");
|
||||
STATIC_ASSERT( sizeof( mfaceinfo_t ) == 304, "mfaceinfo_t unexpected size");
|
||||
#endif
|
||||
|
||||
#endif//COM_MODEL_H
|
||||
|
|
|
@ -717,7 +717,6 @@ enum
|
|||
kRenderFxExplode, // Scale up really big!
|
||||
kRenderFxGlowShell, // Glowing Shell
|
||||
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
|
||||
kRenderFxLightMultiplier,
|
||||
};
|
||||
|
||||
typedef int func_t;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
enginefeatures.h - engine features that can be enabled by mod-maker request
|
||||
features.h - engine features that can be enabled by mod-maker request
|
||||
Copyright (C) 2012 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -27,20 +27,4 @@ GNU General Public License for more details.
|
|||
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
|
||||
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
|
||||
|
||||
#define ENGINE_DISABLE_HDTEXTURES (1U<<30) // disable support of HD-textures in case custom renderer have separate way to load them
|
||||
#define ENGINE_STEP_POSHISTORY_LERP (1U<<31) // enable MOVETYPE_STEP interpolation based on position history. Incompatible with ENGINE_COMPUTE_STUDIO_LERP!
|
||||
|
||||
// adjust the mask when features will be added or removed
|
||||
#define ENGINE_FEATURES_MASK \
|
||||
( ENGINE_WRITE_LARGE_COORD \
|
||||
| ENGINE_QUAKE_COMPATIBLE \
|
||||
| ENGINE_LOAD_DELUXEDATA \
|
||||
| ENGINE_PHYSICS_PUSHER_EXT \
|
||||
| ENGINE_LARGE_LIGHTMAPS \
|
||||
| ENGINE_COMPENSATE_QUAKE_BUG \
|
||||
| ENGINE_IMPROVED_LINETRACE \
|
||||
| ENGINE_COMPUTE_STUDIO_LERP \
|
||||
| ENGINE_LINEAR_GAMMA_SPACE \
|
||||
| ENGINE_STEP_POSHISTORY_LERP )
|
||||
|
||||
#endif//FEATURES_H
|
||||
|
|
|
@ -1,35 +1,18 @@
|
|||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
#ifndef KBUTTON_H
|
||||
#define KBUTTON_H
|
||||
|
||||
// a1ba: copied from WinQuake/client.h
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// cl_input
|
||||
// Purpose:
|
||||
//
|
||||
typedef struct
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( KBUTTONH )
|
||||
#define KBUTTONH
|
||||
#pragma once
|
||||
|
||||
typedef struct kbutton_s
|
||||
{
|
||||
int down[2]; // key nums holding it down
|
||||
int state; // low bit is down state
|
||||
} kbutton_t;
|
||||
|
||||
STATIC_ASSERT( sizeof( kbutton_t ) == 12, "kbutton_t isn't 12 bytes!" );
|
||||
|
||||
#endif // KBUTTON_H
|
||||
#endif // !KBUTTONH
|
||||
|
|
104
common/netadr.h
104
common/netadr.h
|
@ -1,74 +1,76 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NET_ADR_H
|
||||
#define NET_ADR_H
|
||||
#ifndef NETADR_H
|
||||
#define NETADR_H
|
||||
|
||||
#include "build.h"
|
||||
#include STDINT_H
|
||||
|
||||
// net.h -- quake's interface to the networking layer
|
||||
// a1ba: copied from Quake-2/qcommon/qcommon.h and modified to support IPv6
|
||||
|
||||
#define PORT_ANY -1
|
||||
|
||||
typedef enum {NA_LOOPBACK = 1, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX, NA_IP6, NA_MULTICAST_IP6} netadrtype_t;
|
||||
|
||||
/*
|
||||
Original Quake-2 structure:
|
||||
typedef struct
|
||||
typedef enum
|
||||
{
|
||||
netadrtype_t type;
|
||||
NA_UNUSED = 0,
|
||||
NA_LOOPBACK,
|
||||
NA_BROADCAST,
|
||||
NA_IP,
|
||||
NA_IPX,
|
||||
NA_BROADCAST_IPX,
|
||||
NA_IP6,
|
||||
NA_MULTICAST_IP6, // all nodes multicast
|
||||
} netadrtype_t;
|
||||
|
||||
byte ip[4];
|
||||
byte ipx[10];
|
||||
|
||||
unsigned short port;
|
||||
} netadr_t;
|
||||
*/
|
||||
// Original structure:
|
||||
// typedef struct netadr_s
|
||||
// {
|
||||
// netadrtype_t type;
|
||||
// unsigned char ip[4];
|
||||
// unsigned char ipx[10];
|
||||
// unsigned short port;
|
||||
// } netadr_t;
|
||||
|
||||
#pragma pack( push, 1 )
|
||||
typedef struct netadr_s
|
||||
{
|
||||
union
|
||||
{
|
||||
// IPv6 struct
|
||||
struct
|
||||
{
|
||||
uint16_t type6;
|
||||
uint8_t ip6[16];
|
||||
};
|
||||
struct
|
||||
{
|
||||
uint32_t type; // must be netadrtype_t but will break with short enums
|
||||
uint32_t type;
|
||||
union
|
||||
{
|
||||
uint8_t ip[4];
|
||||
uint32_t ip4; // for easier conversions
|
||||
uint8_t ip[4];
|
||||
uint32_t ip4;
|
||||
};
|
||||
uint8_t ipx[10];
|
||||
uint8_t ipx[10];
|
||||
};
|
||||
struct
|
||||
{
|
||||
#if XASH_LITTLE_ENDIAN
|
||||
uint16_t type6;
|
||||
uint8_t ip6[16];
|
||||
#elif XASH_BIG_ENDIAN
|
||||
uint8_t ip6_0[2];
|
||||
uint16_t type6;
|
||||
uint8_t ip6_2[14];
|
||||
#endif
|
||||
};
|
||||
};
|
||||
uint16_t port;
|
||||
uint16_t port;
|
||||
} netadr_t;
|
||||
#pragma pack( pop )
|
||||
|
||||
STATIC_ASSERT( sizeof( netadr_t ) == 20, "netadr_t isn't 20 bytes!" );
|
||||
STATIC_ASSERT( sizeof( netadr_t ) == 20, "invalid netadr_t size" );
|
||||
|
||||
#endif // NET_ADR_H
|
||||
#endif//NETADR_H
|
||||
|
|
|
@ -35,6 +35,7 @@ GNU General Public License for more details.
|
|||
#define __cdecl
|
||||
#define __stdcall
|
||||
#define _inline static inline
|
||||
#define FORCEINLINE inline __attribute__((always_inline))
|
||||
|
||||
#if XASH_POSIX
|
||||
#include <unistd.h>
|
||||
|
@ -62,6 +63,13 @@ GNU General Public License for more details.
|
|||
int x, y;
|
||||
} POINT;
|
||||
#else // WIN32
|
||||
#ifdef __MINGW32__
|
||||
#define _inline static inline
|
||||
#define FORCEINLINE inline __attribute__((always_inline))
|
||||
#else
|
||||
#define FORCEINLINE __forceinline
|
||||
#endif
|
||||
|
||||
#define open _open
|
||||
#define read _read
|
||||
#define alloca _alloca
|
||||
|
|
|
@ -107,8 +107,7 @@ typedef enum
|
|||
TF_ARB_FLOAT = (1<<26), // float textures
|
||||
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
|
||||
TF_ARB_16BIT = (1<<28), // keep image as 16-bit (not 24)
|
||||
TF_MULTISAMPLE = (1<<29), // multisampling texture
|
||||
TF_ALLOW_NEAREST = (1<<30), // allows toggling nearest filtering for TF_NOMIPMAP textures
|
||||
TF_MULTISAMPLE = (1<<29) // multisampling texture
|
||||
} texFlags_t;
|
||||
|
||||
typedef enum
|
||||
|
@ -230,7 +229,7 @@ typedef struct render_api_s
|
|||
void (*R_Reserved0)( void );
|
||||
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
|
||||
// engine utils (not related with render API but placed here)
|
||||
|
|
|
@ -28,7 +28,11 @@ typedef byte rgb_t[3]; // unsigned byte colorpack
|
|||
typedef vec_t matrix3x4[3][4];
|
||||
typedef vec_t matrix4x4[4][4];
|
||||
|
||||
#if XASH_64BIT
|
||||
typedef uint32_t poolhandle_t;
|
||||
#else
|
||||
typedef void* poolhandle_t;
|
||||
#endif
|
||||
|
||||
#undef true
|
||||
#undef false
|
||||
|
@ -54,6 +58,9 @@ typedef uint64_t longtime_t;
|
|||
|
||||
#define BIT( n ) ( 1U << ( n ))
|
||||
#define BIT64( n ) ( 1ULL << ( n ))
|
||||
#define GAMMA ( 2.2f ) // Valve Software gamma
|
||||
#define INVGAMMA ( 1.0f / 2.2f ) // back to 1.0
|
||||
#define TEXGAMMA ( 0.9f ) // compensate dim textures
|
||||
#define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
|
||||
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
|
||||
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))
|
||||
|
@ -70,72 +77,51 @@ typedef uint64_t longtime_t;
|
|||
#define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' )
|
||||
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )
|
||||
|
||||
#if defined( __GNUC__ )
|
||||
#if defined( __i386__ )
|
||||
#define EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer ))
|
||||
#define GAME_EXPORT __attribute(( force_align_arg_pointer ))
|
||||
#if defined(__GNUC__)
|
||||
#ifdef __i386__
|
||||
#define EXPORT __attribute__ ((visibility ("default"),force_align_arg_pointer))
|
||||
#define GAME_EXPORT __attribute((force_align_arg_pointer))
|
||||
#else
|
||||
#define EXPORT __attribute__(( visibility ( "default" )))
|
||||
#define EXPORT __attribute__ ((visibility ("default")))
|
||||
#define GAME_EXPORT
|
||||
#endif
|
||||
|
||||
#define NORETURN __attribute__(( noreturn ))
|
||||
#define NONNULL __attribute__(( nonnull ))
|
||||
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
|
||||
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
|
||||
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
|
||||
#define RENAME_SYMBOL( x ) asm( x )
|
||||
#else
|
||||
#if defined( _MSC_VER )
|
||||
#define EXPORT __declspec( dllexport )
|
||||
#define NO_ASAN __declspec( no_sanitize_address )
|
||||
#else
|
||||
#define EXPORT
|
||||
#define NO_ASAN
|
||||
#endif
|
||||
#define _format(x) __attribute__((format(printf, x, x+1)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NONNULL __attribute__((nonnull))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EXPORT __declspec( dllexport )
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#else
|
||||
#define EXPORT
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#define _format( x )
|
||||
#define ALLOC_CHECK( x )
|
||||
#define RENAME_SYMBOL( x )
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#define unlikely( x ) __builtin_expect( x, 0 )
|
||||
#define likely( x ) __builtin_expect( x, 1 )
|
||||
#if ( __GNUC__ >= 3 )
|
||||
#define unlikely(x) __builtin_expect(x, 0)
|
||||
#define likely(x) __builtin_expect(x, 1)
|
||||
#elif defined( __has_builtin )
|
||||
#if __has_builtin( __builtin_expect ) // this must be after defined() check
|
||||
#define unlikely( x ) __builtin_expect( x, 0 )
|
||||
#define likely( x ) __builtin_expect( x, 1 )
|
||||
#if __has_builtin( __builtin_expect )
|
||||
#define unlikely(x) __builtin_expect(x, 0)
|
||||
#define likely(x) __builtin_expect(x, 1)
|
||||
#else
|
||||
#define unlikely(x) (x)
|
||||
#define likely(x) (x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined( unlikely ) || !defined( likely )
|
||||
#define unlikely( x ) ( x )
|
||||
#define likely( x ) ( x )
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
|
||||
#define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y )
|
||||
#define STATIC_ASSERT static_assert
|
||||
#elif __STDC_VERSION__ >= 201112L // in C11 it's _Static_assert
|
||||
#define STATIC_ASSERT_( ignore, x, y ) _Static_assert( x, y )
|
||||
#define STATIC_ASSERT _Static_assert
|
||||
#else
|
||||
#define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1]
|
||||
// need these to correctly expand the line macro
|
||||
#define STATIC_ASSERT_3( line, x, y ) STATIC_ASSERT_( static_assert_ ## line, x, y )
|
||||
#define STATIC_ASSERT_2( line, x, y ) STATIC_ASSERT_3( line, x, y )
|
||||
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
|
||||
#define unlikely(x) (x)
|
||||
#define likely(x) (x)
|
||||
#endif
|
||||
|
||||
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
|
||||
#define XASH_RESTRICT restrict
|
||||
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
|
||||
#define XASH_RESTRICT __restrict
|
||||
#if defined( static_assert ) // C11 static_assert
|
||||
#define STATIC_ASSERT static_assert
|
||||
#else
|
||||
#define XASH_RESTRICT // nothing
|
||||
#define STATIC_ASSERT( x, y ) extern int _static_assert_##__LINE__[( x ) ? 1 : -1]
|
||||
#endif
|
||||
|
||||
#ifdef XASH_BIG_ENDIAN
|
||||
|
@ -168,9 +154,8 @@ _inline float LittleFloat( float f )
|
|||
#endif
|
||||
|
||||
|
||||
typedef unsigned int dword;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned int dword;
|
||||
typedef unsigned int uint;
|
||||
typedef char string[MAX_STRING];
|
||||
typedef struct file_s file_t; // normal file
|
||||
typedef struct stream_s stream_t; // sound stream for background music playing
|
||||
|
|
356
engine/anorms.h
356
engine/anorms.h
|
@ -1,181 +1,177 @@
|
|||
/*
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
{-0.525731, 0.000000, 0.850651},
|
||||
{-0.442863, 0.238856, 0.864188},
|
||||
{-0.295242, 0.000000, 0.955423},
|
||||
{-0.309017, 0.500000, 0.809017},
|
||||
{-0.162460, 0.262866, 0.951056},
|
||||
{0.000000, 0.000000, 1.000000},
|
||||
{0.000000, 0.850651, 0.525731},
|
||||
{-0.147621, 0.716567, 0.681718},
|
||||
{0.147621, 0.716567, 0.681718},
|
||||
{0.000000, 0.525731, 0.850651},
|
||||
{0.309017, 0.500000, 0.809017},
|
||||
{0.525731, 0.000000, 0.850651},
|
||||
{0.295242, 0.000000, 0.955423},
|
||||
{0.442863, 0.238856, 0.864188},
|
||||
{0.162460, 0.262866, 0.951056},
|
||||
{-0.681718, 0.147621, 0.716567},
|
||||
{-0.809017, 0.309017, 0.500000},
|
||||
{-0.587785, 0.425325, 0.688191},
|
||||
{-0.850651, 0.525731, 0.000000},
|
||||
{-0.864188, 0.442863, 0.238856},
|
||||
{-0.716567, 0.681718, 0.147621},
|
||||
{-0.688191, 0.587785, 0.425325},
|
||||
{-0.500000, 0.809017, 0.309017},
|
||||
{-0.238856, 0.864188, 0.442863},
|
||||
{-0.425325, 0.688191, 0.587785},
|
||||
{-0.716567, 0.681718, -0.147621},
|
||||
{-0.500000, 0.809017, -0.309017},
|
||||
{-0.525731, 0.850651, 0.000000},
|
||||
{0.000000, 0.850651, -0.525731},
|
||||
{-0.238856, 0.864188, -0.442863},
|
||||
{0.000000, 0.955423, -0.295242},
|
||||
{-0.262866, 0.951056, -0.162460},
|
||||
{0.000000, 1.000000, 0.000000},
|
||||
{0.000000, 0.955423, 0.295242},
|
||||
{-0.262866, 0.951056, 0.162460},
|
||||
{0.238856, 0.864188, 0.442863},
|
||||
{0.262866, 0.951056, 0.162460},
|
||||
{0.500000, 0.809017, 0.309017},
|
||||
{0.238856, 0.864188, -0.442863},
|
||||
{0.262866, 0.951056, -0.162460},
|
||||
{0.500000, 0.809017, -0.309017},
|
||||
{0.850651, 0.525731, 0.000000},
|
||||
{0.716567, 0.681718, 0.147621},
|
||||
{0.716567, 0.681718, -0.147621},
|
||||
{0.525731, 0.850651, 0.000000},
|
||||
{0.425325, 0.688191, 0.587785},
|
||||
{0.864188, 0.442863, 0.238856},
|
||||
{0.688191, 0.587785, 0.425325},
|
||||
{0.809017, 0.309017, 0.500000},
|
||||
{0.681718, 0.147621, 0.716567},
|
||||
{0.587785, 0.425325, 0.688191},
|
||||
{0.955423, 0.295242, 0.000000},
|
||||
{1.000000, 0.000000, 0.000000},
|
||||
{0.951056, 0.162460, 0.262866},
|
||||
{0.850651, -0.525731, 0.000000},
|
||||
{0.955423, -0.295242, 0.000000},
|
||||
{0.864188, -0.442863, 0.238856},
|
||||
{0.951056, -0.162460, 0.262866},
|
||||
{0.809017, -0.309017, 0.500000},
|
||||
{0.681718, -0.147621, 0.716567},
|
||||
{0.850651, 0.000000, 0.525731},
|
||||
{0.864188, 0.442863, -0.238856},
|
||||
{0.809017, 0.309017, -0.500000},
|
||||
{0.951056, 0.162460, -0.262866},
|
||||
{0.525731, 0.000000, -0.850651},
|
||||
{0.681718, 0.147621, -0.716567},
|
||||
{0.681718, -0.147621, -0.716567},
|
||||
{0.850651, 0.000000, -0.525731},
|
||||
{0.809017, -0.309017, -0.500000},
|
||||
{0.864188, -0.442863, -0.238856},
|
||||
{0.951056, -0.162460, -0.262866},
|
||||
{0.147621, 0.716567, -0.681718},
|
||||
{0.309017, 0.500000, -0.809017},
|
||||
{0.425325, 0.688191, -0.587785},
|
||||
{0.442863, 0.238856, -0.864188},
|
||||
{0.587785, 0.425325, -0.688191},
|
||||
{0.688191, 0.587785, -0.425325},
|
||||
{-0.147621, 0.716567, -0.681718},
|
||||
{-0.309017, 0.500000, -0.809017},
|
||||
{0.000000, 0.525731, -0.850651},
|
||||
{-0.525731, 0.000000, -0.850651},
|
||||
{-0.442863, 0.238856, -0.864188},
|
||||
{-0.295242, 0.000000, -0.955423},
|
||||
{-0.162460, 0.262866, -0.951056},
|
||||
{0.000000, 0.000000, -1.000000},
|
||||
{0.295242, 0.000000, -0.955423},
|
||||
{0.162460, 0.262866, -0.951056},
|
||||
{-0.442863, -0.238856, -0.864188},
|
||||
{-0.309017, -0.500000, -0.809017},
|
||||
{-0.162460, -0.262866, -0.951056},
|
||||
{0.000000, -0.850651, -0.525731},
|
||||
{-0.147621, -0.716567, -0.681718},
|
||||
{0.147621, -0.716567, -0.681718},
|
||||
{0.000000, -0.525731, -0.850651},
|
||||
{0.309017, -0.500000, -0.809017},
|
||||
{0.442863, -0.238856, -0.864188},
|
||||
{0.162460, -0.262866, -0.951056},
|
||||
{0.238856, -0.864188, -0.442863},
|
||||
{0.500000, -0.809017, -0.309017},
|
||||
{0.425325, -0.688191, -0.587785},
|
||||
{0.716567, -0.681718, -0.147621},
|
||||
{0.688191, -0.587785, -0.425325},
|
||||
{0.587785, -0.425325, -0.688191},
|
||||
{0.000000, -0.955423, -0.295242},
|
||||
{0.000000, -1.000000, 0.000000},
|
||||
{0.262866, -0.951056, -0.162460},
|
||||
{0.000000, -0.850651, 0.525731},
|
||||
{0.000000, -0.955423, 0.295242},
|
||||
{0.238856, -0.864188, 0.442863},
|
||||
{0.262866, -0.951056, 0.162460},
|
||||
{0.500000, -0.809017, 0.309017},
|
||||
{0.716567, -0.681718, 0.147621},
|
||||
{0.525731, -0.850651, 0.000000},
|
||||
{-0.238856, -0.864188, -0.442863},
|
||||
{-0.500000, -0.809017, -0.309017},
|
||||
{-0.262866, -0.951056, -0.162460},
|
||||
{-0.850651, -0.525731, 0.000000},
|
||||
{-0.716567, -0.681718, -0.147621},
|
||||
{-0.716567, -0.681718, 0.147621},
|
||||
{-0.525731, -0.850651, 0.000000},
|
||||
{-0.500000, -0.809017, 0.309017},
|
||||
{-0.238856, -0.864188, 0.442863},
|
||||
{-0.262866, -0.951056, 0.162460},
|
||||
{-0.864188, -0.442863, 0.238856},
|
||||
{-0.809017, -0.309017, 0.500000},
|
||||
{-0.688191, -0.587785, 0.425325},
|
||||
{-0.681718, -0.147621, 0.716567},
|
||||
{-0.442863, -0.238856, 0.864188},
|
||||
{-0.587785, -0.425325, 0.688191},
|
||||
{-0.309017, -0.500000, 0.809017},
|
||||
{-0.147621, -0.716567, 0.681718},
|
||||
{-0.425325, -0.688191, 0.587785},
|
||||
{-0.162460, -0.262866, 0.951056},
|
||||
{0.442863, -0.238856, 0.864188},
|
||||
{0.162460, -0.262866, 0.951056},
|
||||
{0.309017, -0.500000, 0.809017},
|
||||
{0.147621, -0.716567, 0.681718},
|
||||
{0.000000, -0.525731, 0.850651},
|
||||
{0.425325, -0.688191, 0.587785},
|
||||
{0.587785, -0.425325, 0.688191},
|
||||
{0.688191, -0.587785, 0.425325},
|
||||
{-0.955423, 0.295242, 0.000000},
|
||||
{-0.951056, 0.162460, 0.262866},
|
||||
{-1.000000, 0.000000, 0.000000},
|
||||
{-0.850651, 0.000000, 0.525731},
|
||||
{-0.955423, -0.295242, 0.000000},
|
||||
{-0.951056, -0.162460, 0.262866},
|
||||
{-0.864188, 0.442863, -0.238856},
|
||||
{-0.951056, 0.162460, -0.262866},
|
||||
{-0.809017, 0.309017, -0.500000},
|
||||
{-0.864188, -0.442863, -0.238856},
|
||||
{-0.951056, -0.162460, -0.262866},
|
||||
{-0.809017, -0.309017, -0.500000},
|
||||
{-0.681718, 0.147621, -0.716567},
|
||||
{-0.681718, -0.147621, -0.716567},
|
||||
{-0.850651, 0.000000, -0.525731},
|
||||
{-0.688191, 0.587785, -0.425325},
|
||||
{-0.587785, 0.425325, -0.688191},
|
||||
{-0.425325, 0.688191, -0.587785},
|
||||
{-0.425325, -0.688191, -0.587785},
|
||||
{-0.587785, -0.425325, -0.688191},
|
||||
{-0.688191, -0.587785, -0.425325},
|
||||
{-0.525731, 0.000000, 0.850651},
|
||||
{-0.442863, 0.238856, 0.864188},
|
||||
{-0.295242, 0.000000, 0.955423},
|
||||
{-0.309017, 0.500000, 0.809017},
|
||||
{-0.162460, 0.262866, 0.951056},
|
||||
{0.000000, 0.000000, 1.000000},
|
||||
{0.000000, 0.850651, 0.525731},
|
||||
{-0.147621, 0.716567, 0.681718},
|
||||
{0.147621, 0.716567, 0.681718},
|
||||
{0.000000, 0.525731, 0.850651},
|
||||
{0.309017, 0.500000, 0.809017},
|
||||
{0.525731, 0.000000, 0.850651},
|
||||
{0.295242, 0.000000, 0.955423},
|
||||
{0.442863, 0.238856, 0.864188},
|
||||
{0.162460, 0.262866, 0.951056},
|
||||
{-0.681718, 0.147621, 0.716567},
|
||||
{-0.809017, 0.309017, 0.500000},
|
||||
{-0.587785, 0.425325, 0.688191},
|
||||
{-0.850651, 0.525731, 0.000000},
|
||||
{-0.864188, 0.442863, 0.238856},
|
||||
{-0.716567, 0.681718, 0.147621},
|
||||
{-0.688191, 0.587785, 0.425325},
|
||||
{-0.500000, 0.809017, 0.309017},
|
||||
{-0.238856, 0.864188, 0.442863},
|
||||
{-0.425325, 0.688191, 0.587785},
|
||||
{-0.716567, 0.681718, -0.147621},
|
||||
{-0.500000, 0.809017, -0.309017},
|
||||
{-0.525731, 0.850651, 0.000000},
|
||||
{0.000000, 0.850651, -0.525731},
|
||||
{-0.238856, 0.864188, -0.442863},
|
||||
{0.000000, 0.955423, -0.295242},
|
||||
{-0.262866, 0.951056, -0.162460},
|
||||
{0.000000, 1.000000, 0.000000},
|
||||
{0.000000, 0.955423, 0.295242},
|
||||
{-0.262866, 0.951056, 0.162460},
|
||||
{0.238856, 0.864188, 0.442863},
|
||||
{0.262866, 0.951056, 0.162460},
|
||||
{0.500000, 0.809017, 0.309017},
|
||||
{0.238856, 0.864188, -0.442863},
|
||||
{0.262866, 0.951056, -0.162460},
|
||||
{0.500000, 0.809017, -0.309017},
|
||||
{0.850651, 0.525731, 0.000000},
|
||||
{0.716567, 0.681718, 0.147621},
|
||||
{0.716567, 0.681718, -0.147621},
|
||||
{0.525731, 0.850651, 0.000000},
|
||||
{0.425325, 0.688191, 0.587785},
|
||||
{0.864188, 0.442863, 0.238856},
|
||||
{0.688191, 0.587785, 0.425325},
|
||||
{0.809017, 0.309017, 0.500000},
|
||||
{0.681718, 0.147621, 0.716567},
|
||||
{0.587785, 0.425325, 0.688191},
|
||||
{0.955423, 0.295242, 0.000000},
|
||||
{1.000000, 0.000000, 0.000000},
|
||||
{0.951056, 0.162460, 0.262866},
|
||||
{0.850651, -0.525731, 0.000000},
|
||||
{0.955423, -0.295242, 0.000000},
|
||||
{0.864188, -0.442863, 0.238856},
|
||||
{0.951056, -0.162460, 0.262866},
|
||||
{0.809017, -0.309017, 0.500000},
|
||||
{0.681718, -0.147621, 0.716567},
|
||||
{0.850651, 0.000000, 0.525731},
|
||||
{0.864188, 0.442863, -0.238856},
|
||||
{0.809017, 0.309017, -0.500000},
|
||||
{0.951056, 0.162460, -0.262866},
|
||||
{0.525731, 0.000000, -0.850651},
|
||||
{0.681718, 0.147621, -0.716567},
|
||||
{0.681718, -0.147621, -0.716567},
|
||||
{0.850651, 0.000000, -0.525731},
|
||||
{0.809017, -0.309017, -0.500000},
|
||||
{0.864188, -0.442863, -0.238856},
|
||||
{0.951056, -0.162460, -0.262866},
|
||||
{0.147621, 0.716567, -0.681718},
|
||||
{0.309017, 0.500000, -0.809017},
|
||||
{0.425325, 0.688191, -0.587785},
|
||||
{0.442863, 0.238856, -0.864188},
|
||||
{0.587785, 0.425325, -0.688191},
|
||||
{0.688191, 0.587785, -0.425325},
|
||||
{-0.147621, 0.716567, -0.681718},
|
||||
{-0.309017, 0.500000, -0.809017},
|
||||
{0.000000, 0.525731, -0.850651},
|
||||
{-0.525731, 0.000000, -0.850651},
|
||||
{-0.442863, 0.238856, -0.864188},
|
||||
{-0.295242, 0.000000, -0.955423},
|
||||
{-0.162460, 0.262866, -0.951056},
|
||||
{0.000000, 0.000000, -1.000000},
|
||||
{0.295242, 0.000000, -0.955423},
|
||||
{0.162460, 0.262866, -0.951056},
|
||||
{-0.442863, -0.238856, -0.864188},
|
||||
{-0.309017, -0.500000, -0.809017},
|
||||
{-0.162460, -0.262866, -0.951056},
|
||||
{0.000000, -0.850651, -0.525731},
|
||||
{-0.147621, -0.716567, -0.681718},
|
||||
{0.147621, -0.716567, -0.681718},
|
||||
{0.000000, -0.525731, -0.850651},
|
||||
{0.309017, -0.500000, -0.809017},
|
||||
{0.442863, -0.238856, -0.864188},
|
||||
{0.162460, -0.262866, -0.951056},
|
||||
{0.238856, -0.864188, -0.442863},
|
||||
{0.500000, -0.809017, -0.309017},
|
||||
{0.425325, -0.688191, -0.587785},
|
||||
{0.716567, -0.681718, -0.147621},
|
||||
{0.688191, -0.587785, -0.425325},
|
||||
{0.587785, -0.425325, -0.688191},
|
||||
{0.000000, -0.955423, -0.295242},
|
||||
{0.000000, -1.000000, 0.000000},
|
||||
{0.262866, -0.951056, -0.162460},
|
||||
{0.000000, -0.850651, 0.525731},
|
||||
{0.000000, -0.955423, 0.295242},
|
||||
{0.238856, -0.864188, 0.442863},
|
||||
{0.262866, -0.951056, 0.162460},
|
||||
{0.500000, -0.809017, 0.309017},
|
||||
{0.716567, -0.681718, 0.147621},
|
||||
{0.525731, -0.850651, 0.000000},
|
||||
{-0.238856, -0.864188, -0.442863},
|
||||
{-0.500000, -0.809017, -0.309017},
|
||||
{-0.262866, -0.951056, -0.162460},
|
||||
{-0.850651, -0.525731, 0.000000},
|
||||
{-0.716567, -0.681718, -0.147621},
|
||||
{-0.716567, -0.681718, 0.147621},
|
||||
{-0.525731, -0.850651, 0.000000},
|
||||
{-0.500000, -0.809017, 0.309017},
|
||||
{-0.238856, -0.864188, 0.442863},
|
||||
{-0.262866, -0.951056, 0.162460},
|
||||
{-0.864188, -0.442863, 0.238856},
|
||||
{-0.809017, -0.309017, 0.500000},
|
||||
{-0.688191, -0.587785, 0.425325},
|
||||
{-0.681718, -0.147621, 0.716567},
|
||||
{-0.442863, -0.238856, 0.864188},
|
||||
{-0.587785, -0.425325, 0.688191},
|
||||
{-0.309017, -0.500000, 0.809017},
|
||||
{-0.147621, -0.716567, 0.681718},
|
||||
{-0.425325, -0.688191, 0.587785},
|
||||
{-0.162460, -0.262866, 0.951056},
|
||||
{0.442863, -0.238856, 0.864188},
|
||||
{0.162460, -0.262866, 0.951056},
|
||||
{0.309017, -0.500000, 0.809017},
|
||||
{0.147621, -0.716567, 0.681718},
|
||||
{0.000000, -0.525731, 0.850651},
|
||||
{0.425325, -0.688191, 0.587785},
|
||||
{0.587785, -0.425325, 0.688191},
|
||||
{0.688191, -0.587785, 0.425325},
|
||||
{-0.955423, 0.295242, 0.000000},
|
||||
{-0.951056, 0.162460, 0.262866},
|
||||
{-1.000000, 0.000000, 0.000000},
|
||||
{-0.850651, 0.000000, 0.525731},
|
||||
{-0.955423, -0.295242, 0.000000},
|
||||
{-0.951056, -0.162460, 0.262866},
|
||||
{-0.864188, 0.442863, -0.238856},
|
||||
{-0.951056, 0.162460, -0.262866},
|
||||
{-0.809017, 0.309017, -0.500000},
|
||||
{-0.864188, -0.442863, -0.238856},
|
||||
{-0.951056, -0.162460, -0.262866},
|
||||
{-0.809017, -0.309017, -0.500000},
|
||||
{-0.681718, 0.147621, -0.716567},
|
||||
{-0.681718, -0.147621, -0.716567},
|
||||
{-0.850651, 0.000000, -0.525731},
|
||||
{-0.688191, 0.587785, -0.425325},
|
||||
{-0.587785, 0.425325, -0.688191},
|
||||
{-0.425325, 0.688191, -0.587785},
|
||||
{-0.425325, -0.688191, -0.587785},
|
||||
{-0.587785, -0.425325, -0.688191},
|
||||
{-0.688191, -0.587785, -0.425325},
|
||||
|
|
|
@ -157,12 +157,32 @@ void CL_PlayCDTrack_f( void )
|
|||
CL_ScreenshotGetName
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_ScreenshotGetName( const char *fmt, int lastnum, char *filename, size_t size )
|
||||
static qboolean CL_ScreenshotGetName( int lastnum, char *filename, size_t size )
|
||||
{
|
||||
if( lastnum < 0 || lastnum > 9999 )
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to write screenshot\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return Q_snprintf( filename, size, fmt, clgame.mapname, lastnum ) > 0;
|
||||
return Q_snprintf( filename, size, "scrshots/%s_shot%04d.png", clgame.mapname, lastnum ) > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SnapshotGetName
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_SnapshotGetName( int lastnum, char *filename, size_t size )
|
||||
{
|
||||
if( lastnum < 0 || lastnum > 9999 )
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to write snapshot\n" );
|
||||
FS_AllowDirectPaths( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
return Q_snprintf( filename, size, "../%s_%04d.png", clgame.mapname, lastnum ) > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -172,6 +192,127 @@ static qboolean CL_ScreenshotGetName( const char *fmt, int lastnum, char *filena
|
|||
|
||||
==============================================================================
|
||||
*/
|
||||
/*
|
||||
==================
|
||||
CL_ScreenShot_f
|
||||
|
||||
normal screenshot
|
||||
==================
|
||||
*/
|
||||
void CL_ScreenShot_f( void )
|
||||
{
|
||||
int i;
|
||||
string checkname;
|
||||
|
||||
if( CL_IsDevOverviewMode() == 1 )
|
||||
{
|
||||
// special case for write overview image and script file
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
|
||||
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
|
||||
}
|
||||
else
|
||||
{
|
||||
// scan for a free filename
|
||||
for( i = 0; i < 9999; i++ )
|
||||
{
|
||||
if( !CL_ScreenshotGetName( i, checkname, sizeof( checkname )))
|
||||
return; // no namespace
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
|
||||
cls.scrshot_action = scrshot_normal; // build new frame for screenshot
|
||||
}
|
||||
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SnapShot_f
|
||||
|
||||
save screenshots into root dir
|
||||
==================
|
||||
*/
|
||||
void CL_SnapShot_f( void )
|
||||
{
|
||||
int i;
|
||||
string checkname;
|
||||
|
||||
if( CL_IsDevOverviewMode() == 1 )
|
||||
{
|
||||
// special case for write overview image and script file
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
|
||||
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
|
||||
}
|
||||
else
|
||||
{
|
||||
FS_AllowDirectPaths( true );
|
||||
|
||||
// scan for a free filename
|
||||
for( i = 0; i < 9999; i++ )
|
||||
{
|
||||
if( !CL_SnapshotGetName( i, checkname, sizeof( checkname )))
|
||||
return; // no namespace
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
FS_AllowDirectPaths( false );
|
||||
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
|
||||
cls.scrshot_action = scrshot_snapshot; // build new frame for screenshot
|
||||
}
|
||||
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_EnvShot_f
|
||||
|
||||
cubemap view
|
||||
==================
|
||||
*/
|
||||
void CL_EnvShot_f( void )
|
||||
{
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "envshot <shotname>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
|
||||
cls.scrshot_action = scrshot_envshot; // build new frame for envshot
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_SkyShot_f
|
||||
|
||||
skybox view
|
||||
==================
|
||||
*/
|
||||
void CL_SkyShot_f( void )
|
||||
{
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "skyshot <shotname>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ),"gfx/env/%s", Cmd_Argv( 1 ));
|
||||
cls.scrshot_action = scrshot_skyshot; // build new frame for skyshot
|
||||
cls.envshot_vieworg = NULL; // no custom view
|
||||
cls.envshot_viewsize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_LevelShot_f
|
||||
|
@ -214,100 +355,23 @@ void CL_LevelShot_f( void )
|
|||
else cls.scrshot_action = scrshot_inactive; // disable - not needs
|
||||
}
|
||||
|
||||
static scrshot_t CL_GetScreenshotTypeFromString( const char *string )
|
||||
/*
|
||||
==================
|
||||
CL_SaveShot_f
|
||||
|
||||
mini-pic in loadgame menu
|
||||
==================
|
||||
*/
|
||||
void CL_SaveShot_f( void )
|
||||
{
|
||||
if( !Q_stricmp( string, "snapshot" ))
|
||||
return scrshot_snapshot;
|
||||
|
||||
if( !Q_stricmp( string, "screenshot" ))
|
||||
return scrshot_normal;
|
||||
|
||||
if( !Q_stricmp( string, "saveshot" ))
|
||||
return scrshot_savegame;
|
||||
|
||||
if( !Q_stricmp( string, "envshot" ))
|
||||
return scrshot_envshot;
|
||||
|
||||
if( !Q_stricmp( string, "skyshot" ))
|
||||
return scrshot_skyshot;
|
||||
|
||||
return scrshot_inactive;
|
||||
}
|
||||
|
||||
void CL_GenericShot_f( void )
|
||||
{
|
||||
const char *argv0 = Cmd_Argv( 0 );
|
||||
scrshot_t type;
|
||||
|
||||
type = CL_GetScreenshotTypeFromString( argv0 );
|
||||
|
||||
if( type == scrshot_normal || type == scrshot_snapshot )
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
if( CL_IsDevOverviewMode() == 1 )
|
||||
type = scrshot_mapshot;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "%s <shotname>\n", argv0 );
|
||||
return;
|
||||
}
|
||||
Con_Printf( S_USAGE "saveshot <savename>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case scrshot_envshot:
|
||||
case scrshot_skyshot:
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
|
||||
break;
|
||||
case scrshot_savegame:
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
|
||||
break;
|
||||
case scrshot_mapshot:
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
|
||||
break;
|
||||
case scrshot_normal:
|
||||
case scrshot_snapshot:
|
||||
{
|
||||
const char *fmt;
|
||||
string checkname;
|
||||
int i;
|
||||
|
||||
if( type == scrshot_snapshot )
|
||||
{
|
||||
fmt = "../%s_%04d.png";
|
||||
FS_AllowDirectPaths( true );
|
||||
}
|
||||
else fmt = "scrshots/%s_shot%04d.png";
|
||||
|
||||
for( i = 0; i < 9999; i++ )
|
||||
{
|
||||
if( !CL_ScreenshotGetName( fmt, i, checkname, sizeof( checkname )))
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to write %s\n", argv0 );
|
||||
FS_AllowDirectPaths( false );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
FS_AllowDirectPaths( false );
|
||||
|
||||
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
|
||||
break;
|
||||
}
|
||||
case scrshot_inactive:
|
||||
case scrshot_plaque:
|
||||
default:
|
||||
return; // shouldn't happen
|
||||
}
|
||||
|
||||
cls.scrshot_action = type; // build new frame for saveshot
|
||||
cls.envshot_vieworg = NULL;
|
||||
cls.envshot_viewsize = 0;
|
||||
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
|
||||
cls.scrshot_action = scrshot_savegame; // build new frame for saveshot
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -349,7 +413,7 @@ void CL_SetSky_f( void )
|
|||
return;
|
||||
}
|
||||
|
||||
R_SetupSky( Cmd_Argv( 1 ));
|
||||
ref.dllFuncs.R_SetupSky( Cmd_Argv( 1 ));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -70,17 +70,16 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
|
|||
return true;
|
||||
}
|
||||
|
||||
host.downloadcount++;
|
||||
|
||||
if( cl.http_download )
|
||||
if( cl.downloadUrl[0] )
|
||||
{
|
||||
HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
|
||||
host.downloadcount++;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG_BeginClientCmd( msg, clc_stringcmd );
|
||||
MSG_WriteStringf( msg, "dlfile %s", filepath );
|
||||
}
|
||||
|
||||
MSG_BeginClientCmd( msg, clc_stringcmd );
|
||||
MSG_WriteStringf( msg, "dlfile %s", filepath );
|
||||
host.downloadcount++;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -105,7 +104,7 @@ void CL_AddToResourceList( resource_t *pResource, resource_t *pList )
|
|||
void CL_RemoveFromResourceList( resource_t *pResource )
|
||||
{
|
||||
if( pResource->pPrev == NULL || pResource->pNext == NULL )
|
||||
Host_Error( "mislinked resource in %s\n", __func__ );
|
||||
Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" );
|
||||
|
||||
if( pResource->pNext == pResource || pResource->pPrev == pResource )
|
||||
Host_Error( "attempt to free last entry in list.\n" );
|
||||
|
@ -120,7 +119,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
|
|||
{
|
||||
if( !pResource )
|
||||
{
|
||||
Con_Reportf( "Null resource passed to %s\n", __func__ );
|
||||
Con_Reportf( "Null resource passed to CL_MoveToOnHandList\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -128,7 +127,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
|
|||
CL_AddToResourceList( pResource, &cl.resourcesonhand );
|
||||
}
|
||||
|
||||
static void CL_ClearResourceList( resource_t *pList )
|
||||
void CL_ClearResourceList( resource_t *pList )
|
||||
{
|
||||
resource_t *p, *n;
|
||||
|
||||
|
|
|
@ -50,29 +50,7 @@ const char *CL_MsgInfo( int cmd )
|
|||
if( cmd >= 0 && cmd <= svc_lastmsg )
|
||||
{
|
||||
// get engine message name
|
||||
const char *svc_string = NULL;
|
||||
|
||||
switch( cls.legacymode )
|
||||
{
|
||||
case PROTO_CURRENT:
|
||||
svc_string = svc_strings[cmd];
|
||||
break;
|
||||
case PROTO_LEGACY:
|
||||
svc_string = svc_legacy_strings[cmd];
|
||||
break;
|
||||
case PROTO_QUAKE:
|
||||
svc_string = svc_quake_strings[cmd];
|
||||
break;
|
||||
case PROTO_GOLDSRC:
|
||||
svc_string = svc_goldsrc_strings[cmd];
|
||||
break;
|
||||
}
|
||||
|
||||
// fall back to current protocol strings
|
||||
if( !svc_string )
|
||||
svc_string = svc_strings[cmd];
|
||||
|
||||
Q_strncpy( sz, svc_string, sizeof( sz ));
|
||||
Q_strncpy( sz, svc_strings[cmd], sizeof( sz ));
|
||||
}
|
||||
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
|
||||
{
|
||||
|
|
|
@ -107,42 +107,6 @@ struct
|
|||
int angle_position;
|
||||
} demo;
|
||||
|
||||
static qboolean CL_NextDemo( void );
|
||||
|
||||
static int CL_GetDemoNetProtocol( connprotocol_t proto )
|
||||
{
|
||||
switch( proto )
|
||||
{
|
||||
case PROTO_CURRENT:
|
||||
return PROTOCOL_VERSION;
|
||||
case PROTO_LEGACY:
|
||||
return PROTOCOL_LEGACY_VERSION;
|
||||
case PROTO_QUAKE:
|
||||
return PROTOCOL_VERSION_QUAKE;
|
||||
case PROTO_GOLDSRC:
|
||||
return PROTOCOL_GOLDSRC_VERSION;
|
||||
}
|
||||
|
||||
return PROTOCOL_VERSION;
|
||||
}
|
||||
|
||||
static connprotocol_t CL_GetProtocolFromDemo( int net_protocol )
|
||||
{
|
||||
switch( net_protocol )
|
||||
{
|
||||
case PROTOCOL_VERSION:
|
||||
return PROTO_CURRENT;
|
||||
case PROTOCOL_LEGACY_VERSION:
|
||||
return PROTO_LEGACY;
|
||||
case PROTOCOL_VERSION_QUAKE:
|
||||
return PROTO_QUAKE;
|
||||
case PROTOCOL_GOLDSRC_VERSION:
|
||||
return PROTO_GOLDSRC;
|
||||
}
|
||||
|
||||
return PROTO_CURRENT;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_StartupDemoHeader
|
||||
|
@ -192,7 +156,7 @@ CL_GetDemoRecordClock
|
|||
write time while demo is recording
|
||||
====================
|
||||
*/
|
||||
static float CL_GetDemoRecordClock( void )
|
||||
float CL_GetDemoRecordClock( void )
|
||||
{
|
||||
return cl.mtime[0];
|
||||
}
|
||||
|
@ -204,7 +168,7 @@ CL_GetDemoPlaybackClock
|
|||
overwrite host.realtime
|
||||
====================
|
||||
*/
|
||||
static float CL_GetDemoPlaybackClock( void )
|
||||
float CL_GetDemoPlaybackClock( void )
|
||||
{
|
||||
return host.realtime + host.frametime;
|
||||
}
|
||||
|
@ -230,7 +194,7 @@ CL_WriteDemoCmdHeader
|
|||
Writes the demo command header and time-delta
|
||||
====================
|
||||
*/
|
||||
static void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
|
||||
void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
|
||||
{
|
||||
float dt;
|
||||
|
||||
|
@ -303,7 +267,7 @@ Save state of cls.netchan sequences
|
|||
so that we can play the demo correctly.
|
||||
====================
|
||||
*/
|
||||
static void CL_WriteDemoSequence( file_t *file )
|
||||
void CL_WriteDemoSequence( file_t *file )
|
||||
{
|
||||
Assert( file != NULL );
|
||||
|
||||
|
@ -384,7 +348,7 @@ CL_WriteDemoHeader
|
|||
Write demo header
|
||||
====================
|
||||
*/
|
||||
static void CL_WriteDemoHeader( const char *name )
|
||||
void CL_WriteDemoHeader( const char *name )
|
||||
{
|
||||
int copysize;
|
||||
int savepos;
|
||||
|
@ -407,8 +371,8 @@ static void CL_WriteDemoHeader( const char *name )
|
|||
|
||||
demo.header.id = IDEMOHEADER;
|
||||
demo.header.dem_protocol = DEMO_PROTOCOL;
|
||||
demo.header.net_protocol = CL_GetDemoNetProtocol( cls.legacymode );
|
||||
demo.header.host_fps = host_maxfps.value ? bound( MIN_FPS, host_maxfps.value, MAX_FPS ) : MAX_FPS;
|
||||
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
|
||||
demo.header.host_fps = bound( MIN_FPS, host_maxfps.value, MAX_FPS );
|
||||
Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname ));
|
||||
Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment ));
|
||||
Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir ));
|
||||
|
@ -472,7 +436,7 @@ CL_StopRecord
|
|||
finish recording demo
|
||||
=================
|
||||
*/
|
||||
static void CL_StopRecord( void )
|
||||
void CL_StopRecord( void )
|
||||
{
|
||||
int i, curpos;
|
||||
float stoptime;
|
||||
|
@ -554,7 +518,7 @@ CL_ReadDemoCmdHeader
|
|||
read the demo command
|
||||
=================
|
||||
*/
|
||||
static qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt )
|
||||
qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt )
|
||||
{
|
||||
// read the command
|
||||
// HACKHACK: skip NOPs
|
||||
|
@ -584,7 +548,7 @@ read the demo usercmd for predicting
|
|||
and smooth movement during playback the demo
|
||||
=================
|
||||
*/
|
||||
static void CL_ReadDemoUserCmd( qboolean discard )
|
||||
void CL_ReadDemoUserCmd( qboolean discard )
|
||||
{
|
||||
byte data[1024];
|
||||
int cmdnumber;
|
||||
|
@ -606,9 +570,6 @@ static void CL_ReadDemoUserCmd( qboolean discard )
|
|||
memset( &nullcmd, 0, sizeof( nullcmd ));
|
||||
MSG_Init( &buf, "UserCmd", data, sizeof( data ));
|
||||
|
||||
// a1ba: I have no proper explanation why
|
||||
cmdnumber++;
|
||||
|
||||
pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK];
|
||||
pcmd->processedfuncs = false;
|
||||
pcmd->senttime = 0.0f;
|
||||
|
@ -649,7 +610,7 @@ CL_ReadDemoSequence
|
|||
read netchan sequences
|
||||
=================
|
||||
*/
|
||||
static void CL_ReadDemoSequence( qboolean discard )
|
||||
void CL_ReadDemoSequence( qboolean discard )
|
||||
{
|
||||
int incoming_sequence;
|
||||
int incoming_acknowledged;
|
||||
|
@ -683,7 +644,7 @@ static void CL_ReadDemoSequence( qboolean discard )
|
|||
CL_DemoStartPlayback
|
||||
=================
|
||||
*/
|
||||
static void CL_DemoStartPlayback( int mode )
|
||||
void CL_DemoStartPlayback( int mode )
|
||||
{
|
||||
if( cls.changedemo )
|
||||
{
|
||||
|
@ -728,7 +689,7 @@ static void CL_DemoStartPlayback( int mode )
|
|||
CL_DemoAborted
|
||||
=================
|
||||
*/
|
||||
static void CL_DemoAborted( void )
|
||||
void CL_DemoAborted( void )
|
||||
{
|
||||
if( cls.demofile )
|
||||
FS_Close( cls.demofile );
|
||||
|
@ -768,7 +729,7 @@ returns true on success, false on failure
|
|||
g-cont. probably captain obvious mode is ON
|
||||
=================
|
||||
*/
|
||||
static qboolean CL_DemoMoveToNextSection( void )
|
||||
qboolean CL_DemoMoveToNextSection( void )
|
||||
{
|
||||
if( ++demo.entryIndex >= demo.directory.numentries )
|
||||
{
|
||||
|
@ -790,7 +751,7 @@ static qboolean CL_DemoMoveToNextSection( void )
|
|||
return true;
|
||||
}
|
||||
|
||||
static qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
|
||||
qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
|
||||
{
|
||||
int msglen = 0;
|
||||
|
||||
|
@ -841,7 +802,7 @@ CL_DemoReadMessageQuake
|
|||
reads demo data and write it to client
|
||||
=================
|
||||
*/
|
||||
static qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
|
||||
qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
|
||||
{
|
||||
vec3_t viewangles;
|
||||
int msglen = 0;
|
||||
|
@ -1056,7 +1017,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
|
|||
return CL_ReadRawNetworkData( buffer, length );
|
||||
}
|
||||
|
||||
static void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next )
|
||||
void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next )
|
||||
{
|
||||
int i, i0, i1, imod;
|
||||
float at;
|
||||
|
@ -1151,7 +1112,7 @@ CL_FinishTimeDemo
|
|||
show stats
|
||||
==============
|
||||
*/
|
||||
static void CL_FinishTimeDemo( void )
|
||||
void CL_FinishTimeDemo( void )
|
||||
{
|
||||
int frames;
|
||||
double time;
|
||||
|
@ -1300,7 +1261,7 @@ CL_NextDemo
|
|||
Called when a demo finishes
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_NextDemo( void )
|
||||
qboolean CL_NextDemo( void )
|
||||
{
|
||||
char str[MAX_QPATH];
|
||||
|
||||
|
@ -1523,7 +1484,6 @@ void CL_PlayDemo_f( void )
|
|||
}
|
||||
|
||||
if( neg ) cls.forcetrack = -cls.forcetrack;
|
||||
cls.legacymode = PROTO_QUAKE;
|
||||
CL_DemoStartPlayback( DEMO_QUAKE1 );
|
||||
return; // quake demo is started
|
||||
}
|
||||
|
@ -1579,11 +1539,9 @@ void CL_PlayDemo_f( void )
|
|||
|
||||
CL_DemoStartPlayback( DEMO_XASH3D );
|
||||
|
||||
// must be after DemoStartPlayback, as CL_Disconnect_f resets the protocol
|
||||
cls.legacymode = CL_GetProtocolFromDemo( demo.header.net_protocol );
|
||||
|
||||
// g-cont. is this need?
|
||||
Q_strncpy( cls.servername, demoname, sizeof( cls.servername ));
|
||||
cls.legacymode = demo.header.net_protocol == PROTOCOL_LEGACY_VERSION;
|
||||
|
||||
// begin a playback demo
|
||||
}
|
||||
|
@ -1625,7 +1583,7 @@ void CL_StartDemos_f( void )
|
|||
c = Cmd_Argc() - 1;
|
||||
if( c > MAX_DEMOS )
|
||||
{
|
||||
Con_DPrintf( S_WARN "%s: max %i demos in demoloop\n", __func__, MAX_DEMOS );
|
||||
Con_DPrintf( S_WARN "Host_StartDemos: max %i demos in demoloop\n", MAX_DEMOS );
|
||||
c = MAX_DEMOS;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float )
|
|||
return NULL;
|
||||
|
||||
// never alloc particles when we not in game
|
||||
if( cl_clientframetime() == 0.0 ) return NULL;
|
||||
// if( tr.frametime == 0.0 ) return NULL;
|
||||
|
||||
if( !cl_free_particles )
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ R_AllocTracer
|
|||
can return NULL if particles is out
|
||||
================
|
||||
*/
|
||||
static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
|
||||
particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
|
||||
{
|
||||
particle_t *p;
|
||||
|
||||
|
@ -226,7 +226,7 @@ static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life
|
|||
return NULL;
|
||||
|
||||
// never alloc particles when we not in game
|
||||
if( cl_clientframetime() == 0.0 ) return NULL;
|
||||
//if( tr.frametime == 0.0 ) return NULL;
|
||||
|
||||
if( !cl_free_particles )
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ R_BeamAlloc
|
|||
|
||||
==============
|
||||
*/
|
||||
static BEAM *R_BeamAlloc( void )
|
||||
BEAM *R_BeamAlloc( void )
|
||||
{
|
||||
BEAM *pBeam;
|
||||
|
||||
|
@ -323,7 +323,7 @@ R_BeamFree
|
|||
|
||||
==============
|
||||
*/
|
||||
static void R_BeamFree( BEAM *pBeam )
|
||||
void R_BeamFree( BEAM *pBeam )
|
||||
{
|
||||
// free particles that have died off.
|
||||
R_FreeDeadParticles( &pBeam->particles );
|
||||
|
@ -605,7 +605,7 @@ CL_BeamAttemptToDie
|
|||
Check for expired beams
|
||||
==============
|
||||
*/
|
||||
static qboolean CL_BeamAttemptToDie( BEAM *pBeam )
|
||||
qboolean CL_BeamAttemptToDie( BEAM *pBeam )
|
||||
{
|
||||
Assert( pBeam != NULL );
|
||||
|
||||
|
@ -2040,7 +2040,7 @@ void CL_ReadPointFile_f( void )
|
|||
else Con_Printf( "map %s has no leaks!\n", clgame.mapname );
|
||||
}
|
||||
|
||||
static void CL_FreeDeadBeams( void )
|
||||
void CL_FreeDeadBeams( void )
|
||||
{
|
||||
BEAM *pBeam, *pNext, *pPrev = NULL;
|
||||
// draw temporary entity beams
|
||||
|
|
|
@ -40,7 +40,7 @@ CL_CalcPlayerVelocity
|
|||
compute velocity for a given client
|
||||
=============
|
||||
*/
|
||||
static void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
|
||||
void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
|
||||
{
|
||||
clientdata_t *pcd;
|
||||
vec3_t delta;
|
||||
|
@ -78,7 +78,7 @@ CL_DescribeEvent
|
|||
|
||||
=============
|
||||
*/
|
||||
static void CL_DescribeEvent( event_info_t *ei, int slot )
|
||||
void CL_DescribeEvent( event_info_t *ei, int slot )
|
||||
{
|
||||
int idx = (slot & 63) * 2;
|
||||
con_nprint_t info;
|
||||
|
@ -192,7 +192,7 @@ void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func )
|
|||
ev = clgame.events[lastnum];
|
||||
|
||||
// NOTE: ev->index will be set later
|
||||
Q_strncpy( ev->name, szEvName, sizeof( ev->name ));
|
||||
Q_strncpy( ev->name, szEvName, MAX_QPATH );
|
||||
ev->func = func;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ CL_FireEvent
|
|||
|
||||
=============
|
||||
*/
|
||||
static qboolean CL_FireEvent( event_info_t *ei, int slot )
|
||||
qboolean CL_FireEvent( event_info_t *ei, int slot )
|
||||
{
|
||||
cl_user_event_t *ev;
|
||||
const char *name;
|
||||
|
@ -219,7 +219,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
|
|||
if( !ev )
|
||||
{
|
||||
idx = bound( 1, ei->index, ( MAX_EVENTS - 1 ));
|
||||
Con_Reportf( S_ERROR "%s: %s not precached\n", __func__, cl.event_precache[idx] );
|
||||
Con_Reportf( S_ERROR "CL_FireEvent: %s not precached\n", cl.event_precache[idx] );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
|
|||
return true;
|
||||
}
|
||||
|
||||
Con_Reportf( S_ERROR "%s: %s not hooked\n", __func__, name );
|
||||
Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ CL_FindEvent
|
|||
find first empty event
|
||||
=============
|
||||
*/
|
||||
static event_info_t *CL_FindEmptyEvent( void )
|
||||
event_info_t *CL_FindEmptyEvent( void )
|
||||
{
|
||||
int i;
|
||||
event_state_t *es;
|
||||
|
@ -320,7 +320,7 @@ CL_FindEvent
|
|||
replace only unreliable events
|
||||
=============
|
||||
*/
|
||||
static event_info_t *CL_FindUnreliableEvent( void )
|
||||
event_info_t *CL_FindUnreliableEvent( void )
|
||||
{
|
||||
event_state_t *es;
|
||||
event_info_t *ei;
|
||||
|
@ -350,7 +350,7 @@ CL_QueueEvent
|
|||
|
||||
=============
|
||||
*/
|
||||
static void CL_QueueEvent( int flags, int index, float delay, event_args_t *args )
|
||||
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args )
|
||||
{
|
||||
event_info_t *ei;
|
||||
|
||||
|
@ -497,14 +497,14 @@ void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word even
|
|||
// first check event for out of bounds
|
||||
if( eventindex < 1 || eventindex >= MAX_EVENTS )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: invalid eventindex %i\n", __func__, eventindex );
|
||||
Con_DPrintf( S_ERROR "CL_PlaybackEvent: invalid eventindex %i\n", eventindex );
|
||||
return;
|
||||
}
|
||||
|
||||
// check event for precached
|
||||
if( !CL_EventIndex( cl.event_precache[eventindex] ))
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: event %i was not precached\n", __func__, eventindex );
|
||||
Con_DPrintf( S_ERROR "CL_PlaybackEvent: event %i was not precached\n", eventindex );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,35 +46,10 @@ static int CL_LoadFontTexture( const char *fontname, uint texFlags, int *width )
|
|||
return tex;
|
||||
}
|
||||
|
||||
static int CL_FontRenderMode( convar_t *fontrender )
|
||||
{
|
||||
switch((int)fontrender->value )
|
||||
{
|
||||
case 0:
|
||||
return kRenderTransAdd;
|
||||
case 1:
|
||||
return kRenderTransAlpha;
|
||||
case 2:
|
||||
return kRenderTransTexture;
|
||||
default:
|
||||
Cvar_DirectSet( fontrender, fontrender->def_string );
|
||||
}
|
||||
|
||||
return kRenderTransTexture;
|
||||
}
|
||||
|
||||
void CL_SetFontRendermode( cl_font_t *font )
|
||||
{
|
||||
ref.dllFuncs.GL_SetRenderMode( CL_FontRenderMode( font->rendermode ));
|
||||
}
|
||||
|
||||
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
|
||||
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags )
|
||||
{
|
||||
int font_width, i;
|
||||
|
||||
if( !rendermode )
|
||||
return false;
|
||||
|
||||
if( font->valid )
|
||||
return true; // already loaded
|
||||
|
||||
|
@ -85,6 +60,7 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
|
|||
font->type = FONT_FIXED;
|
||||
font->valid = true;
|
||||
font->scale = scale;
|
||||
font->nearest = FBitSet( texFlags, TF_NEAREST );
|
||||
font->rendermode = rendermode;
|
||||
font->charHeight = Q_rint( font_width / 16 * scale );
|
||||
|
||||
|
@ -101,16 +77,13 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
|
|||
return true;
|
||||
}
|
||||
|
||||
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
|
||||
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags )
|
||||
{
|
||||
fs_offset_t length;
|
||||
qfont_t src;
|
||||
byte *pfile;
|
||||
int font_width, i;
|
||||
|
||||
if( !rendermode )
|
||||
return false;
|
||||
|
||||
if( font->valid )
|
||||
return true;
|
||||
|
||||
|
@ -133,7 +106,8 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
|
|||
|
||||
font->type = FONT_VARIABLE;
|
||||
font->valid = true;
|
||||
font->scale = scale ? scale : 1.0f;
|
||||
font->scale = scale;
|
||||
font->nearest = FBitSet( texFlags, TF_NEAREST );
|
||||
font->rendermode = rendermode;
|
||||
font->charHeight = Q_rint( src.rowheight * scale );
|
||||
|
||||
|
@ -205,8 +179,7 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
|
|||
return font->charWidths[number];
|
||||
|
||||
rc = &font->fontRc[number];
|
||||
|
||||
if( font->scale <= 1.f || !REF_GET_PARM( PARM_TEX_FILTERING, font->hFontTexture ))
|
||||
if( font->nearest || font->scale <= 1.0f )
|
||||
half = 0;
|
||||
|
||||
s1 = ((float)rc->left + half ) / texw;
|
||||
|
@ -220,7 +193,7 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
|
|||
SPR_AdjustSize( &x, &y, &w, &h );
|
||||
|
||||
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
|
||||
CL_SetFontRendermode( font );
|
||||
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
|
||||
|
||||
// don't apply color to fixed fonts it's already colored
|
||||
if( font->type != FONT_FIXED || REF_GET_PARM( PARM_TEX_GLFORMAT, font->hFontTexture ) == 0x8045 ) // GL_LUMINANCE8_ALPHA8
|
||||
|
@ -243,7 +216,7 @@ int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *fon
|
|||
Con_UtfProcessChar( 0 ); // clear utf state
|
||||
|
||||
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
|
||||
CL_SetFontRendermode( font );
|
||||
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
|
||||
|
||||
Vector4Copy( color, current_color );
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ GNU General Public License for more details.
|
|||
#include "sound.h"
|
||||
#include "input.h"
|
||||
|
||||
// #define STUDIO_INTERPOLATION_FIX
|
||||
#define STUDIO_INTERPOLATION_FIX
|
||||
|
||||
/*
|
||||
==================
|
||||
|
@ -52,30 +52,19 @@ CL_UpdatePositions
|
|||
Store another position into interpolation circular buffer
|
||||
==================
|
||||
*/
|
||||
static void CL_UpdatePositions( cl_entity_t *ent )
|
||||
void CL_UpdatePositions( cl_entity_t *ent )
|
||||
{
|
||||
position_history_t *ph, *prev;
|
||||
|
||||
prev = &ent->ph[ent->current_position];
|
||||
position_history_t *ph;
|
||||
|
||||
ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
|
||||
ph = &ent->ph[ent->current_position];
|
||||
VectorCopy( ent->curstate.origin, ph->origin );
|
||||
VectorCopy( ent->curstate.angles, ph->angles );
|
||||
|
||||
ph->animtime = ent->curstate.animtime;
|
||||
|
||||
// a1ba: for some reason, this sometimes still may happen
|
||||
// at this time, I'm not sure whether this bug happens in delta readwrite code
|
||||
// or server just decides to go backwards and really sends these values
|
||||
if( ph->animtime < prev->animtime )
|
||||
{
|
||||
// try to deduce real animtime by looking up the difference between
|
||||
// server messages (cl.mtime is never modified ny the interpolation code)
|
||||
float diff = Q_max( 0, ent->curstate.msg_time - ent->prevstate.msg_time );
|
||||
|
||||
ph->animtime = prev->animtime + diff;
|
||||
}
|
||||
if( ent->model && ent->model->type == mod_brush )
|
||||
ph->animtime = ent->curstate.animtime;
|
||||
else
|
||||
ph->animtime = cl.time;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -85,7 +74,7 @@ CL_ResetPositions
|
|||
Interpolation init or reset after teleporting
|
||||
==================
|
||||
*/
|
||||
static void CL_ResetPositions( cl_entity_t *ent )
|
||||
void CL_ResetPositions( cl_entity_t *ent )
|
||||
{
|
||||
position_history_t store;
|
||||
|
||||
|
@ -107,7 +96,7 @@ check for instant movement in case
|
|||
we don't want interpolate this
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_EntityTeleported( cl_entity_t *ent )
|
||||
qboolean CL_EntityTeleported( cl_entity_t *ent )
|
||||
{
|
||||
float len, maxlen;
|
||||
vec3_t delta;
|
||||
|
@ -128,7 +117,7 @@ CL_CompareTimestamps
|
|||
round-off floating errors
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_CompareTimestamps( float t1, float t2 )
|
||||
qboolean CL_CompareTimestamps( float t1, float t2 )
|
||||
{
|
||||
int iTime1 = t1 * 1000;
|
||||
int iTime2 = t2 * 1000;
|
||||
|
@ -143,7 +132,7 @@ CL_EntityIgnoreLerp
|
|||
some ents will be ignore lerping
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
|
||||
qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
|
||||
{
|
||||
if( cl_nointerp.value > 0.f )
|
||||
return true;
|
||||
|
@ -160,7 +149,7 @@ CL_EntityCustomLerp
|
|||
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_EntityCustomLerp( cl_entity_t *e )
|
||||
qboolean CL_EntityCustomLerp( cl_entity_t *e )
|
||||
{
|
||||
switch( e->curstate.movetype )
|
||||
{
|
||||
|
@ -170,13 +159,6 @@ static qboolean CL_EntityCustomLerp( cl_entity_t *e )
|
|||
case MOVETYPE_FLY:
|
||||
case MOVETYPE_COMPOUND:
|
||||
return false;
|
||||
|
||||
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
|
||||
// INTERPOLATION IN GRAVGUNMOD COOP
|
||||
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
|
||||
case MOVETYPE_TOSS:
|
||||
if( cls.legacymode && e->model && e->model->type == mod_studio )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -189,7 +171,7 @@ CL_ParametricMove
|
|||
check for parametrical moved entities
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_ParametricMove( cl_entity_t *ent )
|
||||
qboolean CL_ParametricMove( cl_entity_t *ent )
|
||||
{
|
||||
float frac, dt, t;
|
||||
vec3_t delta;
|
||||
|
@ -226,7 +208,7 @@ CL_UpdateLatchedVars
|
|||
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateLatchedVars( cl_entity_t *ent )
|
||||
void CL_UpdateLatchedVars( cl_entity_t *ent )
|
||||
{
|
||||
if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio ))
|
||||
return; // below fields used only for alias and studio interpolation
|
||||
|
@ -321,7 +303,7 @@ CL_ProcessEntityUpdate
|
|||
apply changes since new frame received
|
||||
==================
|
||||
*/
|
||||
static void CL_ProcessEntityUpdate( cl_entity_t *ent )
|
||||
void CL_ProcessEntityUpdate( cl_entity_t *ent )
|
||||
{
|
||||
qboolean parametric;
|
||||
|
||||
|
@ -367,10 +349,11 @@ CL_FindInterpolationUpdates
|
|||
find two timestamps
|
||||
==================
|
||||
*/
|
||||
static qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, double targettime, position_history_t **ph0, position_history_t **ph1 )
|
||||
qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, position_history_t **ph0, position_history_t **ph1 )
|
||||
{
|
||||
qboolean extrapolate = true;
|
||||
uint i, i0, i1, imod;
|
||||
float at;
|
||||
|
||||
imod = ent->current_position;
|
||||
i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end)
|
||||
|
@ -378,10 +361,8 @@ static qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, double targettime
|
|||
|
||||
for( i = 1; i < HISTORY_MAX - 1; i++ )
|
||||
{
|
||||
double at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
|
||||
|
||||
if( at == 0.0f )
|
||||
break;
|
||||
at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
|
||||
if( at == 0.0f ) break;
|
||||
|
||||
if( targettime > at )
|
||||
{
|
||||
|
@ -406,14 +387,15 @@ CL_PureOrigin
|
|||
non-local players interpolation
|
||||
==================
|
||||
*/
|
||||
static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t outangles )
|
||||
void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangles )
|
||||
{
|
||||
double t1, t0, frac;
|
||||
qboolean extrapolate;
|
||||
float t1, t0, frac;
|
||||
position_history_t *ph0, *ph1;
|
||||
vec3_t delta;
|
||||
|
||||
// NOTE: ph0 is next, ph1 is a prev
|
||||
CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
|
||||
extrapolate = CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
|
||||
|
||||
if ( !ph0 || !ph1 )
|
||||
return;
|
||||
|
@ -421,7 +403,7 @@ static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t
|
|||
t0 = ph0->animtime;
|
||||
t1 = ph1->animtime;
|
||||
|
||||
if( t0 != 0.0 )
|
||||
if( t0 != 0.0f )
|
||||
{
|
||||
vec4_t q, q1, q2;
|
||||
|
||||
|
@ -429,9 +411,9 @@ static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t
|
|||
|
||||
if( !Q_equal( t0, t1 ))
|
||||
frac = ( t - t1 ) / ( t0 - t1 );
|
||||
else frac = 1.0;
|
||||
else frac = 1.0f;
|
||||
|
||||
frac = bound( 0.0, frac, 1.2 );
|
||||
frac = bound( 0.0f, frac, 1.2f );
|
||||
|
||||
VectorMA( ph1->origin, frac, delta, outorigin );
|
||||
|
||||
|
@ -455,11 +437,11 @@ CL_InterpolateModel
|
|||
non-players interpolation
|
||||
==================
|
||||
*/
|
||||
static int CL_InterpolateModel( cl_entity_t *e )
|
||||
int CL_InterpolateModel( cl_entity_t *e )
|
||||
{
|
||||
position_history_t *ph0 = NULL, *ph1 = NULL;
|
||||
vec3_t origin, angles, delta;
|
||||
double t, t1, t2, frac;
|
||||
float t, t1, t2, frac;
|
||||
vec4_t q, q1, q2;
|
||||
|
||||
VectorCopy( e->curstate.origin, e->origin );
|
||||
|
@ -507,7 +489,9 @@ static int CL_InterpolateModel( cl_entity_t *e )
|
|||
return 0;
|
||||
}
|
||||
|
||||
if( Q_equal( t2, t1 ))
|
||||
// HACKHACK: workaround buggy position history animtime
|
||||
// going backward sometimes
|
||||
if( Q_equal( t2, t1 ) || t2 < t1 )
|
||||
{
|
||||
VectorCopy( ph0->origin, e->origin );
|
||||
VectorCopy( ph0->angles, e->angles );
|
||||
|
@ -545,7 +529,7 @@ interpolate non-local clients
|
|||
*/
|
||||
void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||
{
|
||||
double targettime;
|
||||
float targettime;
|
||||
vec4_t q, q1, q2;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
|
@ -585,7 +569,7 @@ CL_ProcessPlayerState
|
|||
process player states after the new packet has received
|
||||
=================
|
||||
*/
|
||||
static void CL_ProcessPlayerState( int playerindex, entity_state_t *state )
|
||||
void CL_ProcessPlayerState( int playerindex, entity_state_t *state )
|
||||
{
|
||||
entity_state_t *ps;
|
||||
|
||||
|
@ -605,7 +589,7 @@ reset latched state if this frame entity was teleported
|
|||
or just EF_NOINTERP was set
|
||||
=================
|
||||
*/
|
||||
static void CL_ResetLatchedState( int pnum, frame_t *frame, cl_entity_t *ent )
|
||||
void CL_ResetLatchedState( int pnum, frame_t *frame, cl_entity_t *ent )
|
||||
{
|
||||
if( CHECKVISBIT( frame->flags, pnum ))
|
||||
{
|
||||
|
@ -695,7 +679,7 @@ CL_FlushEntityPacket
|
|||
Read and ignore whole entity packet.
|
||||
=================
|
||||
*/
|
||||
static void CL_FlushEntityPacket( sizebuf_t *msg )
|
||||
void CL_FlushEntityPacket( sizebuf_t *msg )
|
||||
{
|
||||
int newnum;
|
||||
entity_state_t from, to;
|
||||
|
@ -712,7 +696,7 @@ static void CL_FlushEntityPacket( sizebuf_t *msg )
|
|||
break; // done
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
Host_Error( "CL_FlushEntityPacket: overflow\n" );
|
||||
|
||||
MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ) ? DELTA_PLAYER : DELTA_ENTITY, cl.mtime[0] );
|
||||
}
|
||||
|
@ -725,7 +709,7 @@ CL_DeltaEntity
|
|||
processing delta update
|
||||
=================
|
||||
*/
|
||||
static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, qboolean has_update )
|
||||
void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, qboolean has_update )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
entity_state_t *state;
|
||||
|
@ -740,7 +724,7 @@ static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_s
|
|||
|
||||
if(( newnum < 0 ) || ( newnum >= clgame.maxEntities ))
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: invalid newnum: %d\n", __func__, newnum );
|
||||
Con_DPrintf( S_ERROR "CL_DeltaEntity: invalid newnum: %d\n", newnum );
|
||||
if( has_update )
|
||||
MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
|
||||
return;
|
||||
|
@ -885,7 +869,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
|||
break; // done
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
Host_Error( "CL_ParsePacketEntities: overflow\n" );
|
||||
|
||||
player = CL_IsPlayerIndex( newnum );
|
||||
|
||||
|
@ -955,7 +939,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
|||
}
|
||||
|
||||
if( newframe->num_entities != count && newframe->num_entities != 0 )
|
||||
Con_Reportf( S_WARN "%s%s: (%i should be %i)\n", __func__, delta ? "Delta" : "", newframe->num_entities, count );
|
||||
Con_Reportf( S_WARN "CL_Parse%sPacketEntities: (%i should be %i)\n", delta ? "Delta" : "", newframe->num_entities, count );
|
||||
|
||||
if( !newframe->valid )
|
||||
return playerbytes; // frame is not valid but message was parsed
|
||||
|
@ -1057,7 +1041,7 @@ CL_LinkCustomEntity
|
|||
Add server beam to draw list
|
||||
=============
|
||||
*/
|
||||
static void CL_LinkCustomEntity( cl_entity_t *ent, entity_state_t *state )
|
||||
void CL_LinkCustomEntity( cl_entity_t *ent, entity_state_t *state )
|
||||
{
|
||||
ent->curstate.movetype = state->modelindex; // !!!
|
||||
|
||||
|
@ -1080,7 +1064,7 @@ Create visible entities in the correct position
|
|||
for all current players
|
||||
=============
|
||||
*/
|
||||
static void CL_LinkPlayers( frame_t *frame )
|
||||
void CL_LinkPlayers( frame_t *frame )
|
||||
{
|
||||
entity_state_t *state;
|
||||
cl_entity_t *ent;
|
||||
|
@ -1163,7 +1147,7 @@ CL_LinkPacketEntities
|
|||
|
||||
===============
|
||||
*/
|
||||
static void CL_LinkPacketEntities( frame_t *frame )
|
||||
void CL_LinkPacketEntities( frame_t *frame )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
entity_state_t *state;
|
||||
|
@ -1187,7 +1171,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
|||
|
||||
if( !ent )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: bad entity %i\n", __func__, state->number );
|
||||
Con_Reportf( S_ERROR "CL_LinkPacketEntity: bad entity %i\n", state->number );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1228,33 +1212,17 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
|||
#else
|
||||
if( ent->lastmove >= cl.time )
|
||||
{
|
||||
float at = ent->curstate.animtime;
|
||||
|
||||
CL_ResetLatchedVars( ent, true );
|
||||
|
||||
if( cl_fixmodelinterpolationartifacts.value )
|
||||
ent->latched.prevanimtime = ent->curstate.animtime = at;
|
||||
|
||||
VectorCopy( ent->curstate.origin, ent->latched.prevorigin );
|
||||
VectorCopy( ent->curstate.angles, ent->latched.prevangles );
|
||||
|
||||
if( !FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
|
||||
{
|
||||
// disable step interpolation in client.dll
|
||||
ent->curstate.movetype = MOVETYPE_NONE;
|
||||
}
|
||||
// disable step interpolation in client.dll
|
||||
ent->curstate.movetype = MOVETYPE_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
|
||||
{
|
||||
interpolate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// restore step interpolation in client.dll
|
||||
ent->curstate.movetype = MOVETYPE_STEP;
|
||||
}
|
||||
// restore step interpolation in client.dll
|
||||
ent->curstate.movetype = MOVETYPE_STEP;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1279,24 +1247,11 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
|||
if ( !CL_InterpolateModel( ent ))
|
||||
continue;
|
||||
}
|
||||
// a1ba: in GoldSrc this is done for cstrike and czero
|
||||
// but let modders use this as an engine feature
|
||||
else if( FBitSet( host.features, ENGINE_STEP_POSHISTORY_LERP ) &&
|
||||
ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address ))
|
||||
else if( ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address ))
|
||||
{
|
||||
if( !CL_InterpolateModel( ent ))
|
||||
continue;
|
||||
}
|
||||
#if 0
|
||||
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
|
||||
// INTERPOLATION IN GRAVGUNMOD COOP
|
||||
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
|
||||
else if( cls.legacymode && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
|
||||
{
|
||||
if( !CL_InterpolateModel( ent ))
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
// no interpolation right now
|
||||
|
@ -1492,3 +1447,9 @@ qboolean CL_GetMovieSpatialization( rawchan_t *ch )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CL_ExtraUpdate( void )
|
||||
{
|
||||
clgame.dllFuncs.IN_Accumulate();
|
||||
S_ExtraUpdate();
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ static void CL_InitCDAudio( const char *filename )
|
|||
|
||||
if( ++c > MAX_CDTRACKS - 1 )
|
||||
{
|
||||
Con_Reportf( S_WARN "%s: too many tracks %i in %s\n", __func__, MAX_CDTRACKS, filename );
|
||||
Con_Reportf( S_WARN "CD_Init: too many tracks %i in %s\n", MAX_CDTRACKS, filename );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -357,23 +357,20 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h )
|
|||
*h *= yscale;
|
||||
}
|
||||
|
||||
static void SPR_AdjustTexCoords( int texnum, float width, float height, float *s1, float *t1, float *s2, float *t2 )
|
||||
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 )
|
||||
{
|
||||
if( REF_GET_PARM( PARM_TEX_FILTERING, texnum ))
|
||||
if( refState.width != clgame.scrInfo.iWidth )
|
||||
{
|
||||
if( refState.width != clgame.scrInfo.iWidth )
|
||||
{
|
||||
// align to texel if scaling
|
||||
*s1 += 0.5f;
|
||||
*s2 -= 0.5f;
|
||||
}
|
||||
// align to texel if scaling
|
||||
*s1 += 0.5f;
|
||||
*s2 -= 0.5f;
|
||||
}
|
||||
|
||||
if( refState.height != clgame.scrInfo.iHeight )
|
||||
{
|
||||
// align to texel if scaling
|
||||
*t1 += 0.5f;
|
||||
*t2 -= 0.5f;
|
||||
}
|
||||
if( refState.height != clgame.scrInfo.iHeight )
|
||||
{
|
||||
// align to texel if scaling
|
||||
*t1 += 0.5f;
|
||||
*t2 -= 0.5f;
|
||||
}
|
||||
|
||||
*s1 /= width;
|
||||
|
@ -405,8 +402,6 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
|
|||
height = h;
|
||||
}
|
||||
|
||||
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
|
||||
|
||||
if( prc )
|
||||
{
|
||||
wrect_t rc = *prc;
|
||||
|
@ -423,7 +418,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
|
|||
t2 = rc.bottom;
|
||||
|
||||
// calc user-defined rectangle
|
||||
SPR_AdjustTexCoords( texnum, width, height, &s1, &t1, &s2, &t2 );
|
||||
SPR_AdjustTexCoords( width, height, &s1, &t1, &s2, &t2 );
|
||||
width = rc.right - rc.left;
|
||||
height = rc.bottom - rc.top;
|
||||
}
|
||||
|
@ -439,6 +434,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
|
|||
|
||||
// scale for screen sizes
|
||||
SPR_AdjustSize( &x, &y, &width, &height );
|
||||
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
|
||||
ref.dllFuncs.Color4ub( clgame.ds.spriteColor[0], clgame.ds.spriteColor[1], clgame.ds.spriteColor[2], clgame.ds.spriteColor[3] );
|
||||
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum );
|
||||
}
|
||||
|
@ -474,7 +470,8 @@ void CL_DrawCenterPrint( void )
|
|||
pText = clgame.centerPrint.message;
|
||||
|
||||
CL_DrawCharacterLen( font, 0, NULL, &charHeight );
|
||||
CL_SetFontRendermode( font );
|
||||
|
||||
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
|
||||
for( i = 0; i < clgame.centerPrint.lines; i++ )
|
||||
{
|
||||
lineLength = 0;
|
||||
|
@ -550,7 +547,7 @@ fill screen with specfied color
|
|||
can be modulated
|
||||
=============
|
||||
*/
|
||||
static void CL_DrawScreenFade( void )
|
||||
void CL_DrawScreenFade( void )
|
||||
{
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
int alpha;
|
||||
|
@ -766,7 +763,7 @@ CL_SoundFromIndex
|
|||
return soundname from index
|
||||
====================
|
||||
*/
|
||||
static const char *CL_SoundFromIndex( int index )
|
||||
const char *CL_SoundFromIndex( int index )
|
||||
{
|
||||
sfx_t *sfx = NULL;
|
||||
int hSound;
|
||||
|
@ -777,14 +774,14 @@ static const char *CL_SoundFromIndex( int index )
|
|||
|
||||
if( !hSound )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: invalid sound index %i\n", __func__, index );
|
||||
Con_DPrintf( S_ERROR "CL_SoundFromIndex: invalid sound index %i\n", index );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sfx = S_GetSfxByHandle( hSound );
|
||||
if( !sfx )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: bad sfx for index %i\n", __func__, index );
|
||||
Con_DPrintf( S_ERROR "CL_SoundFromIndex: bad sfx for index %i\n", index );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -912,7 +909,7 @@ CL_DrawCrosshair
|
|||
Render crosshair
|
||||
====================
|
||||
*/
|
||||
static void CL_DrawCrosshair( void )
|
||||
void CL_DrawCrosshair( void )
|
||||
{
|
||||
int x, y, width, height;
|
||||
float xscale, yscale;
|
||||
|
@ -1041,10 +1038,10 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
|
|||
int i;
|
||||
|
||||
if( !pszName || !*pszName )
|
||||
Host_Error( "%s: bad message name\n", __func__ );
|
||||
Host_Error( "CL_LinkUserMessage: bad message name\n" );
|
||||
|
||||
if( svc_num <= svc_lastmsg )
|
||||
Host_Error( "%s: tried to hook a system message \"%s\"\n", __func__, svc_strings[svc_num] );
|
||||
Host_Error( "CL_LinkUserMessage: tried to hook a system message \"%s\"\n", svc_strings[svc_num] );
|
||||
|
||||
// see if already hooked
|
||||
for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
|
||||
|
@ -1061,7 +1058,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
|
|||
|
||||
if( i == MAX_USER_MESSAGES )
|
||||
{
|
||||
Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
|
||||
Host_Error( "CL_LinkUserMessage: MAX_USER_MESSAGES hit!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1112,12 +1109,12 @@ void CL_InitEdicts( int maxclients )
|
|||
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
|
||||
}
|
||||
|
||||
ref.dllFuncs.R_ProcessEntData( true, clgame.entities, clgame.maxEntities );
|
||||
ref.dllFuncs.R_ProcessEntData( true );
|
||||
}
|
||||
|
||||
void CL_FreeEdicts( void )
|
||||
{
|
||||
ref.dllFuncs.R_ProcessEntData( false, NULL, 0 );
|
||||
ref.dllFuncs.R_ProcessEntData( false );
|
||||
|
||||
if( clgame.entities )
|
||||
Mem_Free( clgame.entities );
|
||||
|
@ -1238,18 +1235,22 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
|||
{
|
||||
char name[MAX_QPATH];
|
||||
model_t *mod;
|
||||
int i, start;
|
||||
int i;
|
||||
|
||||
// use high indices for client sprites
|
||||
// for GoldSrc bug-compatibility
|
||||
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
|
||||
|
||||
if( !COM_CheckString( filename ))
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: bad name!\n", __func__ );
|
||||
Con_Reportf( S_ERROR "CL_LoadSpriteModel: bad name!\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Q_strncpy( name, filename, sizeof( name ));
|
||||
COM_FixSlashes( name );
|
||||
|
||||
for( i = 0, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
||||
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
{
|
||||
if( !Q_stricmp( mod->name, name ))
|
||||
{
|
||||
|
@ -1266,15 +1267,8 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
|||
}
|
||||
|
||||
// find a free model slot spot
|
||||
// use low indices only for HUD sprites
|
||||
// for GoldSrc bug compatibility
|
||||
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
|
||||
|
||||
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
{
|
||||
if( !mod->name[0] )
|
||||
break; // this is a valid spot
|
||||
}
|
||||
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
if( !mod->name[0] ) break; // this is a valid spot
|
||||
|
||||
if( i == MAX_CLIENT_SPRITES / 2 )
|
||||
{
|
||||
|
@ -1329,7 +1323,6 @@ pfnSPR_Load
|
|||
function exported for support GoldSrc Monitor utility
|
||||
=========
|
||||
*/
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
|
||||
{
|
||||
model_t *spr;
|
||||
|
@ -1379,7 +1372,6 @@ pfnSPR_Frames
|
|||
function exported for support GoldSrc Monitor utility
|
||||
=========
|
||||
*/
|
||||
int EXPORT pfnSPR_Frames( HSPRITE hPic );
|
||||
int EXPORT pfnSPR_Frames( HSPRITE hPic )
|
||||
{
|
||||
int numFrames = 0;
|
||||
|
@ -1448,7 +1440,7 @@ pfnSPR_Draw
|
|||
*/
|
||||
static void GAME_EXPORT pfnSPR_Draw( int frame, int x, int y, const wrect_t *prc )
|
||||
{
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
|
||||
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
|
||||
}
|
||||
|
||||
|
@ -1503,12 +1495,12 @@ static void GAME_EXPORT pfnSPR_DrawAdditive( int frame, int x, int y, const wrec
|
|||
|
||||
/*
|
||||
=========
|
||||
SPR_GetList
|
||||
pfnSPR_GetList
|
||||
|
||||
for parsing half-life scripts - hud.txt etc
|
||||
=========
|
||||
*/
|
||||
static client_sprite_t *SPR_GetList( char *psz, int *piCount )
|
||||
static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )
|
||||
{
|
||||
cached_spritelist_t *pEntry = &clgame.sprlist[0];
|
||||
int slot, index, numSprites = 0;
|
||||
|
@ -1534,7 +1526,7 @@ static client_sprite_t *SPR_GetList( char *psz, int *piCount )
|
|||
|
||||
if( slot == MAX_CLIENT_SPRITES )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: overflow cache!\n", __func__ );
|
||||
Con_Printf( S_ERROR "SPR_GetList: overflow cache!\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1598,7 +1590,7 @@ CL_FillRGBA
|
|||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
|
||||
void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
|
||||
{
|
||||
float _x = x, _y = y, _w = w, _h = h;
|
||||
|
||||
|
@ -1640,7 +1632,6 @@ get actual screen info
|
|||
*/
|
||||
int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
|
||||
{
|
||||
qboolean apply_scale_factor = false;
|
||||
float scale_factor = hud_scale.value;
|
||||
|
||||
if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED ))
|
||||
|
@ -1655,24 +1646,17 @@ int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
|
|||
clgame.scrInfo.iSize = sizeof( clgame.scrInfo );
|
||||
clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH;
|
||||
|
||||
if( scale_factor && scale_factor != 1.0f )
|
||||
{
|
||||
float scaled_width = (float)refState.width / scale_factor;
|
||||
if( scaled_width >= hud_scale_minimal_width.value )
|
||||
apply_scale_factor = true;
|
||||
}
|
||||
|
||||
if( apply_scale_factor )
|
||||
if( scale_factor && scale_factor != 1.0f)
|
||||
{
|
||||
clgame.scrInfo.iWidth = (float)refState.width / scale_factor;
|
||||
clgame.scrInfo.iHeight = (float)refState.height / scale_factor;
|
||||
SetBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
|
||||
clgame.scrInfo.iFlags |= SCRINFO_STRETCHED;
|
||||
}
|
||||
else
|
||||
{
|
||||
clgame.scrInfo.iWidth = refState.width;
|
||||
clgame.scrInfo.iHeight = refState.height;
|
||||
ClearBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
|
||||
clgame.scrInfo.iFlags &= ~SCRINFO_STRETCHED;
|
||||
}
|
||||
|
||||
if( !pscrinfo ) return 0;
|
||||
|
@ -1713,8 +1697,7 @@ pfnCvar_RegisterVariable
|
|||
static cvar_t *GAME_EXPORT pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
|
||||
{
|
||||
// a1ba: try to mitigate outdated client.dll vulnerabilities
|
||||
if( !Q_stricmp( szName, "motdfile" )
|
||||
|| !Q_stricmp( szName, "sensitivity" ))
|
||||
if( !Q_stricmp( szName, "motdfile" ))
|
||||
flags |= FCVAR_PRIVILEGED;
|
||||
|
||||
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
|
||||
|
@ -1743,7 +1726,7 @@ static int GAME_EXPORT pfnHookUserMsg( const char *pszName, pfnUserMsgHook pfn )
|
|||
|
||||
if( i == MAX_USER_MESSAGES )
|
||||
{
|
||||
Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
|
||||
Host_Error( "HookUserMsg: MAX_USER_MESSAGES hit!\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2135,7 +2118,7 @@ pfnGetViewModel
|
|||
|
||||
=============
|
||||
*/
|
||||
static cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
|
||||
cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
|
||||
{
|
||||
return &clgame.viewent;
|
||||
}
|
||||
|
@ -2293,7 +2276,7 @@ static void GAME_EXPORT pfnHookEvent( const char *filename, pfnEventHook pfn )
|
|||
|
||||
if( !Q_stricmp( name, ev->name ) && ev->func != NULL )
|
||||
{
|
||||
Con_Reportf( S_WARN "%s: %s already hooked!\n", __func__, name );
|
||||
Con_Reportf( S_WARN "CL_HookEvent: %s already hooked!\n", name );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2376,7 +2359,7 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
|
|||
if( lasttimewarn < host.realtime )
|
||||
{
|
||||
// tell user about problem (but don't spam console)
|
||||
Con_DPrintf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
|
||||
Con_Printf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
|
||||
lasttimewarn = host.realtime + 1.0f;
|
||||
}
|
||||
|
||||
|
@ -2484,36 +2467,6 @@ static physent_t *pfnGetVisent( int idx )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int GAME_EXPORT CL_TestLine( const vec3_t start, const vec3_t end, int flags )
|
||||
{
|
||||
return PM_TestLineExt( clgame.pmove, clgame.pmove->physents, clgame.pmove->numphysent, start, end, flags );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_PushTraceBounds
|
||||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs )
|
||||
{
|
||||
hullnum = bound( 0, hullnum, 3 );
|
||||
VectorCopy( mins, clgame.pmove->player_mins[hullnum] );
|
||||
VectorCopy( maxs, clgame.pmove->player_maxs[hullnum] );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_PopTraceBounds
|
||||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT CL_PopTraceBounds( void )
|
||||
{
|
||||
memcpy( clgame.pmove->player_mins, host.player_mins, sizeof( host.player_mins ));
|
||||
memcpy( clgame.pmove->player_maxs, host.player_maxs, sizeof( host.player_maxs ));
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
pfnSetTraceHull
|
||||
|
@ -2709,48 +2662,6 @@ static model_t *pfnLoadMapSprite( const char *filename )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
COM_AddAppDirectoryToSearchPath
|
||||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
|
||||
{
|
||||
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
COM_ExpandFilename
|
||||
|
||||
Finds the file in the search path, copies over the name with the full path name.
|
||||
This doesn't search in the pak file.
|
||||
===========
|
||||
*/
|
||||
static int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
|
||||
{
|
||||
char result[MAX_SYSPATH];
|
||||
|
||||
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
|
||||
return 0;
|
||||
|
||||
// filename examples:
|
||||
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
|
||||
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
|
||||
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
|
||||
{
|
||||
// check for enough room
|
||||
if( Q_strlen( result ) > nameOutBufferSize )
|
||||
return 0;
|
||||
|
||||
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
PlayerInfo_ValueForKey
|
||||
|
@ -3420,7 +3331,7 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
|
|||
|
||||
if( !response )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: no callbcak specified for request with context %i!\n", __func__, context );
|
||||
Con_DPrintf( S_ERROR "Net_SendRequest: no callbcak specified for request with context %i!\n", context );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3808,7 +3719,7 @@ static cl_enginefunc_t gEngfuncs =
|
|||
pfnSPR_DrawAdditive,
|
||||
SPR_EnableScissor,
|
||||
SPR_DisableScissor,
|
||||
SPR_GetList,
|
||||
pfnSPR_GetList,
|
||||
CL_FillRGBA,
|
||||
CL_GetScreenInfo,
|
||||
pfnSetCrosshair,
|
||||
|
@ -4030,14 +3941,14 @@ qboolean CL_LoadProgs( const char *name )
|
|||
// trying to get single export
|
||||
if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL )
|
||||
{
|
||||
Con_Reportf( "%s: found single callback export\n", __func__ );
|
||||
Con_Reportf( "CL_LoadProgs: found single callback export\n" );
|
||||
|
||||
// trying to fill interface now
|
||||
GetClientAPI( &clgame.dllFuncs );
|
||||
}
|
||||
else if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "F" )) != NULL )
|
||||
{
|
||||
Con_Reportf( "%s: found single callback export (secured client dlls)\n", __func__ );
|
||||
Con_Reportf( "CL_LoadProgs: found single callback export (secured client dlls)\n" );
|
||||
|
||||
// trying to fill interface now
|
||||
CL_GetSecuredClientAPI( GetClientAPI );
|
||||
|
@ -4065,7 +3976,7 @@ qboolean CL_LoadProgs( const char *name )
|
|||
// functions are cleared before all the extensions are evaluated
|
||||
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
|
||||
{
|
||||
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
|
||||
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name );
|
||||
|
||||
if( critical_exports )
|
||||
{
|
||||
|
@ -4092,13 +4003,13 @@ qboolean CL_LoadProgs( const char *name )
|
|||
// functions are cleared before all the extensions are evaluated
|
||||
// NOTE: new exports can be missed without stop the engine
|
||||
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
|
||||
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
|
||||
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name );
|
||||
}
|
||||
|
||||
if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
|
||||
{
|
||||
COM_FreeLibrary( clgame.hInstance );
|
||||
Con_Reportf( "%s: can't init client API\n", __func__ );
|
||||
Con_Reportf( "CL_LoadProgs: can't init client API\n" );
|
||||
clgame.hInstance = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -4115,10 +4026,10 @@ qboolean CL_LoadProgs( const char *name )
|
|||
CL_InitTempEnts ();
|
||||
|
||||
if( !R_InitRenderAPI()) // Xash3D extension
|
||||
Con_Reportf( S_WARN "%s: couldn't get render API\n", __func__ );
|
||||
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get render API\n" );
|
||||
|
||||
if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
|
||||
Con_Reportf( S_WARN "%s: couldn't get mobility API\n", __func__ );
|
||||
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" );
|
||||
|
||||
CL_InitEdicts( cl.maxclients ); // initailize local player and world
|
||||
CL_InitClientMove(); // initialize pm_shared
|
||||
|
|
|
@ -216,14 +216,12 @@ UI_ShowConnectionWarning
|
|||
show message box
|
||||
=================
|
||||
*/
|
||||
qboolean UI_ShowMessageBox( const char *text )
|
||||
void UI_ShowMessageBox( const char *text )
|
||||
{
|
||||
if( gameui.dllFuncs2.pfnShowMessageBox )
|
||||
{
|
||||
gameui.dllFuncs2.pfnShowMessageBox( text );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UI_ConnectionProgress_Disconnect( void )
|
||||
|
@ -494,7 +492,7 @@ static HIMAGE GAME_EXPORT pfnPIC_Load( const char *szPicName, const byte *image_
|
|||
|
||||
if( !COM_CheckString( szPicName ))
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: refusing to load image with empty name\n", __func__ );
|
||||
Con_Reportf( S_ERROR "CL_LoadImage: refusing to load image with empty name\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -544,7 +542,7 @@ pfnPIC_Set
|
|||
|
||||
=========
|
||||
*/
|
||||
static void GAME_EXPORT pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
|
||||
void GAME_EXPORT pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
|
||||
{
|
||||
gameui.ds.gl_texturenum = hPic;
|
||||
r = bound( 0, r, 255 );
|
||||
|
@ -560,7 +558,7 @@ pfnPIC_Draw
|
|||
|
||||
=========
|
||||
*/
|
||||
static void GAME_EXPORT pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
|
||||
void GAME_EXPORT pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
|
||||
{
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
|
||||
PIC_DrawGeneric( x, y, width, height, prc );
|
||||
|
@ -572,7 +570,7 @@ pfnPIC_DrawTrans
|
|||
|
||||
=========
|
||||
*/
|
||||
static void GAME_EXPORT pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
|
||||
void GAME_EXPORT pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
|
||||
{
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
|
||||
PIC_DrawGeneric( x, y, width, height, prc );
|
||||
|
@ -584,7 +582,7 @@ pfnPIC_DrawHoles
|
|||
|
||||
=========
|
||||
*/
|
||||
static void GAME_EXPORT pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
|
||||
void GAME_EXPORT pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
|
||||
{
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
|
||||
PIC_DrawGeneric( x, y, width, height, prc );
|
||||
|
@ -596,7 +594,7 @@ pfnPIC_DrawAdditive
|
|||
|
||||
=========
|
||||
*/
|
||||
static void GAME_EXPORT pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
|
||||
void GAME_EXPORT pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
|
||||
{
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
|
||||
PIC_DrawGeneric( x, y, width, height, prc );
|
||||
|
@ -986,7 +984,7 @@ pfnCheckGameDll
|
|||
|
||||
=========
|
||||
*/
|
||||
static int GAME_EXPORT pfnCheckGameDll( void )
|
||||
int GAME_EXPORT pfnCheckGameDll( void )
|
||||
{
|
||||
#ifdef XASH_INTERNAL_GAMELIBS
|
||||
return true;
|
||||
|
@ -1013,7 +1011,7 @@ pfnChangeInstance
|
|||
*/
|
||||
static void GAME_EXPORT pfnChangeInstance( const char *newInstance, const char *szFinalMessage )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s menu call is deprecated!\n", __func__ );
|
||||
Con_Reportf( S_ERROR "ChangeInstance menu call is deprecated!\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1094,25 +1092,6 @@ static int pfnDelete( const char *path )
|
|||
return FS_Delete( path );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
|
||||
{
|
||||
Con_DefaultColor( r, g, b, true );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT pfnSetCursor( void *hCursor )
|
||||
{
|
||||
uintptr_t cursor;
|
||||
|
||||
if( !gameui.use_extended_api )
|
||||
return; // ignore original Xash menus
|
||||
|
||||
cursor = (uintptr_t)hCursor;
|
||||
if( cursor < dc_user || cursor > dc_last )
|
||||
return;
|
||||
|
||||
Platform_SetCursorType( cursor );
|
||||
}
|
||||
|
||||
// engine callbacks
|
||||
static ui_enginefuncs_t gEngfuncs =
|
||||
{
|
||||
|
@ -1152,7 +1131,7 @@ static ui_enginefuncs_t gEngfuncs =
|
|||
UI_DrawConsoleString,
|
||||
UI_DrawSetTextColor,
|
||||
Con_DrawStringLen,
|
||||
pfnCon_DefaultColor,
|
||||
Con_DefaultColor,
|
||||
pfnGetPlayerModel,
|
||||
pfnSetPlayerModel,
|
||||
pfnClearScene,
|
||||
|
@ -1192,7 +1171,7 @@ static ui_enginefuncs_t gEngfuncs =
|
|||
pfnHostEndGame,
|
||||
COM_RandomFloat,
|
||||
COM_RandomLong,
|
||||
pfnSetCursor,
|
||||
IN_SetCursor,
|
||||
pfnIsMapValid,
|
||||
GL_ProcessTexture,
|
||||
COM_CompareFileTime,
|
||||
|
@ -1236,7 +1215,6 @@ static ui_extendedfuncs_t gExtendedfuncs =
|
|||
pfnParseFileSafe,
|
||||
NET_AdrToString,
|
||||
NET_CompareAdrSort,
|
||||
Sys_GetNativeObject,
|
||||
};
|
||||
|
||||
void UI_UnloadProgs( void )
|
||||
|
@ -1296,13 +1274,13 @@ qboolean UI_LoadProgs( void )
|
|||
if(( GetMenuAPI = (MENUAPI)COM_GetProcAddress( gameui.hInstance, "GetMenuAPI" )) == NULL )
|
||||
{
|
||||
COM_FreeLibrary( gameui.hInstance );
|
||||
Con_Reportf( "%s: can't init menu API\n", __func__ );
|
||||
Con_Reportf( "UI_LoadProgs: can't init menu API\n" );
|
||||
gameui.hInstance = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
gameui.use_extended_api = false;
|
||||
gameui.use_text_api = false;
|
||||
|
||||
// make local copy of engfuncs to prevent overwrite it with user dll
|
||||
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
|
||||
|
@ -1312,7 +1290,7 @@ qboolean UI_LoadProgs( void )
|
|||
if( !GetMenuAPI( &gameui.dllFuncs, &gpEngfuncs, gameui.globals ))
|
||||
{
|
||||
COM_FreeLibrary( gameui.hInstance );
|
||||
Con_Reportf( "%s: can't init menu API\n", __func__ );
|
||||
Con_Reportf( "UI_LoadProgs: can't init menu API\n" );
|
||||
Mem_FreePool( &gameui.mempool );
|
||||
gameui.hInstance = NULL;
|
||||
return false;
|
||||
|
@ -1325,30 +1303,30 @@ qboolean UI_LoadProgs( void )
|
|||
// try to initialize new extended API
|
||||
if( ( GetExtAPI = (UIEXTENEDEDAPI)COM_GetProcAddress( gameui.hInstance, "GetExtAPI" ) ) )
|
||||
{
|
||||
Con_Reportf( "%s: extended Menu API found\n", __func__ );
|
||||
Con_Reportf( "UI_LoadProgs: extended Menu API found\n" );
|
||||
if( GetExtAPI( MENU_EXTENDED_API_VERSION, &gameui.dllFuncs2, &gpExtendedfuncs ) )
|
||||
{
|
||||
Con_Reportf( "%s: extended Menu API initialized\n", __func__ );
|
||||
gameui.use_extended_api = true;
|
||||
Con_Reportf( "UI_LoadProgs: extended Menu API initialized\n" );
|
||||
gameui.use_text_api = true;
|
||||
}
|
||||
}
|
||||
else // otherwise, fallback to old and deprecated extensions
|
||||
{
|
||||
if( ( GiveTextApi = (UITEXTAPI)COM_GetProcAddress( gameui.hInstance, "GiveTextAPI" ) ) )
|
||||
{
|
||||
Con_Reportf( "%s: extended text API found\n", __func__ );
|
||||
Con_Reportf( "UI_LoadProgs: extended text API found\n" );
|
||||
Con_Reportf( S_WARN "Text API is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
|
||||
if( GiveTextApi( &gpExtendedfuncs ) ) // they are binary compatible, so we can just pass extended funcs API to menu
|
||||
{
|
||||
Con_Reportf( "%s: extended text API initialized\n", __func__ );
|
||||
gameui.use_extended_api = true;
|
||||
Con_Reportf( "UI_LoadProgs: extended text API initialized\n" );
|
||||
gameui.use_text_api = true;
|
||||
}
|
||||
}
|
||||
|
||||
gameui.dllFuncs2.pfnAddTouchButtonToList = (ADDTOUCHBUTTONTOLIST)COM_GetProcAddress( gameui.hInstance, "AddTouchButtonToList" );
|
||||
if( gameui.dllFuncs2.pfnAddTouchButtonToList )
|
||||
{
|
||||
Con_Reportf( "%s: AddTouchButtonToList call found\n", __func__ );
|
||||
Con_Reportf( "UI_LoadProgs: AddTouchButtonToList call found\n" );
|
||||
Con_Reportf( S_WARN "AddTouchButtonToList is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -387,7 +387,7 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
|
|||
// move rolling average
|
||||
framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0f - FRAMERATE_AVG_FRAC ) * framerate;
|
||||
|
||||
CL_SetFontRendermode( font );
|
||||
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
|
||||
|
||||
if( framerate > 0.0f )
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ GNU General Public License for more details.
|
|||
#include "shake.h"
|
||||
#include "hltv.h"
|
||||
#include "input.h"
|
||||
#include "server.h"
|
||||
#if XASH_LOW_MEMORY != 2
|
||||
int CL_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
|
||||
#endif
|
||||
|
@ -31,7 +32,7 @@ CL_UserMsgStub
|
|||
Default stub for missed callbacks
|
||||
===============
|
||||
*/
|
||||
static int CL_UserMsgStub( const char *pszName, int iSize, void *pbuf )
|
||||
int CL_UserMsgStub( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ CL_ParseSoundPacket
|
|||
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseSoundPacket( sizebuf_t *msg )
|
||||
void CL_ParseSoundPacket( sizebuf_t *msg )
|
||||
{
|
||||
vec3_t pos;
|
||||
int chan, sound;
|
||||
|
@ -188,7 +189,7 @@ void CL_ParseServerTime( sizebuf_t *msg )
|
|||
cl.mtime[1] = cl.mtime[0];
|
||||
cl.mtime[0] = MSG_ReadFloat( msg );
|
||||
|
||||
if( cls.legacymode == PROTO_QUAKE )
|
||||
if( cls.demoplayback == DEMO_QUAKE1 )
|
||||
return; // don't mess the time
|
||||
|
||||
if( cl.maxclients == 1 )
|
||||
|
@ -249,7 +250,7 @@ void CL_ParseMovevars( sizebuf_t *msg )
|
|||
|
||||
// update sky if changed
|
||||
if( Q_strcmp( clgame.oldmovevars.skyName, clgame.movevars.skyName ) && cl.video_prepped )
|
||||
R_SetupSky( clgame.movevars.skyName );
|
||||
ref.dllFuncs.R_SetupSky( clgame.movevars.skyName );
|
||||
|
||||
memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t ));
|
||||
clgame.entities->curstate.scale = clgame.movevars.waveHeight;
|
||||
|
@ -304,7 +305,7 @@ CL_ParseStaticEntity
|
|||
static client entity
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseStaticEntity( sizebuf_t *msg )
|
||||
void CL_ParseStaticEntity( sizebuf_t *msg )
|
||||
{
|
||||
int i, newnum;
|
||||
entity_state_t from, to;
|
||||
|
@ -458,7 +459,6 @@ void CL_BatchResourceRequest( qboolean initialize )
|
|||
byte data[MAX_INIT_MSG];
|
||||
resource_t *p, *n;
|
||||
sizebuf_t msg;
|
||||
qboolean done_downloading = true;
|
||||
|
||||
MSG_Init( &msg, "Resource Batch", data, sizeof( data ));
|
||||
|
||||
|
@ -488,24 +488,20 @@ void CL_BatchResourceRequest( qboolean initialize )
|
|||
case t_model:
|
||||
case t_eventscript:
|
||||
if( !CL_CheckFile( &msg, p ))
|
||||
{
|
||||
done_downloading = false;
|
||||
break;
|
||||
}
|
||||
CL_MoveToOnHandList( p );
|
||||
break;
|
||||
case t_skin:
|
||||
CL_MoveToOnHandList( p );
|
||||
break;
|
||||
case t_decal:
|
||||
if( !HPAK_GetDataPointer( hpk_custom_file.string, p, NULL, NULL ))
|
||||
if( !HPAK_GetDataPointer( CUSTOM_RES_PATH, p, NULL, NULL ))
|
||||
{
|
||||
if( !FBitSet( p->ucFlags, RES_REQUESTED ))
|
||||
{
|
||||
MSG_BeginClientCmd( &msg, clc_stringcmd );
|
||||
MSG_WriteStringf( &msg, "dlfile !MD5%s", MD5_Print( p->rgucMD5_hash ));;
|
||||
SetBits( p->ucFlags, RES_REQUESTED );
|
||||
done_downloading = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -530,7 +526,11 @@ void CL_BatchResourceRequest( qboolean initialize )
|
|||
|
||||
if( cls.state != ca_disconnected )
|
||||
{
|
||||
if( done_downloading && CL_PrecacheResources( ))
|
||||
if( !cl.downloadUrl[0] && !MSG_GetNumBytesWritten( &msg ) && CL_PrecacheResources( ))
|
||||
{
|
||||
CL_RegisterResources( &msg );
|
||||
}
|
||||
if( cl.downloadUrl[0] && host.downloadcount == 0 && CL_PrecacheResources( ) )
|
||||
{
|
||||
CL_RegisterResources( &msg );
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ static void CL_StartResourceDownloading( const char *pszMessage, qboolean bCusto
|
|||
CL_BatchResourceRequest( !bCustom );
|
||||
}
|
||||
|
||||
static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_t type )
|
||||
customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_t type )
|
||||
{
|
||||
customization_t *pList;
|
||||
|
||||
|
@ -631,7 +631,7 @@ static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
|
||||
void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
|
||||
{
|
||||
customization_t *pList;
|
||||
customization_t *pNext;
|
||||
|
@ -722,7 +722,7 @@ void CL_ParseCustomization( sizebuf_t *msg )
|
|||
}
|
||||
}
|
||||
|
||||
if( HPAK_GetDataPointer( hpk_custom_file.string, pRes, NULL, NULL ))
|
||||
if( HPAK_GetDataPointer( CUSTOM_RES_PATH, pRes, NULL, NULL ))
|
||||
{
|
||||
qboolean bError = false;
|
||||
|
||||
|
@ -802,7 +802,7 @@ CL_CreateCustomizationList
|
|||
loading custom decal for self
|
||||
==================
|
||||
*/
|
||||
static void CL_CreateCustomizationList( void )
|
||||
void CL_CreateCustomizationList( void )
|
||||
{
|
||||
resource_t *pResource;
|
||||
player_info_t *pPlayer;
|
||||
|
@ -854,7 +854,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
|
|||
int i;
|
||||
uint32_t mapCRC;
|
||||
|
||||
HPAK_CheckSize( hpk_custom_file.string );
|
||||
HPAK_CheckSize( CUSTOM_RES_PATH );
|
||||
|
||||
Con_Reportf( "%s packet received.\n", legacy ? "Legacy serverdata" : "Serverdata" );
|
||||
|
||||
|
@ -903,7 +903,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
|
|||
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
|
||||
background = MSG_ReadOneBit( msg );
|
||||
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
|
||||
Host_ValidateEngineFeatures( MSG_ReadDword( msg ));
|
||||
host.features = (uint)MSG_ReadLong( msg );
|
||||
|
||||
if( !legacy )
|
||||
{
|
||||
|
@ -1204,7 +1204,7 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
|
|||
player = CL_IsPlayerIndex( newnum );
|
||||
|
||||
if( newnum >= clgame.maxEntities )
|
||||
Host_Error( "%s: no free edicts\n", __func__ );
|
||||
Host_Error( "CL_AllocEdict: no free edicts\n" );
|
||||
|
||||
ent = CL_EDICT_NUM( newnum );
|
||||
memset( &ent->prevstate, 0, sizeof( ent->prevstate ));
|
||||
|
@ -1381,15 +1381,11 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
|
|||
slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );
|
||||
|
||||
if( slot >= MAX_CLIENTS )
|
||||
Host_Error( "%s: svc_updateuserinfo >= MAX_CLIENTS\n", __func__ );
|
||||
|
||||
player = &cl.players[slot];
|
||||
Host_Error( "CL_ParseServerMessage: svc_updateuserinfo >= MAX_CLIENTS\n" );
|
||||
|
||||
if( !legacy )
|
||||
id = MSG_ReadLong( msg ); // unique user ID
|
||||
else
|
||||
id = 0; // bogus
|
||||
|
||||
player = &cl.players[slot];
|
||||
active = MSG_ReadOneBit( msg ) ? true : false;
|
||||
|
||||
if( active )
|
||||
|
@ -1411,10 +1407,6 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
|
|||
|
||||
memset( player, 0, sizeof( *player ));
|
||||
}
|
||||
|
||||
// in GoldSrc userinfo might be empty but userid is always sent as separate value
|
||||
// thus avoids clean up even after client disconnect
|
||||
player->userid = id;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1494,7 +1486,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
|
|||
slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );
|
||||
|
||||
if( slot >= MAX_CLIENTS )
|
||||
Host_Error( "%s: svc_pings > MAX_CLIENTS\n", __func__ );
|
||||
Host_Error( "CL_ParseServerMessage: svc_pings > MAX_CLIENTS\n" );
|
||||
|
||||
player = &cl.players[slot];
|
||||
player->ping = MSG_ReadUBitLong( msg, 12 );
|
||||
|
@ -1502,7 +1494,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
|
|||
}
|
||||
}
|
||||
|
||||
static void CL_SendConsistencyInfo( sizebuf_t *msg )
|
||||
void CL_SendConsistencyInfo( sizebuf_t *msg )
|
||||
{
|
||||
qboolean user_changed_diskfile;
|
||||
vec3_t mins, maxs;
|
||||
|
@ -1646,8 +1638,8 @@ void CL_RegisterResources( sizebuf_t *msg )
|
|||
|
||||
CL_ClearWorld ();
|
||||
|
||||
// load skybox
|
||||
R_SetupSky( clgame.movevars.skyName );
|
||||
// update the ref state.
|
||||
R_UpdateRefState ();
|
||||
|
||||
// tell rendering system we have a new set of models.
|
||||
ref.dllFuncs.R_NewMap ();
|
||||
|
@ -1682,7 +1674,7 @@ void CL_RegisterResources( sizebuf_t *msg )
|
|||
}
|
||||
}
|
||||
|
||||
static void CL_ParseConsistencyInfo( sizebuf_t *msg )
|
||||
void CL_ParseConsistencyInfo( sizebuf_t *msg )
|
||||
{
|
||||
int lastcheck;
|
||||
int delta;
|
||||
|
@ -1722,7 +1714,7 @@ static void CL_ParseConsistencyInfo( sizebuf_t *msg )
|
|||
}
|
||||
|
||||
if( cl.num_consistency >= MAX_MODELS )
|
||||
Host_Error( "%s: MAX_MODELS limit exceeded (%d)\n", __func__, MAX_MODELS );
|
||||
Host_Error( "CL_CheckConsistency: MAX_MODELS limit exceeded (%d)\n", MAX_MODELS );
|
||||
|
||||
pc = &cl.consistency_list[cl.num_consistency];
|
||||
cl.num_consistency++;
|
||||
|
@ -1747,7 +1739,7 @@ CL_ParseResourceList
|
|||
|
||||
==============
|
||||
*/
|
||||
static void CL_ParseResourceList( sizebuf_t *msg )
|
||||
void CL_ParseResourceList( sizebuf_t *msg )
|
||||
{
|
||||
resource_t *pResource;
|
||||
int i, total;
|
||||
|
@ -1784,12 +1776,12 @@ CL_ParseVoiceInit
|
|||
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseVoiceInit( sizebuf_t *msg )
|
||||
void CL_ParseVoiceInit( sizebuf_t *msg )
|
||||
{
|
||||
char *pszCodec = MSG_ReadString( msg );
|
||||
int quality = MSG_ReadByte( msg );
|
||||
|
||||
Voice_Init( pszCodec, quality, false ); // init requested codec and the device
|
||||
Voice_Init( pszCodec, quality );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1798,7 +1790,7 @@ CL_ParseVoiceData
|
|||
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseVoiceData( sizebuf_t *msg )
|
||||
void CL_ParseVoiceData( sizebuf_t *msg )
|
||||
{
|
||||
int size, idx, frames;
|
||||
byte received[8192];
|
||||
|
@ -1844,10 +1836,13 @@ void CL_ParseResLocation( sizebuf_t *msg )
|
|||
return;
|
||||
}
|
||||
|
||||
while(( data = COM_ParseFile( data, token, sizeof( token ))))
|
||||
while( ( data = COM_ParseFile( data, token, sizeof( token ) ) ) )
|
||||
{
|
||||
Con_Reportf( "Adding %s as download location\n", token );
|
||||
cl.http_download = true;
|
||||
|
||||
if( !cl.downloadUrl[0] )
|
||||
Q_strncpy( cl.downloadUrl, token, sizeof( token ) );
|
||||
|
||||
HTTP_AddCustomServer( token );
|
||||
}
|
||||
}
|
||||
|
@ -1878,12 +1873,8 @@ void CL_ParseHLTV( sizebuf_t *msg )
|
|||
break;
|
||||
case HLTV_LISTEN:
|
||||
cls.signon = SIGNONS;
|
||||
#if 1
|
||||
MSG_ReadString( msg );
|
||||
#else
|
||||
NET_StringToAdr( MSG_ReadString( msg ), &cls.hltv_listen_address );
|
||||
NET_JoinGroup( cls.netchan.sock, cls.hltv_listen_address );
|
||||
#endif
|
||||
// NET_JoinGroup( cls.netchan.sock, cls.hltv_listen_address );
|
||||
SCR_EndLoadingPlaque();
|
||||
break;
|
||||
default:
|
||||
|
@ -1916,7 +1907,7 @@ CL_ParseScreenShake
|
|||
Set screen shake
|
||||
==============
|
||||
*/
|
||||
static void CL_ParseScreenShake( sizebuf_t *msg )
|
||||
void CL_ParseScreenShake( sizebuf_t *msg )
|
||||
{
|
||||
float amplitude = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 ));
|
||||
float duration = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 ));
|
||||
|
@ -1939,7 +1930,7 @@ CL_ParseScreenFade
|
|||
Set screen fade
|
||||
==============
|
||||
*/
|
||||
static void CL_ParseScreenFade( sizebuf_t *msg )
|
||||
void CL_ParseScreenFade( sizebuf_t *msg )
|
||||
{
|
||||
float duration, holdTime;
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
|
@ -1993,7 +1984,7 @@ Find the client cvar value
|
|||
and sent it back to the server
|
||||
==============
|
||||
*/
|
||||
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto )
|
||||
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext )
|
||||
{
|
||||
const char *cvarName, *response;
|
||||
convar_t *cvar;
|
||||
|
@ -2016,14 +2007,7 @@ void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t
|
|||
else
|
||||
response = cvar->string;
|
||||
}
|
||||
else if( proto == PROTO_LEGACY )
|
||||
{
|
||||
response = "Not Found";
|
||||
}
|
||||
else
|
||||
{
|
||||
response = "Bad CVAR request";
|
||||
}
|
||||
else response = "Bad CVAR request";
|
||||
|
||||
if( ext )
|
||||
{
|
||||
|
@ -2045,7 +2029,7 @@ CL_ParseExec
|
|||
Exec map/class specific configs
|
||||
==============
|
||||
*/
|
||||
static void CL_ParseExec( sizebuf_t *msg )
|
||||
void CL_ParseExec( sizebuf_t *msg )
|
||||
{
|
||||
qboolean is_class;
|
||||
int class_idx;
|
||||
|
@ -2140,7 +2124,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
|||
if( svc_num <= svc_lastmsg || svc_num > ( MAX_USER_MESSAGES + svc_lastmsg ))
|
||||
{
|
||||
// out or range
|
||||
Host_Error( "%s: illegible server message %d\n", __func__, svc_num );
|
||||
Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2152,7 +2136,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
|||
}
|
||||
|
||||
if( i == MAX_USER_MESSAGES ) // probably unregistered
|
||||
Host_Error( "%s: illegible server message %d\n", __func__, svc_num );
|
||||
Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num );
|
||||
|
||||
// NOTE: some user messages handled into engine
|
||||
if( !Q_strcmp( clgame.msg[i].name, "ScreenShake" ))
|
||||
|
@ -2178,7 +2162,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
|||
|
||||
if( iSize >= MAX_USERMSG_LENGTH )
|
||||
{
|
||||
Con_Reportf( "%s: user message %s size limit hit (%d > %d)!\n", __func__, clgame.msg[i].name, iSize, MAX_USERMSG_LENGTH );
|
||||
Msg("WTF??? %d %d\n", i, svc_num );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2207,7 +2191,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
|||
}
|
||||
else
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: No pfn %s %d\n", __func__, clgame.msg[i].name, clgame.msg[i].number );
|
||||
Con_DPrintf( S_ERROR "UserMsg: No pfn %s %d\n", clgame.msg[i].name, clgame.msg[i].number );
|
||||
clgame.msg[i].func = CL_UserMsgStub; // throw warning only once
|
||||
}
|
||||
}
|
||||
|
@ -2226,19 +2210,36 @@ CL_ParseServerMessage
|
|||
dispatch messages
|
||||
=====================
|
||||
*/
|
||||
void CL_ParseServerMessage( sizebuf_t *msg )
|
||||
void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
|
||||
{
|
||||
size_t bufStart, playerbytes;
|
||||
int cmd, param1, param2;
|
||||
int old_background;
|
||||
const char *s;
|
||||
|
||||
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
|
||||
CL_Parse_Debug( true ); // begin parsing
|
||||
|
||||
if( normal_message )
|
||||
{
|
||||
// assume no entity/player update this packet
|
||||
if( cls.state == ca_active )
|
||||
{
|
||||
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
|
||||
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
|
||||
}
|
||||
}
|
||||
|
||||
// parse the message
|
||||
while( 1 )
|
||||
{
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
{
|
||||
Host_Error( "%s: overflow!\n", __func__ );
|
||||
Host_Error( "CL_ParseServerMessage: overflow!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2324,18 +2325,11 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
|||
break;
|
||||
case svc_stufftext:
|
||||
s = MSG_ReadString( msg );
|
||||
if( cl_trace_stufftext.value )
|
||||
{
|
||||
size_t len = Q_strlen( s );
|
||||
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
|
||||
}
|
||||
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
// disable Cry Of Fear antisave protection
|
||||
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
|
||||
break; // too early
|
||||
#endif
|
||||
|
||||
Cbuf_AddFilteredText( s );
|
||||
break;
|
||||
case svc_setangle:
|
||||
|
@ -2483,10 +2477,10 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
|||
CL_ParseResLocation( msg );
|
||||
break;
|
||||
case svc_querycvarvalue:
|
||||
CL_ParseCvarValue( msg, false, PROTO_CURRENT );
|
||||
CL_ParseCvarValue( msg, false );
|
||||
break;
|
||||
case svc_querycvarvalue2:
|
||||
CL_ParseCvarValue( msg, true, PROTO_CURRENT );
|
||||
CL_ParseCvarValue( msg, true );
|
||||
break;
|
||||
case svc_exec:
|
||||
CL_ParseExec( msg );
|
||||
|
@ -2497,4 +2491,21 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
|
||||
CL_Parse_Debug( false ); // done
|
||||
|
||||
// we don't know if it is ok to save a demo message until
|
||||
// after we have parsed the frame
|
||||
if( !cls.demoplayback )
|
||||
{
|
||||
if( cls.demorecording && !cls.demowaiting )
|
||||
{
|
||||
CL_WriteDemoMessage( false, cls.starting_count, msg );
|
||||
}
|
||||
else if( cls.state != ca_active )
|
||||
{
|
||||
CL_WriteDemoMessage( true, cls.starting_count, msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ CL_ParseStaticEntity
|
|||
static client entity
|
||||
==================
|
||||
*/
|
||||
static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
|
||||
void CL_LegacyParseStaticEntity( sizebuf_t *msg )
|
||||
{
|
||||
int i;
|
||||
entity_state_t state;
|
||||
|
@ -98,7 +98,7 @@ static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
|
|||
R_AddEfrags( ent ); // add link
|
||||
}
|
||||
|
||||
static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
|
||||
void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
|
||||
{
|
||||
vec3_t pos;
|
||||
int chan, sound;
|
||||
|
@ -167,14 +167,14 @@ CL_PrecacheSound
|
|||
prceache sound from server
|
||||
================
|
||||
*/
|
||||
static void CL_LegacyPrecacheSound( sizebuf_t *msg )
|
||||
void CL_LegacyPrecacheSound( sizebuf_t *msg )
|
||||
{
|
||||
int soundIndex;
|
||||
|
||||
soundIndex = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
|
||||
|
||||
if( soundIndex < 0 || soundIndex >= MAX_SOUNDS )
|
||||
Host_Error( "%s: bad soundindex %i\n", __func__, soundIndex );
|
||||
Host_Error( "CL_PrecacheSound: bad soundindex %i\n", soundIndex );
|
||||
|
||||
Q_strncpy( cl.sound_precache[soundIndex], MSG_ReadString( msg ), sizeof( cl.sound_precache[0] ));
|
||||
|
||||
|
@ -184,7 +184,7 @@ static void CL_LegacyPrecacheSound( sizebuf_t *msg )
|
|||
cl.sound_index[soundIndex] = S_RegisterSound( cl.sound_precache[soundIndex] );
|
||||
}
|
||||
|
||||
static void CL_LegacyPrecacheModel( sizebuf_t *msg )
|
||||
void CL_LegacyPrecacheModel( sizebuf_t *msg )
|
||||
{
|
||||
int modelIndex;
|
||||
string model;
|
||||
|
@ -192,9 +192,9 @@ static void CL_LegacyPrecacheModel( sizebuf_t *msg )
|
|||
modelIndex = MSG_ReadUBitLong( msg, MAX_LEGACY_MODEL_BITS );
|
||||
|
||||
if( modelIndex < 0 || modelIndex >= MAX_MODELS )
|
||||
Host_Error( "%s: bad modelindex %i\n", __func__, modelIndex );
|
||||
Host_Error( "CL_PrecacheModel: bad modelindex %i\n", modelIndex );
|
||||
|
||||
Q_strncpy( model, MSG_ReadString( msg ), sizeof( model ));
|
||||
Q_strncpy( model, MSG_ReadString( msg ), MAX_STRING );
|
||||
//Q_strncpy( cl.model_precache[modelIndex], BF_ReadString( msg ), sizeof( cl.model_precache[0] ));
|
||||
|
||||
// when we loading map all resources is precached sequentially
|
||||
|
@ -214,14 +214,14 @@ static void CL_LegacyPrecacheModel( sizebuf_t *msg )
|
|||
cl.nummodels = Q_max( cl.nummodels, modelIndex );
|
||||
}
|
||||
|
||||
static void CL_LegacyPrecacheEvent( sizebuf_t *msg )
|
||||
void CL_LegacyPrecacheEvent( sizebuf_t *msg )
|
||||
{
|
||||
int eventIndex;
|
||||
|
||||
eventIndex = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||
|
||||
if( eventIndex < 0 || eventIndex >= MAX_EVENTS )
|
||||
Host_Error( "%s: bad eventindex %i\n", __func__, eventIndex );
|
||||
Host_Error( "CL_PrecacheEvent: bad eventindex %i\n", eventIndex );
|
||||
|
||||
Q_strncpy( cl.event_precache[eventIndex], MSG_ReadString( msg ), sizeof( cl.event_precache[0] ));
|
||||
|
||||
|
@ -242,7 +242,7 @@ CL_ParseResourceList
|
|||
|
||||
==============
|
||||
*/
|
||||
static void CL_LegacyParseResourceList( sizebuf_t *msg )
|
||||
void CL_LegacyParseResourceList( sizebuf_t *msg )
|
||||
{
|
||||
int i = 0;
|
||||
static struct
|
||||
|
@ -256,15 +256,15 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg )
|
|||
reslist.rescount = MSG_ReadWord( msg ) - 1;
|
||||
|
||||
if( reslist.rescount > MAX_LEGACY_RESOURCES )
|
||||
Host_Error( "MAX_RESOURCES reached\n" );
|
||||
Host_Error("MAX_RESOURCES reached\n");
|
||||
|
||||
for( i = 0; i < reslist.rescount; i++ )
|
||||
{
|
||||
reslist.restype[i] = MSG_ReadWord( msg );
|
||||
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), sizeof( reslist.resnames[i] ));
|
||||
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), MAX_QPATH );
|
||||
}
|
||||
|
||||
if( cls.demoplayback )
|
||||
if( CL_IsPlaybackDemo() )
|
||||
return;
|
||||
|
||||
if( !cl_allow_download.value )
|
||||
|
@ -317,19 +317,36 @@ CL_ParseLegacyServerMessage
|
|||
dispatch messages
|
||||
=====================
|
||||
*/
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
|
||||
{
|
||||
size_t bufStart, playerbytes;
|
||||
int cmd, param1, param2;
|
||||
int old_background;
|
||||
const char *s;
|
||||
|
||||
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
|
||||
CL_Parse_Debug( true ); // begin parsing
|
||||
|
||||
if( normal_message )
|
||||
{
|
||||
// assume no entity/player update this packet
|
||||
if( cls.state == ca_active )
|
||||
{
|
||||
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
|
||||
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
|
||||
}
|
||||
}
|
||||
|
||||
// parse the message
|
||||
while( 1 )
|
||||
{
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
{
|
||||
Host_Error( "%s: overflow!\n", __func__ );
|
||||
Host_Error( "CL_ParseServerMessage: overflow!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -426,17 +443,13 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
|||
break;
|
||||
case svc_stufftext:
|
||||
s = MSG_ReadString( msg );
|
||||
if( cl_trace_stufftext.value )
|
||||
{
|
||||
size_t len = Q_strlen( s );
|
||||
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
|
||||
}
|
||||
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
// disable Cry Of Fear antisave protection
|
||||
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
|
||||
break; // too early
|
||||
#endif
|
||||
|
||||
Con_Reportf( "Stufftext: %s", s );
|
||||
Cbuf_AddFilteredText( s );
|
||||
break;
|
||||
case svc_setangle:
|
||||
|
@ -595,10 +608,10 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
|||
CL_ParseResLocation( msg );
|
||||
break;
|
||||
case svc_querycvarvalue:
|
||||
CL_ParseCvarValue( msg, false, PROTO_LEGACY );
|
||||
CL_ParseCvarValue( msg, false );
|
||||
break;
|
||||
case svc_querycvarvalue2:
|
||||
CL_ParseCvarValue( msg, true, PROTO_LEGACY );
|
||||
CL_ParseCvarValue( msg, true );
|
||||
break;
|
||||
default:
|
||||
CL_ParseUserMessage( msg, cmd );
|
||||
|
@ -606,6 +619,23 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
|
||||
CL_Parse_Debug( false ); // done
|
||||
|
||||
// we don't know if it is ok to save a demo message until
|
||||
// after we have parsed the frame
|
||||
if( !cls.demoplayback )
|
||||
{
|
||||
if( cls.demorecording && !cls.demowaiting )
|
||||
{
|
||||
CL_WriteDemoMessage( false, cls.starting_count, msg );
|
||||
}
|
||||
else if( cls.state != ca_active )
|
||||
{
|
||||
CL_WriteDemoMessage( true, cls.starting_count, msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CL_LegacyPrecache_f( void )
|
||||
|
@ -630,8 +660,8 @@ void CL_LegacyPrecache_f( void )
|
|||
if( clgame.entities )
|
||||
clgame.entities->model = cl.worldmodel;
|
||||
|
||||
// load skybox
|
||||
R_SetupSky( clgame.movevars.skyName );
|
||||
// update the ref state.
|
||||
R_UpdateRefState ();
|
||||
|
||||
// tell rendering system we have a new set of models.
|
||||
ref.dllFuncs.R_NewMap ();
|
||||
|
@ -671,5 +701,5 @@ void CL_LegacyUpdateInfo( void )
|
|||
|
||||
qboolean CL_LegacyMode( void )
|
||||
{
|
||||
return cls.legacymode == PROTO_LEGACY;
|
||||
return cls.legacymode;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,31 @@ void GAME_EXPORT CL_PopPMStates( void )
|
|||
clgame.pushed = false;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_PushTraceBounds
|
||||
|
||||
=============
|
||||
*/
|
||||
void GAME_EXPORT CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs )
|
||||
{
|
||||
hullnum = bound( 0, hullnum, 3 );
|
||||
VectorCopy( mins, clgame.pmove->player_mins[hullnum] );
|
||||
VectorCopy( maxs, clgame.pmove->player_maxs[hullnum] );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_PopTraceBounds
|
||||
|
||||
=============
|
||||
*/
|
||||
void GAME_EXPORT CL_PopTraceBounds( void )
|
||||
{
|
||||
memcpy( clgame.pmove->player_mins, host.player_mins, sizeof( host.player_mins ));
|
||||
memcpy( clgame.pmove->player_maxs, host.player_maxs, sizeof( host.player_maxs ));
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_IsPredicted
|
||||
|
@ -392,7 +417,7 @@ CL_AddLinksToPmove
|
|||
collect solid entities
|
||||
====================
|
||||
*/
|
||||
static void CL_AddLinksToPmove( frame_t *frame )
|
||||
void CL_AddLinksToPmove( frame_t *frame )
|
||||
{
|
||||
entity_state_t *state;
|
||||
model_t *model;
|
||||
|
@ -662,6 +687,11 @@ cl_entity_t *CL_GetWaterEntity( const float *rgflPos )
|
|||
return CL_GetEntityByIndex( entnum );
|
||||
}
|
||||
|
||||
int GAME_EXPORT CL_TestLine( const vec3_t start, const vec3_t end, int flags )
|
||||
{
|
||||
return PM_TestLineExt( clgame.pmove, clgame.pmove->physents, clgame.pmove->numphysent, start, end, flags );
|
||||
}
|
||||
|
||||
static int GAME_EXPORT pfnTestPlayerPosition( float *pos, pmtrace_t *ptrace )
|
||||
{
|
||||
return PM_TestPlayerPosition( clgame.pmove, pos, ptrace, NULL );
|
||||
|
@ -794,16 +824,6 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
|
|||
cd = &from->client;
|
||||
|
||||
pmove->player_index = ps->number - 1;
|
||||
|
||||
// a1ba: workaround bug where the server refuse to send our local player in delta
|
||||
// cl.playernum, in theory, must be equal to our local player index anyway
|
||||
//
|
||||
// this might not be a real solution, since everything else will be bogus
|
||||
// but we need to properly run prediction and avoid potential memory
|
||||
// corruption
|
||||
if( pmove->player_index < 0 )
|
||||
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
|
||||
|
||||
pmove->multiplayer = (cl.maxclients > 1);
|
||||
pmove->runfuncs = runfuncs;
|
||||
pmove->time = time * 1000.0f;
|
||||
|
@ -853,10 +873,10 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
|
|||
VectorCopy( cd->vuser4, pmove->vuser4 );
|
||||
pmove->cmd = *ucmd; // copy current cmds
|
||||
|
||||
Q_strncpy( pmove->physinfo, cls.physinfo, sizeof( pmove->physinfo ));
|
||||
Q_strncpy( pmove->physinfo, cls.physinfo, MAX_INFO_STRING );
|
||||
}
|
||||
|
||||
static const void CL_FinishPMove( const playermove_t *pmove, local_state_t *to )
|
||||
const void CL_FinishPMove( const playermove_t *pmove, local_state_t *to )
|
||||
{
|
||||
entity_state_t *ps;
|
||||
clientdata_t *cd;
|
||||
|
@ -909,7 +929,7 @@ CL_RunUsercmd
|
|||
Runs prediction code for user cmd
|
||||
=================
|
||||
*/
|
||||
static void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboolean runfuncs, double *time, unsigned int random_seed )
|
||||
void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboolean runfuncs, double *time, unsigned int random_seed )
|
||||
{
|
||||
usercmd_t cmd;
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
|||
clgame.maxEntities = GI->max_edicts;
|
||||
clgame.maxEntities = bound( 600, clgame.maxEntities, MAX_EDICTS );
|
||||
clgame.maxModels = MAX_MODELS;
|
||||
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
|
||||
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), MAX_STRING );
|
||||
|
||||
// Re-init hud video, especially if we changed game directories
|
||||
clgame.dllFuncs.pfnVidInit();
|
||||
|
@ -414,7 +414,7 @@ If an entities model or origin changes from frame to frame, it must be
|
|||
relinked. Other attributes can change without relinking.
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
|
||||
void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
|
||||
{
|
||||
int i, newnum, pack;
|
||||
qboolean forcelink;
|
||||
|
@ -565,7 +565,7 @@ CL_ParseQuakeParticles
|
|||
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseQuakeParticle( sizebuf_t *msg )
|
||||
void CL_ParseQuakeParticle( sizebuf_t *msg )
|
||||
{
|
||||
int count, color;
|
||||
vec3_t org, dir;
|
||||
|
@ -587,7 +587,7 @@ CL_ParseQuakeStaticSound
|
|||
|
||||
===================
|
||||
*/
|
||||
static void CL_ParseQuakeStaticSound( sizebuf_t *msg )
|
||||
void CL_ParseQuakeStaticSound( sizebuf_t *msg )
|
||||
{
|
||||
int sound_num;
|
||||
float vol, attn;
|
||||
|
@ -620,11 +620,11 @@ static void CL_ParseQuakeDamage( sizebuf_t *msg )
|
|||
|
||||
/*
|
||||
===================
|
||||
CL_ParseStaticEntity
|
||||
CL_ParseQuakeStaticEntity
|
||||
|
||||
===================
|
||||
*/
|
||||
static void CL_ParseStaticEntity( sizebuf_t *msg )
|
||||
static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
|
||||
{
|
||||
entity_state_t state;
|
||||
cl_entity_t *ent;
|
||||
|
@ -646,7 +646,7 @@ static void CL_ParseStaticEntity( sizebuf_t *msg )
|
|||
i = clgame.numStatics;
|
||||
if( i >= MAX_STATIC_ENTITIES )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: static entities limit exceeded!\n", __func__ );
|
||||
Con_Printf( S_ERROR "CL_ParseStaticEntity: static entities limit exceeded!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -697,7 +697,7 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
|
|||
newnum = MSG_ReadWord( msg ); // entnum
|
||||
|
||||
if( newnum >= clgame.maxEntities )
|
||||
Host_Error( "%s: no free edicts\n", __func__ );
|
||||
Host_Error( "CL_AllocEdict: no free edicts\n" );
|
||||
|
||||
// parse baseline
|
||||
memset( &state, 0, sizeof( state ));
|
||||
|
@ -778,7 +778,7 @@ static void CL_ParseQuakeSignon( sizebuf_t *msg )
|
|||
int i = MSG_ReadByte( msg );
|
||||
|
||||
if( i == 3 ) cls.signon = SIGNONS - 1;
|
||||
Con_Reportf( "%s: %d\n", __func__, i );
|
||||
Con_Reportf( "CL_Signon: %d\n", i );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -816,7 +816,7 @@ CL_QuakeStuffText
|
|||
|
||||
==================
|
||||
*/
|
||||
static void CL_QuakeStuffText( const char *text )
|
||||
void CL_QuakeStuffText( const char *text )
|
||||
{
|
||||
Q_strncat( cmd_buf, text, sizeof( cmd_buf ));
|
||||
|
||||
|
@ -831,7 +831,7 @@ CL_QuakeExecStuff
|
|||
|
||||
==================
|
||||
*/
|
||||
static void CL_QuakeExecStuff( void )
|
||||
void CL_QuakeExecStuff( void )
|
||||
{
|
||||
char *text = cmd_buf;
|
||||
char token[256];
|
||||
|
@ -844,7 +844,7 @@ static void CL_QuakeExecStuff( void )
|
|||
while( 1 )
|
||||
{
|
||||
// skip whitespace up to a /n
|
||||
while( *text && ((byte)*text ) <= ' ' && *text != '\r' && *text != '\n' )
|
||||
while( *text && ((byte)*text) <= ' ' && *text != '\r' && *text != '\n' )
|
||||
text++;
|
||||
|
||||
if( *text == '\n' || *text == '\r' )
|
||||
|
@ -886,21 +886,38 @@ CL_ParseQuakeMessage
|
|||
|
||||
==================
|
||||
*/
|
||||
void CL_ParseQuakeMessage( sizebuf_t *msg )
|
||||
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message )
|
||||
{
|
||||
int cmd, param1, param2;
|
||||
size_t bufStart;
|
||||
const char *str;
|
||||
|
||||
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
|
||||
CL_Parse_Debug( true ); // begin parsing
|
||||
|
||||
// init excise buffer
|
||||
MSG_Init( &msg_demo, "UserMsg", msg_buf, sizeof( msg_buf ));
|
||||
|
||||
if( normal_message )
|
||||
{
|
||||
// assume no entity/player update this packet
|
||||
if( cls.state == ca_active )
|
||||
{
|
||||
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
|
||||
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
|
||||
}
|
||||
}
|
||||
|
||||
// parse the message
|
||||
while( 1 )
|
||||
{
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
{
|
||||
Host_Error( "%s: overflow!\n", __func__ );
|
||||
Host_Error( "CL_ParseServerMessage: overflow!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1022,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
|
|||
CL_ParseQuakeDamage( msg );
|
||||
break;
|
||||
case svc_spawnstatic:
|
||||
CL_ParseStaticEntity( msg );
|
||||
CL_ParseQuakeStaticEntity( msg );
|
||||
break;
|
||||
case svc_spawnbinary:
|
||||
// never used in Quake
|
||||
|
@ -1091,11 +1108,14 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Host_Error( "%s: Illegible server message\n", __func__ );
|
||||
Host_Error( "CL_ParseServerMessage: Illegible server message\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
|
||||
CL_Parse_Debug( false ); // done
|
||||
|
||||
// now process packet.
|
||||
CL_ProcessPacket( &cl.frames[cl.parsecountmod] );
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ CL_CreateRawTextureFromPixels
|
|||
Convert texture_t struct into mstudiotexture_t prototype
|
||||
====================
|
||||
*/
|
||||
static byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
{
|
||||
static mstudiotexture_t pin;
|
||||
byte *pal;
|
||||
|
@ -111,7 +111,7 @@ CL_DuplicateTexture
|
|||
Dupliacte texture with remap pixels
|
||||
====================
|
||||
*/
|
||||
static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
const char *name;
|
||||
texture_t *tx = NULL;
|
||||
|
@ -154,7 +154,7 @@ CL_UpdateStudioTexture
|
|||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
rgbdata_t *pic;
|
||||
texture_t *tx = NULL;
|
||||
|
@ -215,7 +215,7 @@ CL_UpdateAliasTexture
|
|||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
{
|
||||
char texname[MAX_QPATH];
|
||||
rgbdata_t skin, *pic;
|
||||
|
@ -247,68 +247,6 @@ static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture,
|
|||
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_AllocRemapInfo
|
||||
|
@ -317,7 +255,7 @@ Allocate new remap info per entity
|
|||
and make copy of remap textures
|
||||
====================
|
||||
*/
|
||||
static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
studiohdr_t *phdr;
|
||||
|
@ -424,6 +362,68 @@ static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor
|
|||
info->model = model;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_ClearAllRemaps
|
||||
|
@ -446,21 +446,3 @@ void CL_ClearAllRemaps( void )
|
|||
}
|
||||
clgame.remap_info = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_EntitySetRemapColors
|
||||
=============
|
||||
*/
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom )
|
||||
{
|
||||
CL_AllocRemapInfo( e, mod, top, bottom );
|
||||
|
||||
if( CL_GetRemapInfoForEntity( e ))
|
||||
{
|
||||
CL_UpdateRemapInfo( e, top, bottom );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ GNU General Public License for more details.
|
|||
|
||||
int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis )
|
||||
{
|
||||
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis, false );
|
||||
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis );
|
||||
}
|
||||
|
||||
lightstyle_t *CL_GetLightStyle( int number )
|
||||
|
@ -126,7 +126,7 @@ CL_GenericHandle
|
|||
|
||||
=============
|
||||
*/
|
||||
static const char *CL_GenericHandle( int fileindex )
|
||||
const char *CL_GenericHandle( int fileindex )
|
||||
{
|
||||
if( fileindex < 0 || fileindex >= MAX_CUSTOM )
|
||||
return 0;
|
||||
|
@ -142,6 +142,8 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
|||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
case PARM_SKY_SPHERE:
|
||||
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
|
||||
case PARAM_GAMEPAUSED:
|
||||
return cl.paused;
|
||||
case PARM_CLIENT_INGAME:
|
||||
|
@ -170,12 +172,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
|||
return refState.width;
|
||||
case PARM_SCREEN_HEIGHT:
|
||||
return refState.height;
|
||||
case PARM_SKY_SPHERE:
|
||||
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
|
||||
case PARM_SURF_SAMPLESIZE:
|
||||
if( arg >= 0 && arg < cl.worldmodel->numsurfaces )
|
||||
return Mod_SampleSizeForFace( &cl.worldmodel->surfaces[arg] );
|
||||
return LM_SAMPLE_SIZE;
|
||||
default:
|
||||
// indicates call from client.dll
|
||||
if( checkRef )
|
||||
|
@ -191,30 +187,26 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
|||
return CL_IsThirdPerson();
|
||||
case PARM_QUAKE_COMPATIBLE:
|
||||
return Host_IsQuakeCompatible();
|
||||
case PARM_PLAYER_INDEX:
|
||||
return cl.playernum + 1;
|
||||
case PARM_VIEWENT_INDEX:
|
||||
return cl.viewentity;
|
||||
case PARM_CONNSTATE:
|
||||
return (int)cls.state;
|
||||
case PARM_PLAYING_DEMO:
|
||||
return cls.demoplayback;
|
||||
case PARM_WATER_LEVEL:
|
||||
return cl.local.waterlevel;
|
||||
case PARM_MAX_CLIENTS:
|
||||
return cl.maxclients;
|
||||
case PARM_LOCAL_HEALTH:
|
||||
return cl.local.health;
|
||||
case PARM_LOCAL_GAME:
|
||||
return Host_IsLocalGame();
|
||||
case PARM_NUMENTITIES:
|
||||
return pfnNumberOfEntities();
|
||||
case PARM_GET_CLIENT_PTR:
|
||||
return (intptr_t)&cl.time; // with the offset
|
||||
case PARM_GET_HOST_PTR:
|
||||
return (intptr_t)&host.realtime; // with the offset
|
||||
case PARM_GET_WORLD_PTR:
|
||||
return (intptr_t)&world;
|
||||
case PARM_GET_MOVEVARS_PTR:
|
||||
return (intptr_t)&clgame.movevars;
|
||||
case PARM_GET_PALETTE_PTR:
|
||||
return (intptr_t)&clgame.palette;
|
||||
case PARM_GET_VIEWENT_PTR:
|
||||
return (intptr_t)&clgame.viewent;
|
||||
case PARM_NUMMODELS:
|
||||
return cl.nummodels;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -347,7 +339,7 @@ qboolean R_InitRenderAPI( void )
|
|||
{
|
||||
if( clgame.dllFuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &clgame.drawFuncs ))
|
||||
{
|
||||
Con_Reportf( "%s: ^2initailized extended RenderAPI ^7ver. %i\n", __func__, CL_RENDER_INTERFACE_VERSION );
|
||||
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" );
|
|||
CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" );
|
||||
CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" );
|
||||
CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" );
|
||||
CVAR_DEFINE_AUTO( cl_testlights, "0", FCVAR_CHEAT, "test dynamic lights" );
|
||||
CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" );
|
||||
CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
|
||||
CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" );
|
||||
static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" );
|
||||
|
@ -32,7 +32,6 @@ CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" );
|
|||
static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" );
|
||||
static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" );
|
||||
static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" );
|
||||
static CVAR_DEFINE_AUTO( cl_showents, "0", FCVAR_ARCHIVE | FCVAR_CHEAT, "show entities information (largely undone)" );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -123,7 +122,7 @@ void SCR_DrawPos( void )
|
|||
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
||||
return;
|
||||
|
||||
ent = CL_EDICT_NUM( cl.playernum + 1 );
|
||||
ent = CL_GetLocalPlayer();
|
||||
speed = VectorLength( cl.simvel );
|
||||
|
||||
Q_snprintf( msg, MAX_SYSPATH,
|
||||
|
@ -141,68 +140,6 @@ void SCR_DrawPos( void )
|
|||
Con_DrawString( refState.width / 2, 4, msg, color );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_DrawEnts
|
||||
==============
|
||||
*/
|
||||
void SCR_DrawEnts( void )
|
||||
{
|
||||
rgba_t color = { 255, 255, 255, 255 };
|
||||
int i;
|
||||
|
||||
if( cls.state != ca_active || !cl_showents.value || ( cl.maxclients > 1 && !cls.demoplayback ))
|
||||
return;
|
||||
|
||||
// this probably better hook CL_AddVisibleEntities
|
||||
// as entities might get added by client.dll
|
||||
for( i = 0; i < clgame.maxEntities; i++ )
|
||||
{
|
||||
const cl_entity_t *ent = &clgame.entities[i];
|
||||
string msg;
|
||||
vec3_t screen, pos;
|
||||
|
||||
if( ent->curstate.messagenum != cl.parsecount )
|
||||
continue;
|
||||
|
||||
VectorCopy( ent->origin, pos );
|
||||
|
||||
if( ent->model != NULL )
|
||||
{
|
||||
vec3_t v;
|
||||
|
||||
// simple model type filter
|
||||
if( cl_showents.value > 1 )
|
||||
{
|
||||
if( ent->model->type != (modtype_t)( cl_showents.value - 2 ))
|
||||
continue;
|
||||
}
|
||||
|
||||
VectorAverage( ent->model->mins, ent->model->maxs, v );
|
||||
VectorAdd( pos, v, pos );
|
||||
}
|
||||
|
||||
if( !ref.dllFuncs.WorldToScreen( pos, screen ))
|
||||
{
|
||||
Q_snprintf( msg, sizeof( msg ),
|
||||
"entity %d\n"
|
||||
"model %s\n"
|
||||
"movetype %d\n",
|
||||
ent->index,
|
||||
ent->model ? ent->model->name : "(null)",
|
||||
ent->curstate.movetype );
|
||||
|
||||
screen[0] = 0.5f * screen[0] * refState.width;
|
||||
screen[1] = -0.5f * screen[1] * refState.height;
|
||||
screen[0] += 0.5f * refState.width;
|
||||
screen[1] += 0.5f * refState.height;
|
||||
|
||||
|
||||
Con_DrawString( screen[0], screen[1], msg, color );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_NetSpeeds
|
||||
|
@ -315,7 +252,7 @@ VID_WriteOverviewScript
|
|||
Create overview script file
|
||||
===============
|
||||
*/
|
||||
static void VID_WriteOverviewScript( void )
|
||||
void VID_WriteOverviewScript( void )
|
||||
{
|
||||
ref_overview_t *ov = &clgame.overView;
|
||||
string filename;
|
||||
|
@ -351,15 +288,10 @@ void SCR_MakeScreenShot( void )
|
|||
qboolean iRet = false;
|
||||
int viewsize;
|
||||
|
||||
if( cls.scrshot_action == scrshot_inactive )
|
||||
return;
|
||||
|
||||
if( cls.envshot_viewsize > 0 )
|
||||
viewsize = cls.envshot_viewsize;
|
||||
else viewsize = cl_envshot_size.value;
|
||||
|
||||
V_CheckGamma();
|
||||
|
||||
switch( cls.scrshot_action )
|
||||
{
|
||||
case scrshot_normal:
|
||||
|
@ -385,6 +317,8 @@ void SCR_MakeScreenShot( void )
|
|||
if( iRet )
|
||||
VID_WriteOverviewScript(); // store overview script too
|
||||
break;
|
||||
case scrshot_inactive:
|
||||
return;
|
||||
}
|
||||
|
||||
// report
|
||||
|
@ -408,7 +342,7 @@ void SCR_MakeScreenShot( void )
|
|||
SCR_DrawPlaque
|
||||
================
|
||||
*/
|
||||
static void SCR_DrawPlaque( void )
|
||||
void SCR_DrawPlaque( void )
|
||||
{
|
||||
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background )
|
||||
{
|
||||
|
@ -479,7 +413,7 @@ void SCR_EndLoadingPlaque( void )
|
|||
SCR_AddDirtyPoint
|
||||
=================
|
||||
*/
|
||||
static void SCR_AddDirtyPoint( int x, int y )
|
||||
void SCR_AddDirtyPoint( int x, int y )
|
||||
{
|
||||
if( x < scr_dirty.x1 ) scr_dirty.x1 = x;
|
||||
if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
|
||||
|
@ -606,7 +540,7 @@ void SCR_UpdateScreen( void )
|
|||
SCR_DrawCinematic();
|
||||
break;
|
||||
default:
|
||||
Host_Error( "%s: bad cls.state\n", __func__ );
|
||||
Host_Error( "SCR_UpdateScreen: bad cls.state\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -636,15 +570,15 @@ void SCR_LoadCreditsFont( void )
|
|||
"creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 )
|
||||
{
|
||||
if( FS_FileExists( charsetFnt, false ))
|
||||
success = Con_LoadVariableWidthFont( charsetFnt, font, scale, &hud_fontrender, TF_FONT );
|
||||
success = Con_LoadVariableWidthFont( charsetFnt, font, scale, kRenderTransAdd, TF_FONT );
|
||||
}
|
||||
}
|
||||
|
||||
if( !success )
|
||||
success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, &hud_fontrender, TF_FONT );
|
||||
success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, kRenderTransAdd, TF_FONT );
|
||||
|
||||
if( !success )
|
||||
success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, &hud_fontrender, TF_FONT );
|
||||
success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransAdd, TF_FONT );
|
||||
|
||||
// copy font size for client.dll
|
||||
if( success )
|
||||
|
@ -666,7 +600,7 @@ SCR_InstallParticlePalette
|
|||
INTERNAL RESOURCE
|
||||
================
|
||||
*/
|
||||
static void SCR_InstallParticlePalette( void )
|
||||
void SCR_InstallParticlePalette( void )
|
||||
{
|
||||
rgbdata_t *pic;
|
||||
int i;
|
||||
|
@ -712,21 +646,21 @@ void SCR_RegisterTextures( void )
|
|||
// register gfx.wad images
|
||||
|
||||
if( FS_FileExists( "gfx/paused.lmp", false ))
|
||||
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
|
||||
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
|
||||
else if( FS_FileExists( "gfx/pause.lmp", false ))
|
||||
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
|
||||
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
|
||||
|
||||
if( FS_FileExists( "gfx/lambda.lmp", false ))
|
||||
{
|
||||
if( cl_allow_levelshots.value )
|
||||
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|TF_ALLOW_NEAREST );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
|
||||
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
else if( FS_FileExists( "gfx/loading.lmp", false ))
|
||||
{
|
||||
if( cl_allow_levelshots.value )
|
||||
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|TF_ALLOW_NEAREST );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
|
||||
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
|
||||
cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
|
||||
|
@ -739,7 +673,7 @@ SCR_SizeUp_f
|
|||
Keybinding command
|
||||
=================
|
||||
*/
|
||||
static void SCR_SizeUp_f( void )
|
||||
void SCR_SizeUp_f( void )
|
||||
{
|
||||
Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 ));
|
||||
}
|
||||
|
@ -752,7 +686,7 @@ SCR_SizeDown_f
|
|||
Keybinding command
|
||||
=================
|
||||
*/
|
||||
static void SCR_SizeDown_f( void )
|
||||
void SCR_SizeDown_f( void )
|
||||
{
|
||||
Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 ));
|
||||
}
|
||||
|
@ -816,9 +750,6 @@ void SCR_Init( void )
|
|||
Cvar_RegisterVariable( &net_speeds );
|
||||
Cvar_RegisterVariable( &cl_showfps );
|
||||
Cvar_RegisterVariable( &cl_showpos );
|
||||
#ifdef _DEBUG
|
||||
Cvar_RegisterVariable( &cl_showents );
|
||||
#endif // NDEBUG
|
||||
|
||||
// register our commands
|
||||
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
|
||||
|
|
|
@ -57,7 +57,35 @@ const char *cl_default_sprites[] =
|
|||
"sprites/shellchrome.spr",
|
||||
};
|
||||
|
||||
static void CL_PlayerDecal( int playerIndex, int textureIndex, int entityIndex, float *pos );
|
||||
const char *cl_player_shell_sounds[] =
|
||||
{
|
||||
"player/pl_shell1.wav",
|
||||
"player/pl_shell2.wav",
|
||||
"player/pl_shell3.wav",
|
||||
};
|
||||
|
||||
const char *cl_weapon_shell_sounds[] =
|
||||
{
|
||||
"weapons/sshell1.wav",
|
||||
"weapons/sshell2.wav",
|
||||
"weapons/sshell3.wav",
|
||||
};
|
||||
|
||||
const char *cl_ricochet_sounds[] =
|
||||
{
|
||||
"weapons/ric1.wav",
|
||||
"weapons/ric2.wav",
|
||||
"weapons/ric3.wav",
|
||||
"weapons/ric4.wav",
|
||||
"weapons/ric5.wav",
|
||||
};
|
||||
|
||||
const char *cl_explode_sounds[] =
|
||||
{
|
||||
"weapons/explode3.wav",
|
||||
"weapons/explode4.wav",
|
||||
"weapons/explode5.wav",
|
||||
};
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -118,7 +146,6 @@ client resources not precached by server
|
|||
*/
|
||||
void CL_AddClientResources( void )
|
||||
{
|
||||
const char *snd;
|
||||
char filepath[MAX_QPATH];
|
||||
int i;
|
||||
|
||||
|
@ -134,37 +161,37 @@ void CL_AddClientResources( void )
|
|||
}
|
||||
|
||||
// then check sounds
|
||||
for( i = 0; ( snd = SoundList_Get( BouncePlayerShell, i )); i++ )
|
||||
for( i = 0; i < ARRAYSIZE( cl_player_shell_sounds ); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_player_shell_sounds[i] );
|
||||
|
||||
if( !FS_FileExists( filepath, false ))
|
||||
CL_AddClientResource( snd, t_sound );
|
||||
CL_AddClientResource( cl_player_shell_sounds[i], t_sound );
|
||||
}
|
||||
|
||||
for( i = 0; ( snd = SoundList_Get( BounceWeaponShell, i )); i++ )
|
||||
for( i = 0; i < ARRAYSIZE( cl_weapon_shell_sounds ); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_weapon_shell_sounds[i] );
|
||||
|
||||
if( !FS_FileExists( filepath, false ))
|
||||
CL_AddClientResource( snd, t_sound );
|
||||
CL_AddClientResource( cl_weapon_shell_sounds[i], t_sound );
|
||||
}
|
||||
|
||||
for( i = 0; ( snd = SoundList_Get( Explode, i )); i++ )
|
||||
for( i = 0; i < ARRAYSIZE( cl_explode_sounds ); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_explode_sounds[i] );
|
||||
|
||||
if( !FS_FileExists( filepath, false ))
|
||||
CL_AddClientResource( snd, t_sound );
|
||||
CL_AddClientResource( cl_explode_sounds[i], t_sound );
|
||||
}
|
||||
|
||||
#if 0 // ric sounds was precached by server-side
|
||||
for( i = 0; ( snd = SoundList_Get( Ricochet, i )); i++ )
|
||||
for( i = 0; i < ARRAYSIZE( cl_ricochet_sounds ); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", cl_ricochet_sounds[i] );
|
||||
|
||||
if( !FS_FileExists( filepath, false ))
|
||||
CL_AddClientResource( snd, t_sound );
|
||||
CL_AddClientResource( cl_ricochet_sounds[i], t_sound );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -228,7 +255,7 @@ CL_PrepareTEnt
|
|||
set default values
|
||||
==============
|
||||
*/
|
||||
static void CL_PrepareTEnt( TEMPENTITY *pTemp, model_t *pmodel )
|
||||
void CL_PrepareTEnt( TEMPENTITY *pTemp, model_t *pmodel )
|
||||
{
|
||||
int frameCount = 0;
|
||||
int modelIndex = 0;
|
||||
|
@ -269,10 +296,10 @@ CL_TempEntPlaySound
|
|||
play collide sound
|
||||
==============
|
||||
*/
|
||||
static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
{
|
||||
float fvol;
|
||||
const char *soundname = NULL;
|
||||
char soundname[32];
|
||||
qboolean isshellcasing = false;
|
||||
int zvel;
|
||||
|
||||
|
@ -283,39 +310,36 @@ static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
|||
switch( pTemp->hitSound )
|
||||
{
|
||||
case BOUNCE_GLASS:
|
||||
soundname = SoundList_GetRandom( BounceGlass );
|
||||
Q_snprintf( soundname, sizeof( soundname ), "debris/glass%i.wav", COM_RandomLong( 1, 4 ));
|
||||
break;
|
||||
case BOUNCE_METAL:
|
||||
soundname = SoundList_GetRandom( BounceMetal );
|
||||
Q_snprintf( soundname, sizeof( soundname ), "debris/metal%i.wav", COM_RandomLong( 1, 6 ));
|
||||
break;
|
||||
case BOUNCE_FLESH:
|
||||
soundname = SoundList_GetRandom( BounceFlesh );
|
||||
Q_snprintf( soundname, sizeof( soundname ), "debris/flesh%i.wav", COM_RandomLong( 1, 7 ));
|
||||
break;
|
||||
case BOUNCE_WOOD:
|
||||
soundname = SoundList_GetRandom( BounceWood );
|
||||
Q_snprintf( soundname, sizeof( soundname ), "debris/wood%i.wav", COM_RandomLong( 1, 4 ));
|
||||
break;
|
||||
case BOUNCE_SHRAP:
|
||||
soundname = SoundList_GetRandom( Ricochet );
|
||||
Q_strncpy( soundname, cl_ricochet_sounds[COM_RandomLong( 0, 4 )], sizeof( soundname ) );
|
||||
break;
|
||||
case BOUNCE_SHOTSHELL:
|
||||
soundname = SoundList_GetRandom( BounceWeaponShell );
|
||||
Q_strncpy( soundname, cl_weapon_shell_sounds[COM_RandomLong( 0, 2 )], sizeof( soundname ) );
|
||||
isshellcasing = true; // shell casings have different playback parameters
|
||||
fvol = 0.5f;
|
||||
break;
|
||||
case BOUNCE_SHELL:
|
||||
soundname = SoundList_GetRandom( BouncePlayerShell );
|
||||
Q_strncpy( soundname, cl_player_shell_sounds[COM_RandomLong( 0, 2 )], sizeof( soundname ) );
|
||||
isshellcasing = true; // shell casings have different playback parameters
|
||||
break;
|
||||
case BOUNCE_CONCRETE:
|
||||
soundname = SoundList_GetRandom( BounceConcrete );
|
||||
Q_snprintf( soundname, sizeof( soundname ), "debris/concrete%i.wav", COM_RandomLong( 1, 3 ));
|
||||
break;
|
||||
default: // null sound
|
||||
return;
|
||||
}
|
||||
|
||||
if( !soundname )
|
||||
return;
|
||||
|
||||
zvel = abs( pTemp->entity.baseline.origin[2] );
|
||||
|
||||
// only play one out of every n
|
||||
|
@ -356,7 +380,7 @@ CL_TEntAddEntity
|
|||
add entity to renderlist
|
||||
==============
|
||||
*/
|
||||
static int CL_TempEntAddEntity( cl_entity_t *pEntity )
|
||||
int CL_TempEntAddEntity( cl_entity_t *pEntity )
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
|
||||
|
@ -408,7 +432,7 @@ CL_TEntAddEntity
|
|||
free the first low priority tempent it finds.
|
||||
==============
|
||||
*/
|
||||
static qboolean CL_FreeLowPriorityTempEnt( void )
|
||||
qboolean CL_FreeLowPriorityTempEnt( void )
|
||||
{
|
||||
TEMPENTITY *pActive = cl_active_tents;
|
||||
TEMPENTITY *pPrev = NULL;
|
||||
|
@ -1465,7 +1489,7 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
|
|||
===============
|
||||
R_SparkEffect
|
||||
|
||||
Create a streaks + ricochet sprite
|
||||
Create a streaks + richochet sprite
|
||||
===============
|
||||
*/
|
||||
void GAME_EXPORT R_SparkEffect( const vec3_t pos, int count, int velocityMin, int velocityMax )
|
||||
|
@ -1481,25 +1505,18 @@ R_RicochetSound
|
|||
Make a random ricochet sound
|
||||
==============
|
||||
*/
|
||||
static void R_RicochetSoundByName( const vec3_t pos, const char *name )
|
||||
static void R_RicochetSound_( const vec3_t pos, int sound )
|
||||
{
|
||||
sound_t handle;
|
||||
handle = S_RegisterSound( name );
|
||||
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
|
||||
}
|
||||
sound_t handle;
|
||||
|
||||
static void R_RicochetSoundByIndex( const vec3_t pos, int idx )
|
||||
{
|
||||
const char *name = SoundList_Get( Ricochet, idx );
|
||||
if( name )
|
||||
R_RicochetSoundByName( pos, name );
|
||||
handle = S_RegisterSound( cl_ricochet_sounds[sound] );
|
||||
|
||||
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
|
||||
}
|
||||
|
||||
void GAME_EXPORT R_RicochetSound( const vec3_t pos )
|
||||
{
|
||||
const char *name = SoundList_GetRandom( Ricochet );
|
||||
if( name )
|
||||
R_RicochetSoundByName( pos, name );
|
||||
R_RicochetSound_( pos, COM_RandomLong( 0, 4 ));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1646,12 +1663,8 @@ void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerat
|
|||
|
||||
if( !FBitSet( flags, TE_EXPLFLAG_NOSOUND ))
|
||||
{
|
||||
const char *name = SoundList_GetRandom( Explode );
|
||||
if( name )
|
||||
{
|
||||
hSound = S_RegisterSound( name );
|
||||
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.3f, PITCH_NORM, 0 );
|
||||
}
|
||||
hSound = S_RegisterSound( cl_explode_sounds[COM_RandomLong( 0, 2 )] );
|
||||
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.3f, PITCH_NORM, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1894,7 +1907,6 @@ void CL_ParseTempEntity( sizebuf_t *msg )
|
|||
cl_entity_t *pEnt;
|
||||
dlight_t *dl;
|
||||
sound_t hSound;
|
||||
const char *name;
|
||||
|
||||
if( cls.legacymode )
|
||||
iSize = MSG_ReadByte( msg );
|
||||
|
@ -1904,7 +1916,7 @@ void CL_ParseTempEntity( sizebuf_t *msg )
|
|||
|
||||
// this will probably be fatal anyway
|
||||
if( iSize > sizeof( pbuf ))
|
||||
Con_Printf( S_ERROR "%s: Temp buffer overflow!\n", __func__ );
|
||||
Con_Printf( S_ERROR "%s: Temp buffer overflow!\n", __FUNCTION__ );
|
||||
|
||||
// parse user message into buffer
|
||||
MSG_ReadBytes( msg, pbuf, iSize );
|
||||
|
@ -1954,11 +1966,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
|
|||
pos[2] = MSG_ReadCoord( &buf );
|
||||
R_BlobExplosion( pos );
|
||||
|
||||
if(( name = SoundList_Get( Explode, 0 )))
|
||||
{
|
||||
hSound = S_RegisterSound( name );
|
||||
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
|
||||
}
|
||||
hSound = S_RegisterSound( cl_explode_sounds[0] );
|
||||
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
|
||||
break;
|
||||
case TE_SMOKE:
|
||||
pos[0] = MSG_ReadCoord( &buf );
|
||||
|
@ -2011,11 +2020,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
|
|||
dl->die = cl.time + 0.5;
|
||||
dl->decay = 300;
|
||||
|
||||
if(( name = SoundList_Get( Explode, 0 )))
|
||||
{
|
||||
hSound = S_RegisterSound( name );
|
||||
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
|
||||
}
|
||||
hSound = S_RegisterSound( cl_explode_sounds[0] );
|
||||
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 0.6f, PITCH_NORM, 0 );
|
||||
break;
|
||||
case TE_BSPDECAL:
|
||||
case TE_DECAL:
|
||||
|
@ -2243,8 +2249,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
|
|||
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, 0, pos, 0 );
|
||||
R_BulletImpactParticles( pos );
|
||||
flags = COM_RandomLong( 0, 0x7fff );
|
||||
if( flags < 0x3fff && ( count = SoundList_Count( Ricochet )))
|
||||
R_RicochetSoundByIndex( pos, flags % count );
|
||||
if( flags < 0x3fff )
|
||||
R_RicochetSound_( pos, flags % 5 );
|
||||
break;
|
||||
case TE_SPRAY:
|
||||
case TE_SPRITE_SPRAY:
|
||||
|
@ -2384,13 +2390,13 @@ void CL_ParseTempEntity( sizebuf_t *msg )
|
|||
R_UserTracerParticle( pos, pos2, life, color, scale, 0, NULL );
|
||||
break;
|
||||
default:
|
||||
Con_DPrintf( S_ERROR "%s: illegible TE message %i\n", __func__, type );
|
||||
Con_DPrintf( S_ERROR "ParseTempEntity: illegible TE message %i\n", type );
|
||||
break;
|
||||
}
|
||||
|
||||
// throw warning
|
||||
if( MSG_CheckOverflow( &buf ))
|
||||
Con_DPrintf( S_WARN "%s: overflow TE message %i\n", __func__, type );
|
||||
Con_DPrintf( S_WARN "ParseTempEntity: overflow TE message %i\n", type );
|
||||
}
|
||||
|
||||
|
||||
|
@ -2408,7 +2414,7 @@ LIGHT STYLE MANAGEMENT
|
|||
CL_ClearLightStyles
|
||||
================
|
||||
*/
|
||||
static void CL_ClearLightStyles( void )
|
||||
void CL_ClearLightStyles( void )
|
||||
{
|
||||
memset( cl.lightstyles, 0, sizeof( cl.lightstyles ));
|
||||
}
|
||||
|
@ -2466,7 +2472,7 @@ dlight_t cl_elights[MAX_ELIGHTS];
|
|||
CL_ClearDlights
|
||||
================
|
||||
*/
|
||||
static void CL_ClearDlights( void )
|
||||
void CL_ClearDlights( void )
|
||||
{
|
||||
memset( cl_dlights, 0, sizeof( cl_dlights ));
|
||||
memset( cl_elights, 0, sizeof( cl_elights ));
|
||||
|
@ -2618,7 +2624,7 @@ CL_UpdateFlashlight
|
|||
update client flashlight
|
||||
================
|
||||
*/
|
||||
static void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
{
|
||||
vec3_t forward, view_ofs;
|
||||
vec3_t vecSrc, vecEnd;
|
||||
|
@ -2659,7 +2665,7 @@ static void CL_UpdateFlashlight( cl_entity_t *ent )
|
|||
// update flashlight endpos
|
||||
dl = CL_AllocDlight( ent->index );
|
||||
#if 1
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->physents[trace.ent].info );
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace.ent].info );
|
||||
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
|
||||
VectorCopy( hit->origin, dl->origin );
|
||||
else VectorCopy( trace.endpos, dl->origin );
|
||||
|
@ -2678,41 +2684,6 @@ static void CL_UpdateFlashlight( cl_entity_t *ent )
|
|||
dl->radius = 80;
|
||||
}
|
||||
|
||||
static void R_EntityDimlight( cl_entity_t *ent, int key )
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( key );
|
||||
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
dl->color.r = dl->color.g = dl->color.b = 100;
|
||||
dl->radius = COM_RandomFloat( 200.0f, 231.0f );
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
|
||||
static void R_EntityLight( cl_entity_t *ent, int key )
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( key );
|
||||
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
dl->color.r = dl->color.g = dl->color.b = 100;
|
||||
dl->radius = 200;
|
||||
dl->die = cl.time + 0.001;
|
||||
|
||||
R_RocketFlare( ent->origin );
|
||||
}
|
||||
|
||||
static void R_EntityBrightlight( cl_entity_t *ent, int key, int radius )
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( key );
|
||||
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
dl->origin[2] += 16.0f;
|
||||
dl->color.r = dl->color.g = dl->color.b = 250;
|
||||
if( !radius )
|
||||
dl->radius = COM_RandomFloat( 400.0f, 431.0f );
|
||||
else dl->radius = 400;
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CL_AddEntityEffects
|
||||
|
@ -2722,41 +2693,50 @@ apply various effects to entity origin or attachment
|
|||
*/
|
||||
void CL_AddEntityEffects( cl_entity_t *ent )
|
||||
{
|
||||
// players have special set of effects, from CL_LinkPlayers
|
||||
if( ent->player && ent->index != cl.viewentity )
|
||||
{
|
||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||
R_EntityBrightlight( ent, ent->index /* 4 in GoldSrc */, 0 );
|
||||
// yellow flies effect 'monster stuck in the wall'
|
||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ) && !RP_LOCALCLIENT( ent ))
|
||||
R_EntityParticles( ent );
|
||||
|
||||
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||
R_EntityDimlight( ent, ent->index /* 4 in GoldSrc */ );
|
||||
}
|
||||
else if( RP_LOCALCLIENT( ent ))
|
||||
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||
{
|
||||
// from CL_PlayerFlashlight
|
||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||
R_EntityBrightlight( ent, ent->index /* 1 in GoldSrc */, 400 );
|
||||
else if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||
if( ent->player && !Host_IsQuakeCompatible( ))
|
||||
{
|
||||
CL_UpdateFlashlight( ent );
|
||||
}
|
||||
else
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
||||
dl->color.r = dl->color.g = dl->color.b = 100;
|
||||
dl->radius = COM_RandomFloat( 200, 231 );
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||
{
|
||||
// from CL_LinkPacketEntities
|
||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ))
|
||||
R_EntityParticles( ent );
|
||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
||||
dl->color.r = dl->color.g = dl->color.b = 250;
|
||||
if( ent->player ) dl->radius = 400; // don't flickering
|
||||
else dl->radius = COM_RandomFloat( 400, 431 );
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
dl->die = cl.time + 0.001;
|
||||
dl->origin[2] += 16.0f;
|
||||
}
|
||||
|
||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||
R_EntityBrightlight( ent, ent->index, 0 );
|
||||
|
||||
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||
R_EntityDimlight( ent, ent->index );
|
||||
|
||||
if( FBitSet( ent->curstate.effects, EF_LIGHT ))
|
||||
R_EntityLight( ent, ent->curstate.number );
|
||||
// add light effect
|
||||
if( FBitSet( ent->curstate.effects, EF_LIGHT ))
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
||||
dl->color.r = dl->color.g = dl->color.b = 100;
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
R_RocketFlare( ent->origin );
|
||||
dl->die = cl.time + 0.001;
|
||||
dl->radius = 200;
|
||||
}
|
||||
|
||||
// studio models are handle muzzleflashes difference
|
||||
if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && ent->model && ent->model->type == mod_alias )
|
||||
if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && Mod_AliasExtradata( ent->model ))
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
||||
vec3_t fv;
|
||||
|
@ -2785,11 +2765,15 @@ void CL_AddModelEffects( cl_entity_t *ent )
|
|||
vec3_t neworigin;
|
||||
vec3_t oldorigin;
|
||||
|
||||
if( !ent->model || ent->player )
|
||||
return;
|
||||
if( !ent->model ) return;
|
||||
|
||||
if( ent->model->type != mod_alias && ent->model->type != mod_studio )
|
||||
return;
|
||||
switch( ent->model->type )
|
||||
{
|
||||
case mod_alias:
|
||||
case mod_studio:
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if( cls.demoplayback == DEMO_QUAKE1 )
|
||||
{
|
||||
|
@ -2809,15 +2793,19 @@ void CL_AddModelEffects( cl_entity_t *ent )
|
|||
|
||||
if( FBitSet( ent->model->flags, STUDIO_GIB ))
|
||||
R_RocketTrail( oldorigin, neworigin, 2 );
|
||||
else if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
|
||||
|
||||
if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
|
||||
R_RocketTrail( oldorigin, neworigin, 4 );
|
||||
else if( FBitSet( ent->model->flags, STUDIO_TRACER ))
|
||||
|
||||
if( FBitSet( ent->model->flags, STUDIO_TRACER ))
|
||||
R_RocketTrail( oldorigin, neworigin, 3 );
|
||||
else if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
|
||||
|
||||
if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
|
||||
R_RocketTrail( oldorigin, neworigin, 5 );
|
||||
else if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
|
||||
|
||||
if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
|
||||
{
|
||||
dlight_t *dl = CL_AllocDlight( ent->curstate.number );
|
||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
||||
|
||||
dl->color.r = dl->color.g = dl->color.b = 200;
|
||||
VectorCopy( ent->origin, dl->origin );
|
||||
|
@ -2831,9 +2819,11 @@ void CL_AddModelEffects( cl_entity_t *ent )
|
|||
|
||||
R_RocketTrail( oldorigin, neworigin, 0 );
|
||||
}
|
||||
else if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
|
||||
|
||||
if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
|
||||
R_RocketTrail( oldorigin, neworigin, 1 );
|
||||
else if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
|
||||
|
||||
if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
|
||||
R_RocketTrail( oldorigin, neworigin, 6 );
|
||||
}
|
||||
|
||||
|
@ -2913,7 +2903,7 @@ CL_PlayerDecal
|
|||
spray custom colored decal (clan logo etc)
|
||||
===============
|
||||
*/
|
||||
static void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos )
|
||||
void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos )
|
||||
{
|
||||
int textureIndex = 0;
|
||||
customization_t *pCust = NULL;
|
||||
|
@ -2927,26 +2917,16 @@ static void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, flo
|
|||
{
|
||||
if( !pCust->nUserData1 )
|
||||
{
|
||||
int sprayTextureIndex;
|
||||
char decalname[MAX_VA_STRING];
|
||||
int width, height;
|
||||
|
||||
Q_snprintf( decalname, sizeof( decalname ), "player%dlogo%d", playernum, customIndex );
|
||||
textureIndex = ref.dllFuncs.GL_FindTexture( decalname );
|
||||
if( textureIndex != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( textureIndex );
|
||||
|
||||
pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL );
|
||||
|
||||
width = REF_GET_PARM( PARM_TEX_WIDTH, pCust->nUserData1 );
|
||||
height = REF_GET_PARM( PARM_TEX_HEIGHT, pCust->nUserData1 );
|
||||
|
||||
if( width > cl_logomaxdim.value || height > cl_logomaxdim.value )
|
||||
sprayTextureIndex = ref.dllFuncs.GL_FindTexture( decalname );
|
||||
if( sprayTextureIndex != 0 )
|
||||
{
|
||||
double scale = cl_logomaxdim.value / Q_max( width, height );
|
||||
width = round( width * scale );
|
||||
height = round( height * scale );
|
||||
ref.dllFuncs.R_OverrideTextureSourceSize( pCust->nUserData1, width, height ); // default custom decal from HL1
|
||||
ref.dllFuncs.GL_FreeTexture( sprayTextureIndex );
|
||||
}
|
||||
pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL );
|
||||
}
|
||||
textureIndex = pCust->nUserData1;
|
||||
}
|
||||
|
@ -2991,47 +2971,8 @@ int GAME_EXPORT CL_DecalIndex( int id )
|
|||
|
||||
if( cl.decal_index[id] == 0 )
|
||||
{
|
||||
int gl_texturenum = 0;
|
||||
|
||||
Image_SetForceFlags( IL_LOAD_DECAL );
|
||||
|
||||
if( Mod_AllowMaterials( ))
|
||||
{
|
||||
string decalname;
|
||||
|
||||
if( Q_snprintf( decalname, sizeof( decalname ), "materials/decals/%s.tga", host.draw_decals[id] ) > 0 )
|
||||
{
|
||||
if( g_fsapi.FileExists( decalname, false ))
|
||||
{
|
||||
gl_texturenum = ref.dllFuncs.GL_LoadTexture( decalname, NULL, 0, TF_DECAL );
|
||||
if( host_allow_materials.value == 2.0f )
|
||||
Con_Printf( "Looking for %s decal replacement...%s (%s)\n", host.draw_decals[id], gl_texturenum != 0 ? S_GREEN "OK" : S_RED "FAIL", decalname );
|
||||
}
|
||||
else if( host_allow_materials.value == 2.0f )
|
||||
Con_Printf( "Looking for %s decal replacement..." S_YELLOW "MISS (%s)\n", host.draw_decals[id], decalname );
|
||||
}
|
||||
else if( host_allow_materials.value == 2.0f )
|
||||
Con_Printf( "Looking for %s decal replacement..." S_YELLOW "MISS (overflow)\n", host.draw_decals[id] );
|
||||
|
||||
if( gl_texturenum )
|
||||
{
|
||||
byte *fin;
|
||||
|
||||
Q_snprintf( decalname, sizeof( decalname ), "decals.wad/%s", host.draw_decals[id] );
|
||||
|
||||
if(( fin = g_fsapi.LoadFile( decalname, NULL, false )) != NULL )
|
||||
{
|
||||
mip_t *mip = (mip_t *)fin;
|
||||
ref.dllFuncs.R_OverrideTextureSourceSize( gl_texturenum, mip->width, mip->height );
|
||||
Mem_Free( fin );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !gl_texturenum )
|
||||
gl_texturenum = ref.dllFuncs.GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
|
||||
|
||||
cl.decal_index[id] = gl_texturenum;
|
||||
cl.decal_index[id] = ref.dllFuncs.GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
|
||||
Image_ClearForceFlags();
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b );
|
|||
void R_RicochetSound( const vec3_t pos );
|
||||
struct dlight_s *CL_AllocDlight( int key );
|
||||
struct dlight_s *CL_AllocElight( int key );
|
||||
void CL_UpdateFlashlight( cl_entity_t *pEnt );
|
||||
void CL_AddEntityEffects( cl_entity_t *ent );
|
||||
void CL_AddModelEffects( cl_entity_t *ent );
|
||||
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
|
||||
|
|
|
@ -68,7 +68,7 @@ qboolean SCR_NextMovie( void )
|
|||
return true;
|
||||
}
|
||||
|
||||
static void SCR_CreateStartupVids( void )
|
||||
void SCR_CreateStartupVids( void )
|
||||
{
|
||||
file_t *f;
|
||||
|
||||
|
@ -202,6 +202,7 @@ SCR_PlayCinematic
|
|||
*/
|
||||
qboolean SCR_PlayCinematic( const char *arg )
|
||||
{
|
||||
string path;
|
||||
const char *fullpath;
|
||||
|
||||
fullpath = FS_GetDiskPath( arg, false );
|
||||
|
|
|
@ -29,7 +29,7 @@ V_CalcViewRect
|
|||
calc frame rectangle (Quake1 style)
|
||||
===============
|
||||
*/
|
||||
static void V_CalcViewRect( void )
|
||||
void V_CalcViewRect( void )
|
||||
{
|
||||
qboolean full = false;
|
||||
int sb_lines;
|
||||
|
@ -88,7 +88,7 @@ static void V_CalcViewRect( void )
|
|||
V_SetupViewModel
|
||||
===============
|
||||
*/
|
||||
static void V_SetupViewModel( void )
|
||||
void V_SetupViewModel( void )
|
||||
{
|
||||
cl_entity_t *view = &clgame.viewent;
|
||||
player_info_t *info = &cl.players[cl.playernum];
|
||||
|
@ -118,7 +118,7 @@ static void V_SetupViewModel( void )
|
|||
V_SetRefParams
|
||||
===============
|
||||
*/
|
||||
static void V_SetRefParams( ref_params_t *fd )
|
||||
void V_SetRefParams( ref_params_t *fd )
|
||||
{
|
||||
memset( fd, 0, sizeof( ref_params_t ));
|
||||
|
||||
|
@ -182,7 +182,7 @@ V_MergeOverviewRefdef
|
|||
merge refdef with overview settings
|
||||
===============
|
||||
*/
|
||||
static void V_RefApplyOverview( ref_viewpass_t *rvp )
|
||||
void V_RefApplyOverview( ref_viewpass_t *rvp )
|
||||
{
|
||||
ref_overview_t *ov = &clgame.overView;
|
||||
float aspect;
|
||||
|
@ -281,7 +281,7 @@ static void V_AdjustFov( float *fov_x, float *fov_y, float width, float height,
|
|||
V_GetRefParams
|
||||
=============
|
||||
*/
|
||||
static void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
|
||||
void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
|
||||
{
|
||||
// part1: deniable updates
|
||||
VectorCopy( fd->simvel, cl.simvel );
|
||||
|
@ -341,14 +341,12 @@ qboolean V_PreRender( void )
|
|||
{
|
||||
if(( host.realtime - cls.disable_screen ) > cl_timeout.value )
|
||||
{
|
||||
Con_Reportf( "%s: loading plaque timed out\n", __func__ );
|
||||
Con_Reportf( "V_PreRender: loading plaque timed out\n" );
|
||||
cls.disable_screen = 0.0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
V_CheckGamma();
|
||||
|
||||
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
|
||||
|
||||
GL_UpdateSwapInterval( );
|
||||
|
@ -408,14 +406,14 @@ void V_RenderView( void )
|
|||
#define NODE_INTERVAL_X(x) (x * 16.0f)
|
||||
#define NODE_INTERVAL_Y(x) (x * 16.0f)
|
||||
|
||||
static void R_DrawLeafNode( float x, float y, float scale )
|
||||
void R_DrawLeafNode( float x, float y, float scale )
|
||||
{
|
||||
float downScale = scale * 0.25f;// * POINT_SIZE;
|
||||
|
||||
ref.dllFuncs.R_DrawStretchPic( x - downScale * 0.5f, y - downScale * 0.5f, downScale, downScale, 0, 0, 1, 1, R_GetBuiltinTexture( REF_PARTICLE_TEXTURE ) );
|
||||
}
|
||||
|
||||
static void R_DrawNodeConnection( float x, float y, float x2, float y2 )
|
||||
void R_DrawNodeConnection( float x, float y, float x2, float y2 )
|
||||
{
|
||||
ref.dllFuncs.Begin( TRI_LINES );
|
||||
ref.dllFuncs.Vertex3f( x, y, 0 );
|
||||
|
@ -423,7 +421,7 @@ static void R_DrawNodeConnection( float x, float y, float x2, float y2 )
|
|||
ref.dllFuncs.End( );
|
||||
}
|
||||
|
||||
static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
|
||||
void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
|
||||
{
|
||||
float downScale = scale * 0.8f;
|
||||
|
||||
|
@ -470,7 +468,7 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
|
|||
world.recursion_level--;
|
||||
}
|
||||
|
||||
static void R_ShowTree( void )
|
||||
void R_ShowTree( void )
|
||||
{
|
||||
float x = (float)((refState.width - (int)POINT_SIZE) >> 1);
|
||||
float y = NODE_INTERVAL_Y(1.0f);
|
||||
|
@ -506,6 +504,7 @@ V_PostRender
|
|||
*/
|
||||
void V_PostRender( void )
|
||||
{
|
||||
static double oldtime;
|
||||
qboolean draw_2d = false;
|
||||
|
||||
ref.dllFuncs.R_AllowFog( false );
|
||||
|
@ -532,7 +531,6 @@ void V_PostRender( void )
|
|||
SCR_RSpeeds();
|
||||
SCR_NetSpeeds();
|
||||
SCR_DrawPos();
|
||||
SCR_DrawEnts();
|
||||
SCR_DrawNetGraph();
|
||||
SV_DrawOrthoTriangles();
|
||||
CL_DrawDemoRecording();
|
||||
|
@ -551,8 +549,5 @@ void V_PostRender( void )
|
|||
|
||||
SCR_MakeScreenShot();
|
||||
ref.dllFuncs.R_AllowFog( true );
|
||||
Platform_SetTimer( 0.0f );
|
||||
ref.dllFuncs.R_EndFrame();
|
||||
|
||||
V_CheckGammaEnd();
|
||||
}
|
||||
|
|
|
@ -174,26 +174,6 @@ typedef struct
|
|||
// at every server map change
|
||||
typedef struct
|
||||
{
|
||||
// ==== shared through RefAPI's ref_client_t ====
|
||||
double time; // this is the time value that the client
|
||||
// is rendering at. always <= cls.realtime
|
||||
// a lerp point for other data
|
||||
double oldtime; // previous cl.time, time-oldtime is used
|
||||
// to decay light values and smooth step ups
|
||||
int viewentity;
|
||||
|
||||
// server state information
|
||||
int playernum;
|
||||
int maxclients;
|
||||
|
||||
int nummodels;
|
||||
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
|
||||
|
||||
qboolean paused;
|
||||
|
||||
vec3_t simorg; // predicted origin
|
||||
// ==== shared through RefAPI's ref_client_t ===
|
||||
|
||||
int servercount; // server identification for prespawns
|
||||
int validsequence; // this is the sequence number of the last good
|
||||
// world snapshot/update we got. If this is 0, we can't
|
||||
|
@ -203,6 +183,7 @@ typedef struct
|
|||
|
||||
qboolean video_prepped; // false if on new level or new ref dll
|
||||
qboolean audio_prepped; // false if on new level or new snd dll
|
||||
qboolean paused;
|
||||
|
||||
int delta_sequence; // acknowledged sequence number
|
||||
|
||||
|
@ -224,12 +205,17 @@ typedef struct
|
|||
runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds
|
||||
local_state_t predicted_frames[MULTIPLAYER_BACKUP]; // local client state
|
||||
|
||||
double time; // this is the time value that the client
|
||||
// is rendering at. always <= cls.realtime
|
||||
// a lerp point for other data
|
||||
double oldtime; // previous cl.time, time-oldtime is used
|
||||
// to decay light values and smooth step ups
|
||||
double timedelta; // floating delta between two updates
|
||||
|
||||
char serverinfo[MAX_SERVERINFO_STRING];
|
||||
player_info_t players[MAX_CLIENTS]; // collected info about all other players include himself
|
||||
double lastresourcecheck;
|
||||
qboolean http_download;
|
||||
string downloadUrl;
|
||||
event_state_t events;
|
||||
|
||||
// predicting stuff but not only...
|
||||
|
@ -237,6 +223,7 @@ typedef struct
|
|||
|
||||
// player final info
|
||||
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
|
||||
int viewentity;
|
||||
vec3_t viewangles;
|
||||
vec3_t viewheight;
|
||||
vec3_t punchangle;
|
||||
|
@ -249,9 +236,14 @@ typedef struct
|
|||
float addangletotal;
|
||||
float prevaddangletotal;
|
||||
|
||||
// predicted velocity
|
||||
// predicted origin and velocity
|
||||
vec3_t simorg;
|
||||
vec3_t simvel;
|
||||
|
||||
// server state information
|
||||
int playernum;
|
||||
int maxclients;
|
||||
|
||||
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
|
||||
int instanced_baseline_count;
|
||||
|
||||
|
@ -259,6 +251,8 @@ typedef struct
|
|||
char event_precache[MAX_EVENTS][MAX_QPATH];
|
||||
char files_precache[MAX_CUSTOM][MAX_QPATH];
|
||||
lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
||||
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
|
||||
int nummodels;
|
||||
int numfiles;
|
||||
|
||||
consistency_t consistency_list[MAX_MODELS];
|
||||
|
@ -276,8 +270,6 @@ typedef struct
|
|||
model_t *worldmodel; // pointer to world
|
||||
|
||||
int lostpackets; // count lost packets and show dialog in menu
|
||||
|
||||
double frametime_remainder;
|
||||
} client_t;
|
||||
|
||||
/*
|
||||
|
@ -309,14 +301,6 @@ typedef enum
|
|||
CL_CHANGELEVEL, // draw 'loading' during changelevel
|
||||
} scrstate_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PROTO_CURRENT = 0, // Xash3D 49
|
||||
PROTO_LEGACY = 1, // Xash3D 48
|
||||
PROTO_QUAKE = 2, // Quake 15
|
||||
PROTO_GOLDSRC = 3, // GoldSrc 48
|
||||
} connprotocol_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[32];
|
||||
|
@ -352,7 +336,8 @@ typedef struct
|
|||
byte charWidths[256]; // scaled widths
|
||||
int charHeight; // scaled height
|
||||
int type; // fixed width font or variable
|
||||
convar_t *rendermode; // user-defined default rendermode
|
||||
int rendermode; // default rendermode
|
||||
qboolean nearest; // nearest filtering enabled
|
||||
qboolean valid; // all rectangles are valid
|
||||
} cl_font_t;
|
||||
|
||||
|
@ -528,7 +513,7 @@ typedef struct
|
|||
int logo_yres;
|
||||
float logo_length;
|
||||
|
||||
qboolean use_extended_api;
|
||||
qboolean use_text_api;
|
||||
} gameui_static_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -549,8 +534,12 @@ typedef struct
|
|||
|
||||
poolhandle_t mempool; // client premamnent pool: edicts etc
|
||||
|
||||
int signon; // 0 to SIGNONS, for the signon sequence.
|
||||
netadr_t hltv_listen_address;
|
||||
|
||||
int signon; // 0 to SIGNONS, for the signon sequence.
|
||||
int quakePort; // a 16 bit value that allows quake servers
|
||||
// to work around address translating routers
|
||||
// g-cont. this port allow many copies of engine in multiplayer game
|
||||
// connection information
|
||||
char servername[MAX_QPATH]; // name of server from original connect
|
||||
double connect_time; // for connection retransmits
|
||||
|
@ -634,14 +623,12 @@ typedef struct
|
|||
char internetservers_query[512]; // cached query
|
||||
uint32_t internetservers_query_len;
|
||||
|
||||
// multiprotocol support
|
||||
connprotocol_t legacymode;
|
||||
// legacy mode support
|
||||
qboolean legacymode; // one-way 48 protocol compatibility
|
||||
netadr_t legacyserver;
|
||||
int extensions;
|
||||
|
||||
netadr_t serveradr;
|
||||
|
||||
// do we accept utf8 as input
|
||||
qboolean accept_utf8;
|
||||
} client_static_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -661,11 +648,14 @@ extern gameui_static_t gameui;
|
|||
// cvars
|
||||
//
|
||||
extern convar_t mp_decals;
|
||||
extern convar_t cl_logomaxdim;
|
||||
extern convar_t cl_logofile;
|
||||
extern convar_t cl_logocolor;
|
||||
extern convar_t cl_allow_download;
|
||||
extern convar_t cl_allow_upload;
|
||||
extern convar_t cl_download_ingame;
|
||||
extern convar_t cl_nopred;
|
||||
extern convar_t cl_timeout;
|
||||
extern convar_t cl_nodelta;
|
||||
extern convar_t cl_interp;
|
||||
extern convar_t cl_nointerp;
|
||||
extern convar_t cl_showerror;
|
||||
|
@ -678,20 +668,19 @@ extern convar_t cl_updaterate;
|
|||
extern convar_t cl_solid_players;
|
||||
extern convar_t cl_idealpitchscale;
|
||||
extern convar_t cl_allow_levelshots;
|
||||
extern convar_t cl_lightstyle_lerping;
|
||||
extern convar_t cl_draw_particles;
|
||||
extern convar_t cl_draw_tracers;
|
||||
extern convar_t cl_levelshot_name;
|
||||
extern convar_t cl_draw_beams;
|
||||
extern convar_t cl_clockreset;
|
||||
extern convar_t cl_fixtimerate;
|
||||
extern convar_t hud_fontscale;
|
||||
extern convar_t hud_fontrender;
|
||||
extern convar_t hud_scale;
|
||||
extern convar_t hud_scale_minimal_width;
|
||||
extern convar_t r_showtextures;
|
||||
extern convar_t cl_bmodelinterp;
|
||||
extern convar_t cl_lw; // local weapons
|
||||
extern convar_t cl_charset;
|
||||
extern convar_t cl_trace_stufftext;
|
||||
extern convar_t cl_trace_messages;
|
||||
extern convar_t cl_trace_events;
|
||||
extern convar_t hud_utf8;
|
||||
|
@ -705,11 +694,11 @@ extern convar_t rate;
|
|||
extern convar_t m_ignore;
|
||||
extern convar_t r_showtree;
|
||||
extern convar_t ui_renderworld;
|
||||
extern convar_t cl_fixmodelinterpolationartifacts;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void CL_SetLightstyle( int style, const char* s, float f );
|
||||
void CL_RunLightStyles( void );
|
||||
void CL_DecayLights( void );
|
||||
dlight_t *CL_GetDynamicLight( int number );
|
||||
dlight_t *CL_GetEntityLight( int number );
|
||||
|
@ -720,8 +709,12 @@ dlight_t *CL_GetEntityLight( int number );
|
|||
// cl_cmds.c
|
||||
//
|
||||
void CL_Quit_f( void );
|
||||
void CL_GenericShot_f( void );
|
||||
void CL_ScreenShot_f( void );
|
||||
void CL_SnapShot_f( void );
|
||||
void CL_PlayCDTrack_f( void );
|
||||
void CL_EnvShot_f( void );
|
||||
void CL_SkyShot_f( void );
|
||||
void CL_SaveShot_f( void );
|
||||
void CL_LevelShot_f( void );
|
||||
void CL_SetSky_f( void );
|
||||
void SCR_Viewpos_f( void );
|
||||
|
@ -742,6 +735,8 @@ void CL_ClearResourceLists( void );
|
|||
void CL_Parse_Debug( qboolean enable );
|
||||
void CL_Parse_RecordCommand( int cmd, int startoffset );
|
||||
void CL_ResetFrame( frame_t *frame );
|
||||
void CL_WriteMessageHistory( void );
|
||||
const char *CL_MsgInfo( int cmd );
|
||||
|
||||
//
|
||||
// cl_efx.c
|
||||
|
@ -752,6 +747,7 @@ void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel );
|
|||
// cl_main.c
|
||||
//
|
||||
void CL_Init( void );
|
||||
void CL_SendCommand( void );
|
||||
void CL_Disconnect_f( void );
|
||||
void CL_ProcessFile( qboolean successfully_received, const char *filename );
|
||||
void CL_WriteUsercmd( sizebuf_t *msg, int from, int to );
|
||||
|
@ -760,6 +756,7 @@ qboolean CL_PrecacheResources( void );
|
|||
void CL_SetupOverviewParams( void );
|
||||
void CL_UpdateFrameLerp( void );
|
||||
int CL_IsDevOverviewMode( void );
|
||||
void CL_PingServers_f( void );
|
||||
void CL_SignonReply( void );
|
||||
void CL_ClearState( void );
|
||||
|
||||
|
@ -777,6 +774,8 @@ void CL_CheckStartupDemos( void );
|
|||
void CL_WriteDemoJumpTime( void );
|
||||
void CL_CloseDemoHeader( void );
|
||||
void CL_DemoCompleted( void );
|
||||
void CL_StopPlayback( void );
|
||||
void CL_StopRecord( void );
|
||||
void CL_PlayDemo_f( void );
|
||||
void CL_TimeDemo_f( void );
|
||||
void CL_StartDemos_f( void );
|
||||
|
@ -784,7 +783,6 @@ void CL_Demos_f( void );
|
|||
void CL_DeleteDemo_f( void );
|
||||
void CL_Record_f( void );
|
||||
void CL_Stop_f( void );
|
||||
int CL_GetDemoComment( const char *demoname, char *comment );
|
||||
|
||||
//
|
||||
// cl_events.c
|
||||
|
@ -792,9 +790,12 @@ int CL_GetDemoComment( const char *demoname, char *comment );
|
|||
void CL_ParseEvent( sizebuf_t *msg );
|
||||
void CL_ParseReliableEvent( sizebuf_t *msg );
|
||||
void CL_SetEventIndex( const char *szEvName, int ev_index );
|
||||
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args );
|
||||
void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
|
||||
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func );
|
||||
void CL_BatchResourceRequest( qboolean initialize );
|
||||
int CL_EstimateNeededResources( void );
|
||||
void CL_ResetEvent( event_info_t *ei );
|
||||
word CL_EventIndex( const char *name );
|
||||
void CL_FireEvents( void );
|
||||
|
@ -803,10 +804,9 @@ void CL_FireEvents( void );
|
|||
// cl_font.c
|
||||
//
|
||||
qboolean CL_FixedFont( cl_font_t *font );
|
||||
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
|
||||
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
|
||||
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags );
|
||||
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags );
|
||||
void CL_FreeFont( cl_font_t *font );
|
||||
void CL_SetFontRendermode( cl_font_t *font );
|
||||
int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags );
|
||||
int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *font, int flags );
|
||||
void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height );
|
||||
|
@ -819,7 +819,10 @@ int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags,
|
|||
//
|
||||
void CL_UnloadProgs( void );
|
||||
qboolean CL_LoadProgs( const char *name );
|
||||
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
|
||||
void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize );
|
||||
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
|
||||
void CL_ParseTextMessage( sizebuf_t *msg );
|
||||
void CL_DrawHUD( int state );
|
||||
void CL_InitEdicts( int maxclients );
|
||||
void CL_FreeEdicts( void );
|
||||
|
@ -836,30 +839,33 @@ model_t *CL_LoadClientSprite( const char *filename );
|
|||
model_t *CL_LoadModel( const char *modelname, int *index );
|
||||
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags );
|
||||
void SPR_AdjustSize( float *x, float *y, float *w, float *h );
|
||||
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 );
|
||||
int CL_GetScreenInfo( SCREENINFO *pscrinfo );
|
||||
void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a );
|
||||
pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );
|
||||
const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend );
|
||||
int PM_CL_PointContents( const float *p, int *truecontents );
|
||||
void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input
|
||||
cl_entity_t* CL_GetViewModel( void );
|
||||
physent_t *pfnGetPhysent( int idx );
|
||||
struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend );
|
||||
movevars_t *pfnGetMoveVars( void );
|
||||
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
|
||||
void CL_DisableScissor( scissor_state_t *scissor );
|
||||
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
|
||||
struct cl_entity_s *CL_GetEntityByIndex( int index );
|
||||
|
||||
_inline cl_entity_t *CL_EDICT_NUM( int n )
|
||||
{
|
||||
if( !clgame.entities )
|
||||
{
|
||||
Host_Error( "%s: clgame.entities is NULL\n", __func__ );
|
||||
Host_Error( "CL_EDICT_NUM: clgame.entities is NULL\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(( n >= 0 ) && ( n < clgame.maxEntities ))
|
||||
return clgame.entities + n;
|
||||
|
||||
Host_Error( "%s: bad number %i\n", __func__, n );
|
||||
Host_Error( "CL_EDICT_NUM: bad number %i\n", n );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -890,24 +896,19 @@ void CL_ParseFileTransferFailed( sizebuf_t *msg );
|
|||
void CL_ParseHLTV( sizebuf_t *msg );
|
||||
void CL_ParseDirector( sizebuf_t *msg );
|
||||
void CL_ParseResLocation( sizebuf_t *msg );
|
||||
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto );
|
||||
void CL_ParseServerMessage( sizebuf_t *msg );
|
||||
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext );
|
||||
void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message );
|
||||
void CL_ParseTempEntity( sizebuf_t *msg );
|
||||
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
|
||||
qboolean CL_RequestMissingResources( void );
|
||||
void CL_RegisterResources ( sizebuf_t *msg );
|
||||
void CL_ParseViewEntity( sizebuf_t *msg );
|
||||
void CL_ParseServerTime( sizebuf_t *msg );
|
||||
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
|
||||
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
|
||||
void CL_ParseTextMessage( sizebuf_t *msg );
|
||||
void CL_BatchResourceRequest( qboolean initialize );
|
||||
int CL_EstimateNeededResources( void );
|
||||
|
||||
//
|
||||
// cl_parse_48.c
|
||||
//
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg );
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message );
|
||||
void CL_LegacyPrecache_f( void );
|
||||
|
||||
//
|
||||
|
@ -916,6 +917,8 @@ void CL_LegacyPrecache_f( void );
|
|||
void SCR_VidInit( void );
|
||||
void SCR_TileClear( void );
|
||||
void SCR_DirtyScreen( void );
|
||||
void SCR_AddDirtyPoint( int x, int y );
|
||||
void SCR_InstallParticlePalette( void );
|
||||
void SCR_EndLoadingPlaque( void );
|
||||
void SCR_RegisterTextures( void );
|
||||
void SCR_LoadCreditsFont( void );
|
||||
|
@ -925,7 +928,6 @@ void SCR_NetSpeeds( void );
|
|||
void SCR_RSpeeds( void );
|
||||
void SCR_DrawFPS( int height );
|
||||
void SCR_DrawPos( void );
|
||||
void SCR_DrawEnts( void );
|
||||
|
||||
//
|
||||
// cl_netgraph.c
|
||||
|
@ -952,22 +954,25 @@ void CL_InitClientMove( void );
|
|||
void CL_PredictMovement( qboolean repredicting );
|
||||
void CL_CheckPredictionError( void );
|
||||
qboolean CL_IsPredicted( void );
|
||||
int CL_TruePointContents( const vec3_t p );
|
||||
int CL_WaterEntity( const float *rgflPos );
|
||||
cl_entity_t *CL_GetWaterEntity( const float *rgflPos );
|
||||
int CL_TestLine( const vec3_t start, const vec3_t end, int flags );
|
||||
pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags );
|
||||
pmtrace_t CL_TraceLine( vec3_t start, vec3_t end, int flags );
|
||||
void CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs );
|
||||
void CL_PopTraceBounds( void );
|
||||
void CL_MoveSpectatorCamera( void );
|
||||
void CL_SetLastUpdate( void );
|
||||
void CL_RedoPrediction( void );
|
||||
void CL_PushPMStates( void );
|
||||
void CL_PopPMStates( void );
|
||||
void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient );
|
||||
void CL_SetIdealPitch( void );
|
||||
|
||||
//
|
||||
// cl_qparse.c
|
||||
//
|
||||
void CL_ParseQuakeMessage( sizebuf_t *msg );
|
||||
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message );
|
||||
|
||||
//
|
||||
// cl_frame.c
|
||||
|
@ -979,17 +984,21 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType );
|
|||
void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset );
|
||||
qboolean CL_GetEntitySpatialization( struct channel_s *ch );
|
||||
qboolean CL_GetMovieSpatialization( struct rawchan_s *ch );
|
||||
void CL_ProcessPlayerState( int playerindex, entity_state_t *state );
|
||||
void CL_ComputePlayerOrigin( cl_entity_t *clent );
|
||||
void CL_ProcessPacket( frame_t *frame );
|
||||
void CL_MoveThirdpersonCamera( void );
|
||||
qboolean CL_IsPlayerIndex( int idx );
|
||||
void CL_SetIdealPitch( void );
|
||||
void CL_EmitEntities( void );
|
||||
|
||||
//
|
||||
// cl_remap.c
|
||||
//
|
||||
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
|
||||
void CL_FreeRemapInfo( remap_info_t *info );
|
||||
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
|
||||
void CL_ClearAllRemaps( void );
|
||||
|
||||
//
|
||||
|
@ -1006,7 +1015,6 @@ const ref_overview_t *GL_GetOverviewParms( void );
|
|||
//
|
||||
void R_StoreEfrags( efrag_t **ppefrag, int framecount );
|
||||
void R_AddEfrags( cl_entity_t *ent );
|
||||
|
||||
//
|
||||
// cl_tent.c
|
||||
//
|
||||
|
@ -1017,6 +1025,7 @@ void CL_ClearEfrags( void );
|
|||
void CL_TestLights( void );
|
||||
void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale );
|
||||
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
|
||||
void CL_PlayerDecal( int playerIndex, int textureIndex, int entityIndex, float *pos );
|
||||
void R_FreeDeadParticles( struct particle_s **ppparticles );
|
||||
void CL_AddClientResource( const char *filename, int type );
|
||||
void CL_AddClientResources( void );
|
||||
|
@ -1038,6 +1047,7 @@ void CL_ReadPointFile_f( void );
|
|||
void CL_DrawEFX( float time, qboolean fTrans );
|
||||
void CL_ThinkParticle( double frametime, particle_t *p );
|
||||
void CL_ReadLineFile_f( void );
|
||||
void CL_RunLightStyles( void );
|
||||
|
||||
//
|
||||
// console.c
|
||||
|
@ -1057,22 +1067,27 @@ int Con_UtfProcessChar( int in );
|
|||
int Con_UtfProcessCharForce( int in );
|
||||
int Con_UtfMoveLeft( char *str, int pos );
|
||||
int Con_UtfMoveRight( char *str, int pos, int length );
|
||||
void Con_DefaultColor( int r, int g, int b, qboolean gameui );
|
||||
void Con_DefaultColor( int r, int g, int b );
|
||||
void Con_InvalidateFonts( void );
|
||||
cl_font_t *Con_GetCurFont( void );
|
||||
cl_font_t *Con_GetFont( int num );
|
||||
void Con_DrawCharacterLen( int number, int *width, int *height );
|
||||
int Con_DrawString( int x, int y, const char *string, rgba_t setColor ); // legacy, use cl_font.c
|
||||
void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c
|
||||
void Con_CharEvent( int key );
|
||||
void Con_RestoreFont( void );
|
||||
void Key_Console( int key );
|
||||
void Key_Message( int key );
|
||||
void Con_FastClose( void );
|
||||
void Con_Bottom( void );
|
||||
void Con_Top( void );
|
||||
void Con_PageDown( int lines );
|
||||
void Con_PageUp( int lines );
|
||||
|
||||
//
|
||||
// s_main.c
|
||||
//
|
||||
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data );
|
||||
void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime );
|
||||
void S_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath );
|
||||
void S_StopBackgroundTrack( void );
|
||||
|
@ -1110,7 +1125,7 @@ qboolean UI_MouseInRect( void );
|
|||
qboolean UI_IsVisible( void );
|
||||
void UI_ResetPing( void );
|
||||
void UI_ShowUpdateDialog( qboolean preferStore );
|
||||
qboolean UI_ShowMessageBox( const char *text );
|
||||
void UI_ShowMessageBox( const char *text );
|
||||
void UI_AddTouchButtonToList( const char *name, const char *texture, const char *command, unsigned char *color, int flags );
|
||||
void UI_ConnectionProgress_Disconnect( void );
|
||||
void UI_ConnectionProgress_Download( const char *pszFileName, const char *pszServerName, const char *pszServerPath, int iCurrent, int iTotal, const char *comment );
|
||||
|
@ -1119,6 +1134,11 @@ void UI_ConnectionProgress_Precache( void );
|
|||
void UI_ConnectionProgress_Connect( const char *server );
|
||||
void UI_ConnectionProgress_ChangeLevel( void );
|
||||
void UI_ConnectionProgress_ParseServerInfo( const char *server );
|
||||
void pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a );
|
||||
void pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc );
|
||||
void pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc );
|
||||
void pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc );
|
||||
void pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc );
|
||||
|
||||
//
|
||||
// cl_mobile.c
|
||||
|
|
|
@ -21,20 +21,18 @@ GNU General Public License for more details.
|
|||
#include "qfont.h"
|
||||
#include "wadfile.h"
|
||||
#include "input.h"
|
||||
#include "utflib.h"
|
||||
|
||||
static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" );
|
||||
static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" );
|
||||
CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
|
||||
static CVAR_DEFINE_AUTO( con_fontrender, "2", FCVAR_ARCHIVE, "console font render mode (0: additive, 1: holes, 2: trans)" );
|
||||
static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
|
||||
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
||||
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
||||
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
||||
static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" );
|
||||
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
|
||||
|
||||
|
||||
static int g_codepage = 0;
|
||||
static qboolean g_utf8 = false;
|
||||
|
||||
static qboolean g_messagemode_privileged = true;
|
||||
|
||||
|
@ -141,9 +139,8 @@ typedef struct
|
|||
|
||||
static console_t con;
|
||||
|
||||
static void Con_ClearField( field_t *edit );
|
||||
static void Field_CharEvent( field_t *edit, int ch );
|
||||
static void Con_InvalidateFonts( void );
|
||||
void Con_ClearField( field_t *edit );
|
||||
void Field_CharEvent( field_t *edit, int ch );
|
||||
|
||||
static void Con_LoadHistory( con_history_t *self );
|
||||
static void Con_SaveHistory( con_history_t *self );
|
||||
|
@ -153,7 +150,7 @@ static void Con_SaveHistory( con_history_t *self );
|
|||
Con_Clear_f
|
||||
================
|
||||
*/
|
||||
static void Con_Clear_f( void )
|
||||
void Con_Clear_f( void )
|
||||
{
|
||||
con.lines_count = 0;
|
||||
con.backscroll = 0; // go to end
|
||||
|
@ -177,10 +174,10 @@ static void Con_SetColor( void )
|
|||
switch( num )
|
||||
{
|
||||
case 1:
|
||||
Con_DefaultColor( r, r, r, false );
|
||||
Con_DefaultColor( r, r, r );
|
||||
break;
|
||||
case 3:
|
||||
Con_DefaultColor( r, g, b, false );
|
||||
Con_DefaultColor( r, g, b );
|
||||
break;
|
||||
default:
|
||||
Cvar_DirectSet( &con_color, con_color.def_string );
|
||||
|
@ -208,7 +205,7 @@ void Con_ClearNotify( void )
|
|||
Con_ClearTyping
|
||||
================
|
||||
*/
|
||||
static void Con_ClearTyping( void )
|
||||
void Con_ClearTyping( void )
|
||||
{
|
||||
Con_ClearField( &con.input );
|
||||
con.input.widthInChars = con.linewidth;
|
||||
|
@ -221,7 +218,7 @@ static void Con_ClearTyping( void )
|
|||
Con_MessageMode_f
|
||||
================
|
||||
*/
|
||||
static void Con_MessageMode_f( void )
|
||||
void Con_MessageMode_f( void )
|
||||
{
|
||||
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
|
||||
|
||||
|
@ -237,7 +234,7 @@ static void Con_MessageMode_f( void )
|
|||
Con_MessageMode2_f
|
||||
================
|
||||
*/
|
||||
static void Con_MessageMode2_f( void )
|
||||
void Con_MessageMode2_f( void )
|
||||
{
|
||||
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
|
||||
|
||||
|
@ -282,7 +279,7 @@ void Con_ToggleConsole_f( void )
|
|||
Con_SetTimes_f
|
||||
================
|
||||
*/
|
||||
static void Con_SetTimes_f( void )
|
||||
void Con_SetTimes_f( void )
|
||||
{
|
||||
int newtimes;
|
||||
|
||||
|
@ -305,7 +302,7 @@ Notifies the console code about the current time
|
|||
went backwards)
|
||||
================
|
||||
*/
|
||||
static void Con_FixTimes( void )
|
||||
void Con_FixTimes( void )
|
||||
{
|
||||
double diff;
|
||||
int i;
|
||||
|
@ -326,7 +323,7 @@ Con_DeleteLine
|
|||
Deletes the first line from the console history.
|
||||
================
|
||||
*/
|
||||
static void Con_DeleteLine( void )
|
||||
void Con_DeleteLine( void )
|
||||
{
|
||||
if( con.lines_count == 0 )
|
||||
return;
|
||||
|
@ -341,7 +338,7 @@ Con_DeleteLastLine
|
|||
Deletes the last line from the console history.
|
||||
================
|
||||
*/
|
||||
static void Con_DeleteLastLine( void )
|
||||
void Con_DeleteLastLine( void )
|
||||
{
|
||||
if( con.lines_count == 0 )
|
||||
return;
|
||||
|
@ -400,7 +397,7 @@ Con_AddLine
|
|||
Appends a given string as a new line to the console.
|
||||
================
|
||||
*/
|
||||
static void Con_AddLine( const char *line, int length, qboolean newline )
|
||||
void Con_AddLine( const char *line, int length, qboolean newline )
|
||||
{
|
||||
char *putpos;
|
||||
con_lineinfo_t *p;
|
||||
|
@ -446,7 +443,7 @@ Con_CheckResize
|
|||
If the line width has changed, reformat the buffer.
|
||||
================
|
||||
*/
|
||||
static void Con_CheckResize( void )
|
||||
void Con_CheckResize( void )
|
||||
{
|
||||
int charWidth = 8;
|
||||
int i, width;
|
||||
|
@ -495,7 +492,7 @@ void Con_PageDown( int lines )
|
|||
Con_Top
|
||||
================
|
||||
*/
|
||||
static void Con_Top( void )
|
||||
void Con_Top( void )
|
||||
{
|
||||
con.backscroll = CON_MAXLINES;
|
||||
}
|
||||
|
@ -546,9 +543,10 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
|||
if( font->valid )
|
||||
return; // already loaded
|
||||
|
||||
if( con_oldfont.value )
|
||||
// loading conchars
|
||||
if( Sys_CheckParm( "-oldfont" ))
|
||||
{
|
||||
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
|
||||
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -561,14 +559,14 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
|||
if( Q_snprintf( path, sizeof( path ),
|
||||
"font%i_%s.fnt", fontNumber, Cvar_VariableString( "con_charset" )) > 0 )
|
||||
{
|
||||
success = Con_LoadVariableWidthFont( path, font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
|
||||
success = Con_LoadVariableWidthFont( path, font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
|
||||
}
|
||||
}
|
||||
|
||||
if( !success )
|
||||
{
|
||||
Q_snprintf( path, sizeof( path ), "fonts/font%i", fontNumber );
|
||||
success = Con_LoadVariableWidthFont( path, font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
|
||||
success = Con_LoadVariableWidthFont( path, font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,7 +574,7 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
|||
{
|
||||
// quake fixed font as fallback
|
||||
// keep source to print directly into conback image
|
||||
if( !Con_LoadFixedWidthFont( "gfx/conchars", font, scale, &con_fontrender, TF_FONT|TF_NEAREST|TF_KEEP_SOURCE ))
|
||||
if( !Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransTexture, TF_FONT|TF_KEEP_SOURCE ))
|
||||
Con_DPrintf( S_ERROR "failed to load console font\n" );
|
||||
}
|
||||
}
|
||||
|
@ -610,6 +608,19 @@ static void Con_LoadConchars( void )
|
|||
con.curFont = &con.chars[fontSize];
|
||||
}
|
||||
|
||||
// CP1251 table
|
||||
|
||||
int table_cp1251[64] = {
|
||||
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
|
||||
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x007F, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
|
||||
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
|
||||
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
|
||||
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457
|
||||
};
|
||||
|
||||
/*
|
||||
============================
|
||||
Con_UtfProcessChar
|
||||
|
@ -619,28 +630,84 @@ Convert utf char to current font's single-byte encoding
|
|||
*/
|
||||
int Con_UtfProcessCharForce( int in )
|
||||
{
|
||||
// TODO: get rid of global state where possible
|
||||
static utfstate_t state = { 0 };
|
||||
static int m = -1, k = 0; //multibyte state
|
||||
static int uc = 0; //unicode char
|
||||
|
||||
int ch = Q_DecodeUTF8( &state, in );
|
||||
if( !in )
|
||||
{
|
||||
m = -1;
|
||||
k = 0;
|
||||
uc = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( g_codepage == 1251 )
|
||||
return Q_UnicodeToCP1251( ch );
|
||||
if( g_codepage == 1252 )
|
||||
return Q_UnicodeToCP1252( ch );
|
||||
// Get character length
|
||||
if(m == -1)
|
||||
{
|
||||
uc = 0;
|
||||
if( in >= 0xF8 )
|
||||
return 0;
|
||||
else if( in >= 0xF0 )
|
||||
uc = in & 0x07, m = 3;
|
||||
else if( in >= 0xE0 )
|
||||
uc = in & 0x0F, m = 2;
|
||||
else if( in >= 0xC0 )
|
||||
uc = in & 0x1F, m = 1;
|
||||
else if( in <= 0x7F)
|
||||
return in; //ascii
|
||||
// return 0 if we need more chars to decode one
|
||||
k=0;
|
||||
return 0;
|
||||
}
|
||||
// get more chars
|
||||
else if( k <= m )
|
||||
{
|
||||
uc <<= 6;
|
||||
uc += in & 0x3F;
|
||||
k++;
|
||||
}
|
||||
if( in > 0xBF || m < 0 )
|
||||
{
|
||||
m = -1;
|
||||
return 0;
|
||||
}
|
||||
if( k == m )
|
||||
{
|
||||
k = m = -1;
|
||||
if( g_codepage == 1251 )
|
||||
{
|
||||
// cp1251 now
|
||||
if( uc >= 0x0410 && uc <= 0x042F )
|
||||
return uc - 0x410 + 0xC0;
|
||||
if( uc >= 0x0430 && uc <= 0x044F )
|
||||
return uc - 0x430 + 0xE0;
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < 64; i++ )
|
||||
if( table_cp1251[i] == uc )
|
||||
return i + 0x80;
|
||||
}
|
||||
}
|
||||
else if( g_codepage == 1252 )
|
||||
{
|
||||
if( uc < 255 )
|
||||
return uc;
|
||||
}
|
||||
|
||||
return '?'; // not implemented yet
|
||||
// not implemented yet
|
||||
return '?';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GAME_EXPORT Con_UtfProcessChar( int in )
|
||||
{
|
||||
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
|
||||
if( !g_utf8 )
|
||||
return in;
|
||||
|
||||
// otherwise, decode it and convert to selected codepage
|
||||
return Con_UtfProcessCharForce( in );
|
||||
else
|
||||
return Con_UtfProcessCharForce( in );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Con_UtfMoveLeft
|
||||
|
@ -650,22 +717,16 @@ get position of previous printful char
|
|||
*/
|
||||
int Con_UtfMoveLeft( char *str, int pos )
|
||||
{
|
||||
utfstate_t state = { 0 };
|
||||
int k = 0;
|
||||
int i;
|
||||
|
||||
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
|
||||
int i, k = 0;
|
||||
// int j;
|
||||
if( !g_utf8 )
|
||||
return pos - 1;
|
||||
|
||||
if( pos == 1 )
|
||||
return 0;
|
||||
|
||||
for( i = 0; i < pos - 1; i++ )
|
||||
{
|
||||
if( Q_DecodeUTF8( &state, (byte)str[i] ))
|
||||
k = i + 1;
|
||||
}
|
||||
|
||||
Con_UtfProcessChar( 0 );
|
||||
if(pos == 1) return 0;
|
||||
for( i = 0; i < pos-1; i++ )
|
||||
if( Con_UtfProcessChar( (unsigned char)str[i] ) )
|
||||
k = i+1;
|
||||
Con_UtfProcessChar( 0 );
|
||||
return k;
|
||||
}
|
||||
|
||||
|
@ -678,19 +739,17 @@ get next of previous printful char
|
|||
*/
|
||||
int Con_UtfMoveRight( char *str, int pos, int length )
|
||||
{
|
||||
utfstate_t state = { 0 };
|
||||
int i;
|
||||
|
||||
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
|
||||
if( !g_utf8 )
|
||||
return pos + 1;
|
||||
|
||||
Con_UtfProcessChar( 0 );
|
||||
for( i = pos; i <= length; i++ )
|
||||
{
|
||||
if( Q_DecodeUTF8( &state, (byte)str[i] ))
|
||||
return i + 1;
|
||||
if( Con_UtfProcessChar( (unsigned char)str[i] ) )
|
||||
return i+1;
|
||||
}
|
||||
|
||||
return pos + 1;
|
||||
Con_UtfProcessChar( 0 );
|
||||
return pos+1;
|
||||
}
|
||||
|
||||
static void Con_DrawCharToConback( int num, const byte *conchars, byte *dest )
|
||||
|
@ -780,11 +839,8 @@ void Con_Init( void )
|
|||
Cvar_RegisterVariable( &con_fontsize );
|
||||
Cvar_RegisterVariable( &con_charset );
|
||||
Cvar_RegisterVariable( &con_fontscale );
|
||||
Cvar_RegisterVariable( &con_fontrender );
|
||||
Cvar_RegisterVariable( &con_fontnum );
|
||||
Cvar_RegisterVariable( &con_color );
|
||||
Cvar_RegisterVariable( &scr_drawversion );
|
||||
Cvar_RegisterVariable( &con_oldfont );
|
||||
|
||||
// init the console buffer
|
||||
con.bufsize = CON_TEXTSIZE;
|
||||
|
@ -1062,9 +1118,9 @@ EDIT FIELDS
|
|||
Con_ClearField
|
||||
================
|
||||
*/
|
||||
static void Con_ClearField( field_t *edit )
|
||||
void Con_ClearField( field_t *edit )
|
||||
{
|
||||
memset( edit->buffer, 0, sizeof( edit->buffer ));
|
||||
memset( edit->buffer, 0, MAX_STRING );
|
||||
edit->cursor = 0;
|
||||
edit->scroll = 0;
|
||||
}
|
||||
|
@ -1077,7 +1133,7 @@ Field_Set
|
|||
static void Field_Set( field_t *f, const char *string )
|
||||
{
|
||||
f->scroll = 0;
|
||||
f->cursor = Q_strncpy( f->buffer, string, sizeof( f->buffer ));
|
||||
f->cursor = Q_strncpy( f->buffer, string, MAX_STRING );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1085,7 +1141,7 @@ static void Field_Set( field_t *f, const char *string )
|
|||
Field_Paste
|
||||
================
|
||||
*/
|
||||
static void Field_Paste( field_t *edit )
|
||||
void Field_Paste( field_t *edit )
|
||||
{
|
||||
char *cbd;
|
||||
int i, pasteLen;
|
||||
|
@ -1121,7 +1177,7 @@ in-game talk, and menu fields
|
|||
Key events are used for non-printable characters, others are gotten from char events.
|
||||
=================
|
||||
*/
|
||||
static void Field_KeyDownEvent( field_t *edit, int key )
|
||||
void Field_KeyDownEvent( field_t *edit, int key )
|
||||
{
|
||||
int len;
|
||||
|
||||
|
@ -1192,7 +1248,7 @@ static void Field_KeyDownEvent( field_t *edit, int key )
|
|||
Field_CharEvent
|
||||
==================
|
||||
*/
|
||||
static void Field_CharEvent( field_t *edit, int ch )
|
||||
void Field_CharEvent( field_t *edit, int ch )
|
||||
{
|
||||
int len;
|
||||
|
||||
|
@ -1253,7 +1309,7 @@ static void Field_CharEvent( field_t *edit, int ch )
|
|||
Field_DrawInputLine
|
||||
==================
|
||||
*/
|
||||
static void Field_DrawInputLine( int x, int y, field_t *edit )
|
||||
void Field_DrawInputLine( int x, int y, field_t *edit )
|
||||
{
|
||||
int len, cursorChar;
|
||||
int drawLen;
|
||||
|
@ -1383,49 +1439,36 @@ static void Con_HistoryAppend( con_history_t *self, field_t *from )
|
|||
|
||||
static void Con_LoadHistory( con_history_t *self )
|
||||
{
|
||||
const byte *aFile = FS_LoadFile( "console_history.txt", NULL, true );
|
||||
const char *pLine, *pFile;
|
||||
int i, len;
|
||||
field_t *f;
|
||||
file_t *fd;
|
||||
int i;
|
||||
|
||||
fd = FS_Open( "console_history.txt", "rb", true );
|
||||
|
||||
if( !fd )
|
||||
if( !aFile )
|
||||
return;
|
||||
|
||||
while( !FS_Eof( fd ))
|
||||
for( pFile = pLine = (char *)aFile; *pFile; pFile++ )
|
||||
{
|
||||
f = &self->lines[self->next % CON_HISTORY];
|
||||
|
||||
Con_ClearField( f );
|
||||
f->widthInChars = con.linewidth;
|
||||
|
||||
FS_Gets( fd, f->buffer, sizeof( f->buffer ));
|
||||
f->cursor = Q_strlen( f->buffer );
|
||||
|
||||
// skip empty lines
|
||||
if( f->cursor == 0 )
|
||||
if( *pFile != '\n' )
|
||||
continue;
|
||||
|
||||
// skip repeating lines
|
||||
if( self->next > 0 )
|
||||
{
|
||||
field_t *prev;
|
||||
prev = &self->lines[(self->next - 1) % CON_HISTORY];
|
||||
if( !Q_stricmp( prev->buffer, f->buffer ))
|
||||
continue;
|
||||
}
|
||||
Con_ClearField( &self->lines[self->next] );
|
||||
|
||||
len = Q_min( pFile - pLine + 1, sizeof( f->buffer ));
|
||||
f = &self->lines[self->next % CON_HISTORY];
|
||||
f->widthInChars = con.linewidth;
|
||||
f->cursor = len - 1;
|
||||
Q_strncpy( f->buffer, pLine, len);
|
||||
|
||||
self->next++;
|
||||
}
|
||||
|
||||
FS_Close( fd );
|
||||
pLine = pFile + 1;
|
||||
}
|
||||
|
||||
for( i = self->next; i < CON_HISTORY; i++ )
|
||||
{
|
||||
f = &self->lines[i];
|
||||
|
||||
Con_ClearField( f );
|
||||
f->widthInChars = con.linewidth;
|
||||
Con_ClearField( &self->lines[i] );
|
||||
self->lines[i].widthInChars = con.linewidth;
|
||||
}
|
||||
|
||||
self->line = self->next;
|
||||
|
@ -1443,18 +1486,10 @@ static void Con_SaveHistory( con_history_t *self )
|
|||
if( historyStart < 0 )
|
||||
historyStart = 0;
|
||||
|
||||
f = FS_Open( "console_history.txt", "wb", true );
|
||||
f = FS_Open( "console_history.txt", "w", true );
|
||||
|
||||
for( i = historyStart; i < self->next; i++ )
|
||||
{
|
||||
const char *s = self->lines[i % CON_HISTORY].buffer;
|
||||
|
||||
// HACKHACK: don't save lines that have something that looks like a password
|
||||
if( Q_stristr( s, "password" ) || Q_stristr( s, "_pw" ))
|
||||
continue;
|
||||
|
||||
FS_Printf( f, "%s\n", s );
|
||||
}
|
||||
FS_Printf( f, "%s\n", self->lines[i % CON_HISTORY].buffer );
|
||||
|
||||
FS_Close( f );
|
||||
}
|
||||
|
@ -1496,9 +1531,6 @@ void Key_Console( int key )
|
|||
Con_Printf( ">%s\n", con.input.buffer );
|
||||
|
||||
// copy line to history buffer
|
||||
// just in case, remove all CR and LF characters pushing it to the history
|
||||
// not sure how they get even added in the first place
|
||||
COM_RemoveLineFeed( con.input.buffer, sizeof( con.input.buffer ));
|
||||
Con_HistoryAppend( &con.history, &con.input );
|
||||
|
||||
Con_ClearField( &con.input );
|
||||
|
@ -1649,7 +1681,7 @@ Con_DrawInput
|
|||
The input line scrolls horizontally if typing goes beyond the right edge
|
||||
================
|
||||
*/
|
||||
static void Con_DrawInput( int lines )
|
||||
void Con_DrawInput( int lines )
|
||||
{
|
||||
int y;
|
||||
|
||||
|
@ -1669,7 +1701,7 @@ Con_DrawDebugLines
|
|||
Custom debug messages
|
||||
================
|
||||
*/
|
||||
static int Con_DrawDebugLines( void )
|
||||
int Con_DrawDebugLines( void )
|
||||
{
|
||||
notify_t *notify = con.notify;
|
||||
int i, count = 0;
|
||||
|
@ -1754,7 +1786,7 @@ Con_DrawNotify
|
|||
Draws the last few lines of output transparently over the game top
|
||||
================
|
||||
*/
|
||||
static void Con_DrawNotify( void )
|
||||
void Con_DrawNotify( void )
|
||||
{
|
||||
double time = cl.time;
|
||||
int i, x, y = 0;
|
||||
|
@ -1806,7 +1838,7 @@ If alpha is 0, the line is not drawn, but still wrapped and its height
|
|||
returned.
|
||||
================
|
||||
*/
|
||||
static int Con_DrawConsoleLine( int y, int lineno )
|
||||
int Con_DrawConsoleLine( int y, int lineno )
|
||||
{
|
||||
con_lineinfo_t *li = &CON_LINES( lineno );
|
||||
|
||||
|
@ -1861,7 +1893,7 @@ Con_DrawConsole
|
|||
Draws the console with the solid background
|
||||
================
|
||||
*/
|
||||
static void Con_DrawSolidConsole( int lines )
|
||||
void Con_DrawSolidConsole( int lines )
|
||||
{
|
||||
int i, x, y;
|
||||
float fraction;
|
||||
|
@ -2015,30 +2047,26 @@ void Con_DrawVersion( void )
|
|||
byte *color = g_color_table[7];
|
||||
int stringLen, charH = 0;
|
||||
int start, height = refState.height;
|
||||
qboolean draw_version = false;
|
||||
string curbuild;
|
||||
|
||||
if( !scr_drawversion.value || CL_IsDevOverviewMode() == 2 || net_graph.value )
|
||||
switch( cls.scrshot_action )
|
||||
{
|
||||
case scrshot_normal:
|
||||
case scrshot_snapshot:
|
||||
draw_version = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( host.force_draw_version_time > host.realtime )
|
||||
draw_version = true;
|
||||
|
||||
if(( cls.key_dest != key_menu && !draw_version ) || CL_IsDevOverviewMode() == 2 || net_graph.value )
|
||||
return;
|
||||
|
||||
if( cls.key_dest == key_menu )
|
||||
{
|
||||
Q_snprintf( curbuild, sizeof( curbuild ),
|
||||
"v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||
}
|
||||
else
|
||||
{
|
||||
qboolean draw_version;
|
||||
|
||||
draw_version = cls.scrshot_action == scrshot_normal
|
||||
|| cls.scrshot_action == scrshot_snapshot
|
||||
|| host.force_draw_version_time > host.realtime;
|
||||
|
||||
if( !draw_version )
|
||||
return;
|
||||
|
||||
Q_snprintf( curbuild, sizeof( curbuild ),
|
||||
XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||
}
|
||||
if( draw_version )
|
||||
Q_snprintf( curbuild, MAX_STRING, XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||
else Q_snprintf( curbuild, MAX_STRING, "v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||
|
||||
Con_DrawStringLen( curbuild, &stringLen, &charH );
|
||||
start = refState.width - stringLen * 1.05f;
|
||||
|
@ -2063,13 +2091,9 @@ void Con_RunConsole( void )
|
|||
// decide on the destination height of the console
|
||||
if( host.allow_console && cls.key_dest == key_console )
|
||||
{
|
||||
#if XASH_MOBILE_PLATFORM
|
||||
con.showlines = refState.height; // always full screen on mobile devices
|
||||
#else
|
||||
if( cls.state < ca_active || cl.first_frame )
|
||||
con.showlines = refState.height; // full screen
|
||||
else con.showlines = (refState.height >> 1); // half screen
|
||||
#endif
|
||||
}
|
||||
else con.showlines = 0; // none visible
|
||||
|
||||
|
@ -2088,7 +2112,10 @@ void Con_RunConsole( void )
|
|||
con.vislines = con.showlines;
|
||||
}
|
||||
|
||||
if( FBitSet( con_charset.flags|con_fontscale.flags|con_fontnum.flags|cl_charset.flags|con_oldfont.flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( con_charset.flags, FCVAR_CHANGED ) ||
|
||||
FBitSet( con_fontscale.flags, FCVAR_CHANGED ) ||
|
||||
FBitSet( con_fontnum.flags, FCVAR_CHANGED ) ||
|
||||
FBitSet( cl_charset.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
// update codepage parameters
|
||||
if( !Q_stricmp( con_charset.string, "cp1251" ))
|
||||
|
@ -2107,14 +2134,13 @@ void Con_RunConsole( void )
|
|||
g_codepage = 1252;
|
||||
}
|
||||
|
||||
cls.accept_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
|
||||
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
|
||||
Con_InvalidateFonts();
|
||||
Con_LoadConchars();
|
||||
ClearBits( con_charset.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_fontnum.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_fontscale.flags, FCVAR_CHANGED );
|
||||
ClearBits( cl_charset.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_oldfont.flags, FCVAR_CHANGED );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2145,28 +2171,6 @@ void Con_CharEvent( int key )
|
|||
}
|
||||
}
|
||||
|
||||
static int Con_LoadSimpleConback( const char *name, int flags )
|
||||
{
|
||||
const char *paths[] = {
|
||||
"gfx/shell/%s.bmp",
|
||||
"gfx/shell/%s.tga",
|
||||
"cached/%s640",
|
||||
"cached/%s",
|
||||
};
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( paths ); i++ )
|
||||
{
|
||||
string path;
|
||||
|
||||
Q_snprintf( path, sizeof( path ), paths[i], name );
|
||||
if( g_fsapi.FileExists( path, false ))
|
||||
return ref.dllFuncs.GL_LoadTexture( path, NULL, 0, flags );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
Con_VidInit
|
||||
|
@ -2176,25 +2180,46 @@ INTERNAL RESOURCE
|
|||
*/
|
||||
void Con_VidInit( void )
|
||||
{
|
||||
const uint flags = TF_IMAGE|TF_ALLOW_NEAREST;
|
||||
|
||||
if( !con.historyLoaded )
|
||||
{
|
||||
Con_LoadHistory( &con.history );
|
||||
con.historyLoaded = true;
|
||||
}
|
||||
|
||||
if( Sys_CheckParm( "-oldfont" ))
|
||||
Cvar_DirectSet( &con_oldfont, "1" );
|
||||
|
||||
Con_LoadConchars();
|
||||
Con_CheckResize();
|
||||
|
||||
#if XASH_LOW_MEMORY
|
||||
con.background = R_GetBuiltinTexture( REF_GRAY_TEXTURE );
|
||||
con.background = R_GetBuiltinTexture( REF_BLACK_TEXTURE );
|
||||
#else
|
||||
// loading console image
|
||||
con.background = Con_LoadSimpleConback( host.allow_console ? "conback" : "loading", flags );
|
||||
if( host.allow_console )
|
||||
{
|
||||
// trying to load truecolor image first
|
||||
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
|
||||
|
||||
if( !con.background )
|
||||
{
|
||||
if( FS_FileExists( "cached/conback640", false ))
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
|
||||
else if( FS_FileExists( "cached/conback", false ))
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// trying to load truecolor image first
|
||||
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
|
||||
|
||||
if( !con.background )
|
||||
{
|
||||
if( FS_FileExists( "cached/loading640", false ))
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
|
||||
else if( FS_FileExists( "cached/loading", false ))
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
}
|
||||
|
||||
if( !con.background ) // last chance - quake conback image
|
||||
{
|
||||
|
@ -2278,20 +2303,11 @@ Con_DefaultColor
|
|||
called from MainUI
|
||||
=========
|
||||
*/
|
||||
void Con_DefaultColor( int r, int g, int b, qboolean gameui )
|
||||
void GAME_EXPORT Con_DefaultColor( int r, int g, int b )
|
||||
{
|
||||
r = bound( 0, r, 255 );
|
||||
g = bound( 0, g, 255 );
|
||||
b = bound( 0, b, 255 );
|
||||
|
||||
// gameui wants to override console color... check if it's not default
|
||||
if( gameui && ( g_color_table[7][0] != r || g_color_table[7][1] != g || g_color_table[7][2] != b ))
|
||||
{
|
||||
// yes, different from default orange, disable con_color
|
||||
SetBits( con_color.flags, FCVAR_READ_ONLY );
|
||||
ClearBits( con_color.flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
MakeRGBA( g_color_table[7], r, g, b, 255 );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,438 +0,0 @@
|
|||
/*
|
||||
gamma.c - gamma routines
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "enginefeatures.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gamma conversion support
|
||||
//-----------------------------------------------------------------------------
|
||||
static qboolean gamma_rebuilt;
|
||||
static byte texgammatable[256];
|
||||
static uint lightgammatable[1024];
|
||||
static uint lineargammatable[1024];
|
||||
static uint screengammatable[1024];
|
||||
static CVAR_DEFINE( v_direct, "direct", "0.9", 0, "direct studio lighting" );
|
||||
static CVAR_DEFINE( v_texgamma, "texgamma", "2.0", 0, "texgamma amount" );
|
||||
static CVAR_DEFINE( v_lightgamma, "lightgamma", "2.5", 0, "lightgamma amount" );
|
||||
static CVAR_DEFINE( v_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
|
||||
static CVAR_DEFINE( v_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
||||
|
||||
static void BuildGammaTable( const float gamma, const float brightness, const float texgamma, const float lightgamma )
|
||||
{
|
||||
float g1, g2, g3;
|
||||
int i;
|
||||
|
||||
if( gamma != 0.0 )
|
||||
g1 = 1.0 / gamma;
|
||||
else g1 = 0.4;
|
||||
|
||||
g2 = g1 * texgamma;
|
||||
|
||||
if( brightness <= 0.0 )
|
||||
g3 = 0.125;
|
||||
else if( brightness <= 1.0 )
|
||||
g3 = 0.125 - brightness * brightness * 0.075;
|
||||
else
|
||||
g3 = 0.05;
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
double d = pow( i / 255.0, (double)g2 );
|
||||
int inf = d * 255.0;
|
||||
texgammatable[i] = bound( 0, inf, 255 );
|
||||
}
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
{
|
||||
double d;
|
||||
float f = pow( i / 1023.0, (double)lightgamma );
|
||||
int inf;
|
||||
|
||||
if( brightness > 1.0 )
|
||||
f *= brightness;
|
||||
|
||||
if( f <= g3 )
|
||||
f = ( f / g3 ) * 0.125;
|
||||
else
|
||||
f = (( f - g3 ) / ( 1.0 - g3 )) * 0.875 + 0.125;
|
||||
|
||||
d = pow( (double)f, (double)g1 ); // do not remove the cast, or tests fail
|
||||
inf = d * 1023.0;
|
||||
lightgammatable[i] = bound( 0, inf, 1023 );
|
||||
|
||||
// do these calculations in the same loop...
|
||||
lineargammatable[i] = pow( i / 1023.0, (double)gamma ) * 1023.0;
|
||||
screengammatable[i] = pow( i / 1023.0, 1.0 / gamma ) * 1023.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void V_ValidateGammaCvars( void )
|
||||
{
|
||||
if( v_gamma.value < 1.8f )
|
||||
Cvar_DirectSet( &v_gamma, "1.8" );
|
||||
else if( v_gamma.value > 3.0f )
|
||||
Cvar_DirectSet( &v_gamma, "3" );
|
||||
|
||||
if( v_texgamma.value < 1.8f )
|
||||
Cvar_DirectSet( &v_texgamma, "1.8" );
|
||||
else if( v_texgamma.value > 3.0f )
|
||||
Cvar_DirectSet( &v_texgamma, "3" );
|
||||
|
||||
if( v_lightgamma.value < 1.8f )
|
||||
Cvar_DirectSet( &v_lightgamma, "1.8" );
|
||||
else if( v_lightgamma.value > 3.0f )
|
||||
Cvar_DirectSet( &v_lightgamma, "3" );
|
||||
|
||||
if( v_brightness.value < 0.0f )
|
||||
Cvar_DirectSet( &v_brightness, "0" );
|
||||
else if( v_brightness.value > 3.0f )
|
||||
Cvar_DirectSet( &v_brightness, "3" );
|
||||
}
|
||||
|
||||
void V_CheckGamma( void )
|
||||
{
|
||||
static qboolean dirty = false;
|
||||
|
||||
// because these cvars were defined as archive
|
||||
// but wasn't doing anything useful
|
||||
// reset them into default values
|
||||
// this might be removed after a while
|
||||
if( v_direct.value == 1.0f || v_lightgamma.value == 1.0f )
|
||||
{
|
||||
Cvar_DirectSet( &v_direct, "0.9" );
|
||||
Cvar_DirectSet( &v_lightgamma, "2.5" );
|
||||
}
|
||||
|
||||
if( cls.scrshot_action == scrshot_envshot || cls.scrshot_action == scrshot_skyshot )
|
||||
{
|
||||
dirty = true; // force recalculate next normal frame
|
||||
BuildGammaTable( 1.8f, 0.0f, 2.0f, 2.5f );
|
||||
if( ref.initialized )
|
||||
ref.dllFuncs.R_GammaChanged( true );
|
||||
return;
|
||||
}
|
||||
|
||||
if( dirty || FBitSet( v_texgamma.flags|v_lightgamma.flags|v_brightness.flags|v_gamma.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
V_ValidateGammaCvars();
|
||||
|
||||
dirty = false;
|
||||
gamma_rebuilt = true;
|
||||
|
||||
BuildGammaTable( v_gamma.value, v_brightness.value, v_texgamma.value, v_lightgamma.value );
|
||||
|
||||
// force refdll to recalculate lightmaps
|
||||
if( ref.initialized )
|
||||
ref.dllFuncs.R_GammaChanged( false );
|
||||
}
|
||||
}
|
||||
|
||||
void V_CheckGammaEnd( void )
|
||||
{
|
||||
// don't reset changed flag if it was set during frame
|
||||
// keep it for next frame
|
||||
if( !gamma_rebuilt )
|
||||
return;
|
||||
|
||||
gamma_rebuilt = false;
|
||||
|
||||
// keep the flags until the end of frame so client.dll will catch these changes
|
||||
if( FBitSet( v_texgamma.flags|v_lightgamma.flags|v_brightness.flags|v_gamma.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
ClearBits( v_texgamma.flags, FCVAR_CHANGED );
|
||||
ClearBits( v_lightgamma.flags, FCVAR_CHANGED );
|
||||
ClearBits( v_brightness.flags, FCVAR_CHANGED );
|
||||
ClearBits( v_gamma.flags, FCVAR_CHANGED );
|
||||
}
|
||||
}
|
||||
|
||||
void V_Init( void )
|
||||
{
|
||||
Cvar_RegisterVariable( &v_texgamma );
|
||||
Cvar_RegisterVariable( &v_lightgamma );
|
||||
Cvar_RegisterVariable( &v_brightness );
|
||||
Cvar_RegisterVariable( &v_gamma );
|
||||
Cvar_RegisterVariable( &v_direct );
|
||||
|
||||
// force gamma init
|
||||
SetBits( v_gamma.flags, FCVAR_CHANGED );
|
||||
V_CheckGamma();
|
||||
}
|
||||
|
||||
byte TextureToGamma( byte b )
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||
return b;
|
||||
|
||||
return texgammatable[b];
|
||||
}
|
||||
|
||||
byte LightToTexGamma( byte b )
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||
return b;
|
||||
|
||||
// 255 << 2 is 1020, impossible to overflow
|
||||
return lightgammatable[b << 2] >> 2;
|
||||
}
|
||||
|
||||
uint LightToTexGammaEx( uint b )
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||
return b;
|
||||
|
||||
if( unlikely( b > ARRAYSIZE( lightgammatable )))
|
||||
return 0;
|
||||
|
||||
return lightgammatable[b];
|
||||
}
|
||||
|
||||
uint ScreenGammaTable( uint b )
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||
return b;
|
||||
|
||||
if( unlikely( b > ARRAYSIZE( screengammatable )))
|
||||
return 0;
|
||||
|
||||
return screengammatable[b];
|
||||
}
|
||||
|
||||
uint LinearGammaTable( uint b )
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||
return b;
|
||||
|
||||
if( unlikely( b > ARRAYSIZE( lineargammatable )))
|
||||
return 0;
|
||||
return lineargammatable[b];
|
||||
}
|
||||
|
||||
#if XASH_ENGINE_TESTS
|
||||
#include "tests.h"
|
||||
|
||||
typedef struct precomputed_gamma_tables_s
|
||||
{
|
||||
float gamma;
|
||||
float brightness;
|
||||
float texgamma;
|
||||
float lightgamma;
|
||||
byte texgammatable[256];
|
||||
int lightgammatable[1024];
|
||||
int lineargammatable[1024];
|
||||
int screengammatable[1024];
|
||||
} precomputed_gamma_tables_t;
|
||||
|
||||
// put at the end of the file, to not confuse Qt Creator's parser
|
||||
precomputed_gamma_tables_t *Test_GetGammaTables( int i );
|
||||
|
||||
static void Test_PrecomputedGammaTables( void )
|
||||
{
|
||||
precomputed_gamma_tables_t *data;
|
||||
int i = 0;
|
||||
|
||||
while(( data = Test_GetGammaTables( i )))
|
||||
{
|
||||
int j;
|
||||
|
||||
BuildGammaTable( data->gamma, data->brightness, data->texgamma, data->lightgamma );
|
||||
|
||||
for( j = 0; j < 1024; j++ )
|
||||
{
|
||||
if( j < 256 )
|
||||
{
|
||||
TASSERT_EQi( texgammatable[j], data->texgammatable[j] );
|
||||
}
|
||||
|
||||
TASSERT_EQi( lightgammatable[j], data->lightgammatable[j] );
|
||||
TASSERT_EQi( lineargammatable[j], data->lineargammatable[j] );
|
||||
TASSERT_EQi( screengammatable[j], data->screengammatable[j] );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void Test_RunGamma( void )
|
||||
{
|
||||
TRUN( Test_PrecomputedGammaTables() );
|
||||
}
|
||||
|
||||
precomputed_gamma_tables_t *Test_GetGammaTables( int i )
|
||||
{
|
||||
static precomputed_gamma_tables_t precomputed_data[] = {
|
||||
{
|
||||
.gamma = 2.5,
|
||||
.brightness = 0.0,
|
||||
.texgamma = 2.0,
|
||||
.lightgamma = 2.5,
|
||||
.texgammatable = {
|
||||
0, 3, 5, 7, 9, 10, 12, 14, 15, 17, 19, 20, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84,
|
||||
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 132, 133, 134, 135, 136, 137, 138,
|
||||
139, 140, 141, 142, 143, 144, 145, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 165, 166, 167, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 177, 178, 179, 180, 180, 181, 182, 183, 184, 185,
|
||||
186, 186, 187, 188, 189, 190, 191, 192, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 224, 224, 225, 226, 227, 228, 229,
|
||||
229, 230, 231, 232, 233, 233, 234, 235, 236, 237, 238, 238, 239, 240, 241, 242, 242, 243, 244, 245, 246, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, 255
|
||||
},
|
||||
.lightgammatable = {
|
||||
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
|
||||
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
|
||||
124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
|
||||
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
|
||||
280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331,
|
||||
332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 343, 343, 344, 345, 346, 347, 348, 349, 350, 351, 353, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 376, 376, 377, 379, 379, 380, 381, 382, 383,
|
||||
384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435,
|
||||
436, 437, 438, 439, 440, 441, 442, 443, 444, 446, 446, 447, 449, 449, 450, 451, 452, 453, 455, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 468, 469, 470, 470, 472, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487,
|
||||
488, 489, 490, 491, 493, 493, 494, 495, 496, 498, 498, 499, 500, 502, 502, 503, 504, 505, 507, 508, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 520, 521, 521, 522, 523, 524, 525, 526, 527, 528, 530, 530, 531, 532, 533, 534, 536, 536, 537, 538, 539,
|
||||
540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 552, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 564, 564, 565, 566, 567, 568, 570, 571, 571, 572, 573, 574, 576, 576, 577, 578, 579, 580, 581, 583, 583, 584, 585, 586, 587, 588, 590, 591, 591,
|
||||
593, 593, 594, 596, 596, 597, 598, 600, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 611, 611, 612, 613, 615, 615, 616, 618, 618, 620, 621, 621, 622, 624, 625, 626, 627, 627, 628, 629, 630, 632, 633, 633, 634, 635, 636, 638, 638, 639, 641, 642, 643, 643,
|
||||
644, 645, 646, 648, 648, 650, 651, 651, 652, 654, 655, 656, 656, 658, 658, 660, 660, 662, 662, 664, 664, 665, 666, 668, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 682, 682, 683, 684, 685, 686, 687, 688, 690, 690, 691, 692, 693, 695, 696,
|
||||
696, 697, 698, 699, 700, 701, 702, 703, 705, 706, 706, 707, 708, 709, 710, 711, 712, 713, 715, 716, 716, 717, 718, 719, 721, 721, 722, 724, 724, 725, 727, 727, 728, 729, 730, 731, 733, 733, 734, 735, 736, 737, 738, 740, 740, 741, 743, 744, 744, 745, 747, 747,
|
||||
748, 749, 750, 752, 753, 753, 755, 755, 757, 757, 758, 759, 760, 761, 762, 764, 764, 766, 766, 767, 769, 770, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 784, 785, 786, 788, 789, 790, 791, 792, 792, 794, 794, 796, 796, 797, 799, 800,
|
||||
801, 801, 802, 803, 804, 805, 806, 807, 809, 810, 810, 811, 813, 813, 815, 815, 816, 817, 819, 819, 820, 822, 823, 823, 824, 825, 826, 827, 829, 829, 830, 832, 832, 833, 835, 835, 837, 837, 839, 840, 840, 841, 842, 843, 844, 845, 847, 847, 849, 849, 850, 851,
|
||||
852, 854, 854, 856, 856, 857, 859, 859, 860, 861, 862, 864, 864, 865, 867, 867, 868, 870, 870, 872, 872, 874, 875, 875, 876, 877, 879, 880, 881, 881, 882, 883, 885, 885, 886, 887, 888, 890, 891, 891, 893, 893, 894, 895, 897, 898, 899, 900, 901, 902, 902, 903,
|
||||
904, 905, 907, 907, 908, 910, 910, 911, 912, 914, 914, 915, 917, 918, 919, 920, 921, 922, 922, 923, 925, 925, 926, 927, 928, 930, 931, 932, 932, 933, 935, 936, 936, 937, 939, 940, 940, 942, 942, 944, 944, 946, 947, 948, 949, 949, 950, 952, 952, 953, 955, 956,
|
||||
957, 958, 959, 959, 960, 962, 962, 964, 965, 965, 967, 967, 969, 970, 971, 972, 973, 973, 975, 975, 976, 977, 978, 979, 980, 982, 982, 984, 984, 986, 986, 988, 988, 990, 991, 992, 993, 993, 994, 995, 996, 998, 999, 999, 1000, 1002, 1002, 1004, 1005, 1005,
|
||||
1006, 1007, 1008, 1010, 1011, 1011, 1013, 1014, 1015, 1016, 1017, 1018, 1018, 1019, 1020, 1021, 1023
|
||||
},
|
||||
.lineargammatable = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11,
|
||||
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 25, 25,
|
||||
25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 43, 43, 43, 44, 44, 44, 45, 45, 46, 46, 46,
|
||||
47, 47, 48, 48, 48, 49, 49, 50, 50, 50, 51, 51, 52, 52, 52, 53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76,
|
||||
77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 92, 93, 94, 94, 95, 95, 96, 97, 97, 98, 99, 99, 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, 110, 111, 111, 112,
|
||||
113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 119, 120, 121, 122, 122, 123, 124, 124, 125, 126, 126, 127, 128, 129, 129, 130, 131, 132, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 140, 141, 142, 143, 144, 144, 145, 146, 147, 147, 148, 149, 150,
|
||||
151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 164, 164, 165, 166, 167, 168, 169, 169, 170, 171, 172, 173, 174, 175, 176, 176, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 193, 194,
|
||||
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
|
||||
247, 248, 249, 250, 251, 252, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 282, 283, 284, 285, 286, 287, 289, 290, 291, 292, 293, 294, 296, 297, 298, 299, 300, 302, 303, 304, 305,
|
||||
306, 308, 309, 310, 311, 312, 314, 315, 316, 317, 319, 320, 321, 322, 324, 325, 326, 327, 329, 330, 331, 333, 334, 335, 336, 338, 339, 340, 342, 343, 344, 345, 347, 348, 349, 351, 352, 353, 355, 356, 357, 359, 360, 361, 363, 364, 365, 367, 368, 369, 371, 372,
|
||||
373, 375, 376, 378, 379, 380, 382, 383, 384, 386, 387, 389, 390, 391, 393, 394, 396, 397, 399, 400, 401, 403, 404, 406, 407, 409, 410, 411, 413, 414, 416, 417, 419, 420, 422, 423, 425, 426, 428, 429, 431, 432, 434, 435, 437, 438, 440, 441, 443, 444, 446, 447,
|
||||
449, 450, 452, 453, 455, 456, 458, 459, 461, 462, 464, 466, 467, 469, 470, 472, 473, 475, 477, 478, 480, 481, 483, 485, 486, 488, 489, 491, 493, 494, 496, 497, 499, 501, 502, 504, 506, 507, 509, 511, 512, 514, 515, 517, 519, 520, 522, 524, 525, 527, 529, 531,
|
||||
532, 534, 536, 537, 539, 541, 542, 544, 546, 548, 549, 551, 553, 554, 556, 558, 560, 561, 563, 565, 567, 568, 570, 572, 574, 575, 577, 579, 581, 583, 584, 586, 588, 590, 592, 593, 595, 597, 599, 601, 602, 604, 606, 608, 610, 612, 613, 615, 617, 619, 621, 623,
|
||||
625, 626, 628, 630, 632, 634, 636, 638, 639, 641, 643, 645, 647, 649, 651, 653, 655, 657, 659, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724,
|
||||
726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 753, 755, 757, 759, 761, 763, 765, 767, 769, 771, 773, 776, 778, 780, 782, 784, 786, 788, 791, 793, 795, 797, 799, 801, 803, 806, 808, 810, 812, 814, 816, 819, 821, 823, 825, 827, 830, 832, 834,
|
||||
836, 839, 841, 843, 845, 847, 850, 852, 854, 856, 859, 861, 863, 865, 868, 870, 872, 874, 877, 879, 881, 884, 886, 888, 890, 893, 895, 897, 900, 902, 904, 907, 909, 911, 914, 916, 918, 921, 923, 925, 928, 930, 932, 935, 937, 940, 942, 944, 947, 949, 952, 954,
|
||||
956, 959, 961, 964, 966, 968, 971, 973, 976, 978, 981, 983, 985, 988, 990, 993, 995, 998, 1000, 1003, 1005, 1008, 1010, 1013, 1015, 1018, 1020, 1023
|
||||
},
|
||||
.screengammatable = {
|
||||
0, 63, 84, 99, 111, 121, 130, 139, 146, 154, 160, 166, 172, 178, 183, 188, 193, 198, 203, 207, 212, 216, 220, 224, 228, 231, 235, 239, 242, 245, 249, 252, 255, 259, 262, 265, 268, 271, 274, 276, 279, 282, 285, 287, 290, 293, 295, 298, 300, 303, 305, 308,
|
||||
310, 313, 315, 317, 320, 322, 324, 326, 328, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 369, 370, 372, 374, 376, 378, 379, 381, 383, 385, 386, 388, 390, 392, 393, 395, 397, 398, 400, 401, 403, 405, 406, 408,
|
||||
409, 411, 413, 414, 416, 417, 419, 420, 422, 423, 425, 426, 428, 429, 431, 432, 434, 435, 436, 438, 439, 441, 442, 444, 445, 446, 448, 449, 450, 452, 453, 455, 456, 457, 459, 460, 461, 463, 464, 465, 466, 468, 469, 470, 472, 473, 474, 475, 477, 478, 479, 480,
|
||||
482, 483, 484, 485, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 499, 500, 501, 502, 503, 504, 505, 507, 508, 509, 510, 511, 512, 513, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539,
|
||||
540, 541, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 585, 586, 587, 588, 589, 590,
|
||||
591, 592, 593, 594, 595, 595, 596, 597, 598, 599, 600, 601, 602, 603, 603, 604, 605, 606, 607, 608, 609, 610, 610, 611, 612, 613, 614, 615, 616, 616, 617, 618, 619, 620, 621, 622, 622, 623, 624, 625, 626, 627, 627, 628, 629, 630, 631, 632, 632, 633, 634, 635,
|
||||
636, 637, 637, 638, 639, 640, 641, 641, 642, 643, 644, 645, 645, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, 656, 657, 658, 659, 659, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, 669, 670, 671, 672, 672, 673, 674, 675, 675,
|
||||
676, 677, 678, 678, 679, 680, 681, 681, 682, 683, 684, 684, 685, 686, 686, 687, 688, 689, 689, 690, 691, 692, 692, 693, 694, 694, 695, 696, 697, 697, 698, 699, 699, 700, 701, 701, 702, 703, 704, 704, 705, 706, 706, 707, 708, 708, 709, 710, 711, 711, 712, 713,
|
||||
713, 714, 715, 715, 716, 717, 717, 718, 719, 719, 720, 721, 721, 722, 723, 723, 724, 725, 725, 726, 727, 727, 728, 729, 729, 730, 731, 731, 732, 733, 733, 734, 735, 735, 736, 737, 737, 738, 739, 739, 740, 741, 741, 742, 743, 743, 744, 745, 745, 746, 746, 747,
|
||||
748, 748, 749, 750, 750, 751, 752, 752, 753, 753, 754, 755, 755, 756, 757, 757, 758, 758, 759, 760, 760, 761, 762, 762, 763, 763, 764, 765, 765, 766, 767, 767, 768, 768, 769, 770, 770, 771, 771, 772, 773, 773, 774, 774, 775, 776, 776, 777, 778, 778, 779, 779,
|
||||
780, 781, 781, 782, 782, 783, 784, 784, 785, 785, 786, 786, 787, 788, 788, 789, 789, 790, 791, 791, 792, 792, 793, 794, 794, 795, 795, 796, 796, 797, 798, 798, 799, 799, 800, 801, 801, 802, 802, 803, 803, 804, 805, 805, 806, 806, 807, 807, 808, 809, 809, 810,
|
||||
810, 811, 811, 812, 813, 813, 814, 814, 815, 815, 816, 816, 817, 818, 818, 819, 819, 820, 820, 821, 821, 822, 823, 823, 824, 824, 825, 825, 826, 826, 827, 828, 828, 829, 829, 830, 830, 831, 831, 832, 832, 833, 834, 834, 835, 835, 836, 836, 837, 837, 838, 838,
|
||||
839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 844, 845, 845, 846, 846, 847, 848, 848, 849, 849, 850, 850, 851, 851, 852, 852, 853, 853, 854, 854, 855, 855, 856, 856, 857, 857, 858, 859, 859, 860, 860, 861, 861, 862, 862, 863, 863, 864, 864, 865, 865, 866,
|
||||
866, 867, 867, 868, 868, 869, 869, 870, 870, 871, 871, 872, 872, 873, 873, 874, 874, 875, 875, 876, 876, 877, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 890, 891, 891, 892,
|
||||
892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 897, 898, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903, 904, 904, 904, 905, 905, 906, 906, 907, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 912, 913, 913, 914, 914, 915, 915, 915, 916, 916, 917,
|
||||
917, 918, 918, 919, 919, 920, 920, 921, 921, 922, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 927, 928, 928, 929, 929, 929, 930, 930, 931, 931, 932, 932, 933, 933, 934, 934, 935, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 940, 941,
|
||||
941, 942, 942, 943, 943, 944, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 949, 949, 950, 950, 951, 951, 952, 952, 953, 953, 953, 954, 954, 955, 955, 956, 956, 957, 957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 961, 962, 962, 963, 963, 964, 964,
|
||||
964, 965, 965, 966, 966, 967, 967, 968, 968, 968, 969, 969, 970, 970, 971, 971, 971, 972, 972, 973, 973, 974, 974, 974, 975, 975, 976, 976, 977, 977, 977, 978, 978, 979, 979, 980, 980, 980, 981, 981, 982, 982, 983, 983, 983, 984, 984, 985, 985, 986, 986, 986,
|
||||
987, 987, 988, 988, 988, 989, 989, 990, 990, 991, 991, 991, 992, 992, 993, 993, 993, 994, 994, 995, 995, 996, 996, 996, 997, 997, 998, 998, 998, 999, 999, 1000, 1000, 1001, 1001, 1001, 1002, 1002, 1003, 1003, 1003, 1004, 1004, 1005, 1005, 1005, 1006, 1006,
|
||||
1007, 1007, 1008, 1008, 1008, 1009, 1009, 1010, 1010, 1010, 1011, 1011, 1012, 1012, 1012, 1013, 1013, 1014, 1014, 1014, 1015, 1015, 1016, 1016, 1016, 1017, 1017, 1018, 1018, 1018, 1019, 1019, 1020, 1020, 1020, 1021, 1021, 1022, 1022, 1023
|
||||
},
|
||||
}, {
|
||||
.gamma = 2.2,
|
||||
.brightness = 1.0,
|
||||
.texgamma = 2.2,
|
||||
.lightgamma = 2.4,
|
||||
.texgammatable = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
|
||||
66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
|
||||
124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
|
||||
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||
},
|
||||
.lightgammatable = {
|
||||
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 45, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67, 69, 70, 71, 72, 74, 75, 76,
|
||||
78, 79, 80, 81, 83, 84, 85, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 116, 117, 118, 120, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 147, 148, 149,
|
||||
151, 152, 153, 155, 156, 157, 159, 160, 162, 163, 164, 166, 167, 168, 170, 171, 173, 174, 175, 177, 178, 179, 181, 182, 184, 185, 186, 188, 189, 191, 192, 193, 195, 196, 198, 199, 200, 202, 203, 204, 206, 207, 209, 210, 211, 213, 214, 216, 217, 219, 220, 221,
|
||||
223, 224, 226, 227, 228, 230, 231, 233, 234, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 250, 251, 252, 254, 255, 257, 258, 260, 261, 262, 264, 265, 267, 268, 270, 271, 272, 274, 275, 277, 278, 280, 281, 282, 284, 285, 287, 288, 290, 291, 293, 294, 295,
|
||||
297, 298, 300, 301, 303, 304, 306, 307, 308, 310, 311, 313, 314, 316, 317, 319, 320, 321, 323, 324, 326, 327, 329, 330, 332, 333, 335, 336, 337, 339, 340, 342, 343, 345, 346, 348, 349, 351, 352, 354, 355, 356, 358, 359, 361, 362, 364, 365, 367, 368, 370, 371,
|
||||
373, 374, 376, 377, 378, 380, 381, 383, 384, 386, 387, 389, 390, 392, 393, 395, 396, 397, 398, 398, 399, 399, 400, 401, 401, 402, 402, 403, 403, 404, 404, 405, 406, 406, 407, 407, 408, 408, 409, 410, 410, 411, 411, 412, 413, 413, 414, 414, 415, 416, 416, 417,
|
||||
417, 418, 419, 419, 420, 420, 421, 422, 422, 423, 423, 424, 425, 425, 426, 427, 427, 428, 428, 429, 430, 430, 431, 432, 432, 433, 433, 434, 435, 435, 436, 437, 437, 438, 439, 439, 440, 441, 441, 442, 443, 443, 444, 445, 445, 446, 447, 447, 448, 449, 449, 450,
|
||||
451, 451, 452, 453, 453, 454, 455, 455, 456, 457, 457, 458, 459, 459, 460, 461, 461, 462, 463, 464, 464, 465, 466, 466, 467, 468, 468, 469, 470, 471, 471, 472, 473, 473, 474, 475, 476, 476, 477, 478, 478, 479, 480, 481, 481, 482, 483, 483, 484, 485, 486, 486,
|
||||
487, 488, 489, 489, 490, 491, 492, 492, 493, 494, 495, 495, 496, 497, 498, 498, 499, 500, 501, 501, 502, 503, 504, 504, 505, 506, 507, 507, 508, 509, 510, 510, 511, 512, 513, 513, 514, 515, 516, 517, 517, 518, 519, 520, 520, 521, 522, 523, 524, 524, 525, 526,
|
||||
527, 527, 528, 529, 530, 531, 531, 532, 533, 534, 535, 535, 536, 537, 538, 538, 539, 540, 541, 542, 542, 543, 544, 545, 546, 546, 547, 548, 549, 550, 550, 551, 552, 553, 554, 555, 555, 556, 557, 558, 559, 559, 560, 561, 562, 563, 564, 564, 565, 566, 567, 568,
|
||||
568, 569, 570, 571, 572, 573, 573, 574, 575, 576, 577, 578, 578, 579, 580, 581, 582, 583, 583, 584, 585, 586, 587, 588, 588, 589, 590, 591, 592, 593, 593, 594, 595, 596, 597, 598, 599, 599, 600, 601, 602, 603, 604, 605, 605, 606, 607, 608, 609, 610, 611, 611,
|
||||
612, 613, 614, 615, 616, 617, 617, 618, 619, 620, 621, 622, 623, 623, 624, 625, 626, 627, 628, 629, 629, 630, 631, 632, 633, 634, 635, 636, 636, 637, 638, 639, 640, 641, 642, 643, 643, 644, 645, 646, 647, 648, 649, 650, 651, 651, 652, 653, 654, 655, 656, 657,
|
||||
658, 658, 659, 660, 661, 662, 663, 664, 665, 666, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 703,
|
||||
704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 749, 750, 751,
|
||||
752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 795, 796, 797, 798, 799, 800,
|
||||
801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850,
|
||||
851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 900,
|
||||
901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952,
|
||||
953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
|
||||
1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1023
|
||||
},
|
||||
.lineargammatable = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36,
|
||||
36, 36, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 42, 42, 42, 43, 43, 44, 44, 44, 45, 45, 46, 46, 46, 47, 47, 48, 48, 48, 49, 49, 50, 50, 51, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 61, 62, 62, 63,
|
||||
63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 93, 93, 94, 94, 95, 96, 96, 97, 97, 98, 99,
|
||||
99, 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, 110, 111, 111, 112, 113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 119, 120, 121, 121, 122, 123, 123, 124, 125, 126, 126, 127, 128, 128, 129, 130, 131, 131, 132, 133, 133,
|
||||
134, 135, 136, 136, 137, 138, 139, 139, 140, 141, 142, 142, 143, 144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 163, 164, 165, 166, 167, 167, 168, 169, 170, 171, 172, 172, 173, 174,
|
||||
175, 176, 177, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
|
||||
222, 223, 224, 225, 226, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
|
||||
274, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 288, 289, 290, 291, 292, 293, 294, 295, 296, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 310, 311, 312, 313, 315, 316, 317, 318, 319, 320, 322, 323, 324, 325, 326, 328, 329, 330, 331, 332,
|
||||
333, 335, 336, 337, 338, 339, 341, 342, 343, 344, 346, 347, 348, 349, 350, 352, 353, 354, 355, 357, 358, 359, 360, 362, 363, 364, 365, 367, 368, 369, 370, 372, 373, 374, 375, 377, 378, 379, 381, 382, 383, 384, 386, 387, 388, 390, 391, 392, 393, 395, 396, 397,
|
||||
399, 400, 401, 403, 404, 405, 407, 408, 409, 411, 412, 413, 415, 416, 417, 419, 420, 421, 423, 424, 426, 427, 428, 430, 431, 432, 434, 435, 437, 438, 439, 441, 442, 443, 445, 446, 448, 449, 450, 452, 453, 455, 456, 458, 459, 460, 462, 463, 465, 466, 468, 469,
|
||||
470, 472, 473, 475, 476, 478, 479, 481, 482, 483, 485, 486, 488, 489, 491, 492, 494, 495, 497, 498, 500, 501, 503, 504, 506, 507, 509, 510, 512, 513, 515, 516, 518, 519, 521, 522, 524, 525, 527, 528, 530, 532, 533, 535, 536, 538, 539, 541, 542, 544, 545, 547,
|
||||
549, 550, 552, 553, 555, 556, 558, 560, 561, 563, 564, 566, 568, 569, 571, 572, 574, 576, 577, 579, 580, 582, 584, 585, 587, 589, 590, 592, 593, 595, 597, 598, 600, 602, 603, 605, 607, 608, 610, 612, 613, 615, 617, 618, 620, 622, 623, 625, 627, 628, 630, 632,
|
||||
633, 635, 637, 639, 640, 642, 644, 645, 647, 649, 650, 652, 654, 656, 657, 659, 661, 663, 664, 666, 668, 670, 671, 673, 675, 677, 678, 680, 682, 684, 685, 687, 689, 691, 692, 694, 696, 698, 700, 701, 703, 705, 707, 709, 710, 712, 714, 716, 718, 719, 721, 723,
|
||||
725, 727, 729, 730, 732, 734, 736, 738, 740, 741, 743, 745, 747, 749, 751, 753, 754, 756, 758, 760, 762, 764, 766, 767, 769, 771, 773, 775, 777, 779, 781, 783, 785, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 809, 811, 813, 815, 817, 819, 821,
|
||||
823, 825, 827, 829, 831, 833, 835, 837, 839, 841, 843, 845, 847, 849, 851, 853, 855, 857, 859, 861, 863, 865, 867, 869, 871, 873, 875, 877, 879, 881, 883, 885, 887, 889, 891, 893, 895, 897, 899, 901, 903, 905, 907, 910, 912, 914, 916, 918, 920, 922, 924, 926,
|
||||
928, 930, 932, 934, 937, 939, 941, 943, 945, 947, 949, 951, 953, 956, 958, 960, 962, 964, 966, 968, 970, 973, 975, 977, 979, 981, 983, 985, 988, 990, 992, 994, 996, 998, 1001, 1003, 1005, 1007, 1009, 1012, 1014, 1016, 1018, 1020, 1023
|
||||
},
|
||||
.screengammatable = {
|
||||
0, 43, 60, 72, 82, 91, 98, 106, 112, 118, 124, 130, 135, 140, 145, 150, 154, 158, 163, 167, 171, 174, 178, 182, 185, 189, 192, 196, 199, 202, 205, 208, 211, 214, 217, 220, 223, 226, 228, 231, 234, 237, 239, 242, 244, 247, 249, 252, 254, 257, 259, 261,
|
||||
264, 266, 268, 270, 273, 275, 277, 279, 281, 283, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 311, 313, 315, 317, 319, 321, 323, 324, 326, 328, 330, 331, 333, 335, 337, 338, 340, 342, 343, 345, 347, 348, 350, 352, 353, 355, 357, 358, 360,
|
||||
361, 363, 365, 366, 368, 369, 371, 372, 374, 375, 377, 378, 380, 381, 383, 384, 386, 387, 389, 390, 392, 393, 394, 396, 397, 399, 400, 401, 403, 404, 406, 407, 408, 410, 411, 412, 414, 415, 416, 418, 419, 420, 422, 423, 424, 426, 427, 428, 430, 431, 432, 433,
|
||||
435, 436, 437, 438, 440, 441, 442, 443, 445, 446, 447, 448, 450, 451, 452, 453, 454, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 477, 478, 479, 480, 481, 482, 483, 484, 486, 487, 488, 489, 490, 491, 492, 493, 494,
|
||||
495, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 545, 546, 547,
|
||||
548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 583, 584, 585, 586, 587, 588, 589, 590, 591, 591, 592, 593, 594, 595,
|
||||
596, 597, 598, 598, 599, 600, 601, 602, 603, 604, 604, 605, 606, 607, 608, 609, 609, 610, 611, 612, 613, 614, 615, 615, 616, 617, 618, 619, 620, 620, 621, 622, 623, 624, 624, 625, 626, 627, 628, 629, 629, 630, 631, 632, 633, 633, 634, 635, 636, 637, 637, 638,
|
||||
639, 640, 641, 641, 642, 643, 644, 645, 645, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, 656, 657, 658, 659, 659, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, 669, 670, 671, 672, 672, 673, 674, 675, 675, 676, 677, 678, 678,
|
||||
679, 680, 681, 681, 682, 683, 684, 684, 685, 686, 686, 687, 688, 689, 689, 690, 691, 692, 692, 693, 694, 694, 695, 696, 697, 697, 698, 699, 700, 700, 701, 702, 702, 703, 704, 705, 705, 706, 707, 707, 708, 709, 709, 710, 711, 712, 712, 713, 714, 714, 715, 716,
|
||||
716, 717, 718, 719, 719, 720, 721, 721, 722, 723, 723, 724, 725, 725, 726, 727, 728, 728, 729, 730, 730, 731, 732, 732, 733, 734, 734, 735, 736, 736, 737, 738, 738, 739, 740, 740, 741, 742, 742, 743, 744, 744, 745, 746, 746, 747, 748, 748, 749, 750, 750, 751,
|
||||
752, 752, 753, 754, 754, 755, 756, 756, 757, 758, 758, 759, 759, 760, 761, 761, 762, 763, 763, 764, 765, 765, 766, 767, 767, 768, 769, 769, 770, 770, 771, 772, 772, 773, 774, 774, 775, 776, 776, 777, 777, 778, 779, 779, 780, 781, 781, 782, 782, 783, 784, 784,
|
||||
785, 786, 786, 787, 787, 788, 789, 789, 790, 791, 791, 792, 792, 793, 794, 794, 795, 795, 796, 797, 797, 798, 799, 799, 800, 800, 801, 802, 802, 803, 803, 804, 805, 805, 806, 806, 807, 808, 808, 809, 809, 810, 811, 811, 812, 812, 813, 814, 814, 815, 815, 816,
|
||||
817, 817, 818, 818, 819, 820, 820, 821, 821, 822, 823, 823, 824, 824, 825, 825, 826, 827, 827, 828, 828, 829, 830, 830, 831, 831, 832, 833, 833, 834, 834, 835, 835, 836, 837, 837, 838, 838, 839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 845, 845, 846, 846,
|
||||
847, 847, 848, 849, 849, 850, 850, 851, 851, 852, 853, 853, 854, 854, 855, 855, 856, 857, 857, 858, 858, 859, 859, 860, 860, 861, 862, 862, 863, 863, 864, 864, 865, 865, 866, 867, 867, 868, 868, 869, 869, 870, 870, 871, 872, 872, 873, 873, 874, 874, 875, 875,
|
||||
876, 876, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 891, 891, 892, 892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 898, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903,
|
||||
904, 904, 905, 905, 906, 906, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 912, 913, 913, 914, 914, 915, 915, 916, 916, 917, 917, 918, 918, 919, 920, 920, 921, 921, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 927, 928, 928, 929, 929, 930, 930,
|
||||
931, 931, 932, 932, 933, 933, 934, 934, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 941, 941, 942, 942, 943, 943, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 949, 950, 950, 951, 951, 952, 952, 953, 953, 954, 954, 955, 955, 956, 956,
|
||||
957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 962, 962, 963, 963, 964, 964, 965, 965, 966, 966, 967, 967, 968, 968, 969, 969, 969, 970, 970, 971, 971, 972, 972, 973, 973, 974, 974, 975, 975, 976, 976, 977, 977, 978, 978, 979, 979, 980, 980, 981, 981, 982,
|
||||
982, 982, 983, 983, 984, 984, 985, 985, 986, 986, 987, 987, 988, 988, 989, 989, 990, 990, 991, 991, 991, 992, 992, 993, 993, 994, 994, 995, 995, 996, 996, 997, 997, 998, 998, 999, 999, 999, 1000, 1000, 1001, 1001, 1002, 1002, 1003, 1003, 1004, 1004, 1005,
|
||||
1005, 1006, 1006, 1006, 1007, 1007, 1008, 1008, 1009, 1009, 1010, 1010, 1011, 1011, 1012, 1012, 1012, 1013, 1013, 1014, 1014, 1015, 1015, 1016, 1016, 1017, 1017, 1017, 1018, 1018, 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, 1023
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
if( i < 0 || i >= ARRAYSIZE( precomputed_data ))
|
||||
return NULL;
|
||||
|
||||
return &precomputed_data[i];
|
||||
}
|
||||
#endif
|
|
@ -134,7 +134,7 @@ static void Joy_ProcessTrigger( const engineAxis_t engineAxis, short value )
|
|||
trigThreshold = joy_lt_threshold.value;
|
||||
break;
|
||||
default:
|
||||
Con_Reportf( S_ERROR "%s: invalid axis = %i\n", __func__, engineAxis );
|
||||
Con_Reportf( S_ERROR "Joy_ProcessTrigger: invalid axis = %i", engineAxis );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ static void Joy_ProcessStick( const engineAxis_t engineAxis, short value )
|
|||
case JOY_AXIS_PITCH: deadzone = joy_pitch_deadzone.value; break;
|
||||
case JOY_AXIS_YAW: deadzone = joy_yaw_deadzone.value; break;
|
||||
default:
|
||||
Con_Reportf( S_ERROR "%s: invalid axis = %i\n", __func__, engineAxis );
|
||||
Con_Reportf( S_ERROR "Joy_ProcessStick: invalid axis = %i", engineAxis );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ static void Joy_ProcessStick( const engineAxis_t engineAxis, short value )
|
|||
|
||||
// fwd/side axis simulate hat movement
|
||||
if( ( engineAxis == JOY_AXIS_SIDE || engineAxis == JOY_AXIS_FWD ) &&
|
||||
( cls.key_dest == key_menu || cls.key_dest == key_console ))
|
||||
( CL_IsInMenu() || CL_IsInConsole() ) )
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ Touch_DumpConfig
|
|||
Dump config to file
|
||||
=================
|
||||
*/
|
||||
static qboolean Touch_DumpConfig( const char *name, const char *profilename )
|
||||
qboolean Touch_DumpConfig( const char *name, const char *profilename )
|
||||
{
|
||||
file_t *f;
|
||||
touch_button_t *button;
|
||||
|
@ -333,7 +333,7 @@ void Touch_WriteConfig( void )
|
|||
if( Sys_CheckParm( "-nowriteconfig" ) || !touch.configchanged || !touch.config_loaded )
|
||||
return;
|
||||
|
||||
Con_DPrintf( "%s: %s\n", __func__, touch_config_file.string );
|
||||
Con_DPrintf( "Touch_WriteConfig(): %s\n", touch_config_file.string );
|
||||
|
||||
Q_snprintf( newconfigfile, sizeof( newconfigfile ), "%s.new", touch_config_file.string );
|
||||
Q_snprintf( oldconfigfile, sizeof( oldconfigfile ), "%s.bak", touch_config_file.string );
|
||||
|
@ -1064,7 +1064,7 @@ void Touch_Init( void )
|
|||
return;
|
||||
touch.mempool = Mem_AllocPool( "Touch" );
|
||||
//touch.first = touch.last = NULL;
|
||||
Con_Printf( "%s()\n", __func__ );
|
||||
Con_Printf( "IN_TouchInit()\n");
|
||||
touch.move_finger = touch.resize_finger = touch.look_finger = touch.wheel_finger = -1;
|
||||
touch.state = state_none;
|
||||
touch.showeditbuttons = true;
|
||||
|
@ -1217,10 +1217,10 @@ static qboolean Touch_IsVisible( touch_button_t *button )
|
|||
if( FBitSet( button->flags, TOUCH_FL_HIDE ))
|
||||
return false; // skip hidden
|
||||
|
||||
if( FBitSet( button->flags, TOUCH_FL_SP ) && cl.maxclients != 1 )
|
||||
if( FBitSet( button->flags, TOUCH_FL_SP ) && CL_GetMaxClients() != 1 )
|
||||
return false; // skip singleplayer(load, save) buttons in multiplayer
|
||||
|
||||
if( FBitSet( button->flags, TOUCH_FL_MP ) && cl.maxclients == 1 )
|
||||
if( FBitSet( button->flags, TOUCH_FL_MP ) && CL_GetMaxClients() == 1 )
|
||||
return false; // skip multiplayer buttons in singleplayer
|
||||
|
||||
return true;
|
||||
|
@ -2029,18 +2029,10 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx
|
|||
{
|
||||
touch.move_finger = touch.resize_finger = touch.look_finger = -1;
|
||||
// Hack for keyboard, hope it help
|
||||
// a1ba: this is absolutely horrible
|
||||
if( cls.key_dest == key_console || cls.key_dest == key_message )
|
||||
{
|
||||
static float x1 = 0.0f;
|
||||
x1 += dx;
|
||||
|
||||
if( type == event_up ) // don't show keyboard on every tap
|
||||
{
|
||||
if ( type == event_down ) // don't pop it again on event_up
|
||||
Key_EnableTextInput( true, true );
|
||||
x1 = 0.0f;
|
||||
}
|
||||
|
||||
if( cls.key_dest == key_console )
|
||||
{
|
||||
static float y1 = 0;
|
||||
|
@ -2062,13 +2054,6 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx
|
|||
// exit of console area
|
||||
if( type == event_down && x < 0.1f && y > 0.9f )
|
||||
Cbuf_AddText( "escape\n" );
|
||||
|
||||
// swipe from edge to exit console/chat
|
||||
if(( x > 0.8f && x1 < -0.1f ) || ( x < 0.2f && x1 > 0.1f ))
|
||||
{
|
||||
Cbuf_AddText( "escape\n" );
|
||||
x1 = 0.0f;
|
||||
}
|
||||
}
|
||||
UI_MouseMove( TO_SCRN_X(x), TO_SCRN_Y(y) );
|
||||
//MsgDev( D_NOTE, "touch %d %d\n", TO_SCRN_X(x), TO_SCRN_Y(y) );
|
||||
|
@ -2163,7 +2148,8 @@ void Touch_KeyEvent( int key, int down )
|
|||
x = xi / SCR_W;
|
||||
y = yi / SCR_H;
|
||||
|
||||
// Con_DPrintf( "event %d %.2f %.2f %.2f %.2f\n", event, x, y, x - lx, y - ly );
|
||||
Con_DPrintf( "event %d %.2f %.2f %.2f %.2f\n",
|
||||
event, x, y, x - lx, y - ly );
|
||||
|
||||
IN_TouchEvent( event, finger, x, y, x - lx, y - ly );
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ GNU General Public License for more details.
|
|||
#include "input.h"
|
||||
#include "client.h"
|
||||
#include "vgui_draw.h"
|
||||
#include "cursor_type.h"
|
||||
|
||||
#if XASH_SDL
|
||||
#include <SDL.h>
|
||||
|
@ -108,7 +107,7 @@ void IN_LockInputDevices( qboolean lock )
|
|||
IN_StartupMouse
|
||||
===========
|
||||
*/
|
||||
static void IN_StartupMouse( void )
|
||||
void IN_StartupMouse( void )
|
||||
{
|
||||
Cvar_RegisterVariable( &m_ignore );
|
||||
|
||||
|
@ -124,6 +123,11 @@ static void IN_StartupMouse( void )
|
|||
in_mouseinitialized = true;
|
||||
}
|
||||
|
||||
void GAME_EXPORT IN_SetCursor( void *hCursor )
|
||||
{
|
||||
// stub
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_MouseSavePos
|
||||
|
@ -202,7 +206,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
|||
}
|
||||
}
|
||||
|
||||
static void IN_CheckMouseState( qboolean active )
|
||||
void IN_CheckMouseState( qboolean active )
|
||||
{
|
||||
static qboolean s_bRawInput, s_bMouseGrab;
|
||||
|
||||
|
@ -309,7 +313,7 @@ void IN_DeactivateMouse( void )
|
|||
IN_MouseMove
|
||||
================
|
||||
*/
|
||||
static void IN_MouseMove( void )
|
||||
void IN_MouseMove( void )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
@ -584,7 +588,7 @@ void IN_EngineAppendMove( float frametime, void *cmd1, qboolean active )
|
|||
}
|
||||
}
|
||||
|
||||
static void IN_Commands( void )
|
||||
void IN_Commands( void )
|
||||
{
|
||||
#if XASH_USE_EVDEV
|
||||
IN_EvdevFrame();
|
||||
|
|
|
@ -40,6 +40,7 @@ void IN_DeactivateMouse( void );
|
|||
void IN_MouseSavePos( void );
|
||||
void IN_MouseRestorePos( void );
|
||||
void IN_ToggleClientMouse( int newstate, int oldstate );
|
||||
void IN_SetCursor( void *hCursor );
|
||||
|
||||
uint IN_CollectInputDevices( void );
|
||||
void IN_LockInputDevices( qboolean lock );
|
||||
|
|
|
@ -332,7 +332,7 @@ int Key_GetKey( const char *pBinding )
|
|||
Key_Unbind_f
|
||||
===================
|
||||
*/
|
||||
static void Key_Unbind_f( void )
|
||||
void Key_Unbind_f( void )
|
||||
{
|
||||
int b;
|
||||
|
||||
|
@ -358,7 +358,7 @@ static void Key_Unbind_f( void )
|
|||
Key_Unbindall_f
|
||||
===================
|
||||
*/
|
||||
static void Key_Unbindall_f( void )
|
||||
void Key_Unbindall_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -378,7 +378,7 @@ static void Key_Unbindall_f( void )
|
|||
Key_Reset_f
|
||||
===================
|
||||
*/
|
||||
static void Key_Reset_f( void )
|
||||
void Key_Reset_f( void )
|
||||
{
|
||||
keyname_t *kn;
|
||||
int i;
|
||||
|
@ -400,7 +400,7 @@ static void Key_Reset_f( void )
|
|||
Key_Bind_f
|
||||
===================
|
||||
*/
|
||||
static void Key_Bind_f( void )
|
||||
void Key_Bind_f( void )
|
||||
{
|
||||
char cmd[1024];
|
||||
int i, c, b;
|
||||
|
@ -473,7 +473,7 @@ Key_Bindlist_f
|
|||
|
||||
============
|
||||
*/
|
||||
static void Key_Bindlist_f( void )
|
||||
void Key_Bindlist_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -523,7 +523,7 @@ void Key_Init( void )
|
|||
Key_AddKeyCommands
|
||||
===================
|
||||
*/
|
||||
static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
|
||||
void Key_AddKeyCommands( int key, const char *kb, qboolean down )
|
||||
{
|
||||
char button[1024];
|
||||
char *buttonPtr;
|
||||
|
@ -553,7 +553,7 @@ static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
|
|||
}
|
||||
|
||||
buttonPtr = button;
|
||||
while((((byte)kb[i]) <= ' ' || kb[i] == ';' ) && kb[i] != 0 )
|
||||
while(( kb[i] <= ' ' || kb[i] == ';' ) && kb[i] != 0 )
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -749,10 +749,10 @@ void GAME_EXPORT Key_Event( int key, int down )
|
|||
if( cls.key_dest == key_menu )
|
||||
{
|
||||
// only non printable keys passed
|
||||
if( !gameui.use_extended_api )
|
||||
if( !gameui.use_text_api )
|
||||
Key_EnableTextInput( true, false );
|
||||
//pass printable chars for old menus
|
||||
if( !gameui.use_extended_api && !host.textmode && down && ( key >= 32 ) && ( key <= 'z' ) )
|
||||
if( !gameui.use_text_api && !host.textmode && down && ( key >= 32 ) && ( key <= 'z' ) )
|
||||
{
|
||||
if( Key_IsDown( K_SHIFT ) )
|
||||
{
|
||||
|
@ -840,7 +840,7 @@ void GAME_EXPORT Key_SetKeyDest( int key_dest )
|
|||
cls.key_dest = key_message;
|
||||
break;
|
||||
default:
|
||||
Host_Error( "%s: wrong destination (%i)\n", __func__, key_dest );
|
||||
Host_Error( "Key_SetKeyDest: wrong destination (%i)\n", key_dest );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1055,16 +1055,18 @@ static qboolean OSK_KeyEvent( int key, int down )
|
|||
break;
|
||||
}
|
||||
|
||||
ch = (byte)osk.curbutton.val;
|
||||
|
||||
// do not pass UTF-8 sequence into the engine, convert it here
|
||||
if( !cls.accept_utf8 )
|
||||
ch = Con_UtfProcessCharForce( ch );
|
||||
if( !Q_stricmp( cl_charset.string, "utf-8" ) )
|
||||
ch = (unsigned char)osk.curbutton.val;
|
||||
else
|
||||
ch = Con_UtfProcessCharForce( (unsigned char)osk.curbutton.val );
|
||||
|
||||
if( !ch )
|
||||
break;
|
||||
|
||||
CL_CharEvent( ch );
|
||||
Con_CharEvent( ch );
|
||||
if( cls.key_dest == key_menu )
|
||||
UI_CharEvent ( ch );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1119,6 +1121,7 @@ static void OSK_EnableTextInput( qboolean enable, qboolean force )
|
|||
{
|
||||
osk.curlayout = 0;
|
||||
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static void free_winding( winding_t *w )
|
|||
{
|
||||
// simple sentinel by Carmack
|
||||
if( *(unsigned *)w == 0xDEADC0DE )
|
||||
Host_Error( "%s: freed a freed winding\n", __func__ );
|
||||
Host_Error( "free_winding: freed a freed winding\n" );
|
||||
*(unsigned *)w = 0xDEADC0DE;
|
||||
free( w );
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ static winding_t *winding_for_plane( const mplane_t *p )
|
|||
vup[0] = 1;
|
||||
break;
|
||||
default:
|
||||
Host_Error( "%s: no axis found\n", __func__ );
|
||||
Host_Error( "BaseWindingForPlane: no axis found\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -685,9 +685,6 @@ void Mod_CreatePolygonsForHull( int hullnum )
|
|||
if( hullnum < 1 || hullnum > 3 )
|
||||
return;
|
||||
|
||||
if( !world.num_hull_models )
|
||||
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
|
||||
|
||||
Con_Printf( "generating polygons for hull %u...\n", hullnum );
|
||||
start = Sys_DoubleTime();
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
struct ref_state_s ref;
|
||||
ref_globals_t refState;
|
||||
|
||||
static const char* r_skyBoxSuffix[SKYBOX_MAX_SIDES] = { "rt", "bk", "lf", "ft", "up", "dn" };
|
||||
|
||||
CVAR_DEFINE_AUTO( gl_vsync, "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
|
||||
CVAR_DEFINE_AUTO( r_showtextures, "0", FCVAR_CHEAT, "show all uploaded textures" );
|
||||
CVAR_DEFINE_AUTO( r_adjust_fov, "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
|
||||
|
@ -20,133 +18,19 @@ CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BS
|
|||
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
|
||||
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
|
||||
|
||||
// there is no need to expose whole host and cl structs into the renderer
|
||||
// but we still need to update timings accurately as possible
|
||||
// this looks horrible but the only other option would be passing four
|
||||
// time pointers and then it's looks even worse with dereferences everywhere
|
||||
#define STATIC_OFFSET_CHECK( s1, s2, field, base, msg ) \
|
||||
STATIC_ASSERT( offsetof( s1, field ) == offsetof( s2, field ) - offsetof( s2, base ), msg )
|
||||
#define REF_CLIENT_CHECK( field ) \
|
||||
STATIC_OFFSET_CHECK( ref_client_t, client_t, field, time, "broken ref_client_t offset" ); \
|
||||
STATIC_ASSERT_( szchk_##__LINE__, sizeof(((ref_client_t *)0)->field ) == sizeof( cl.field ), "broken ref_client_t size" )
|
||||
#define REF_HOST_CHECK( field ) \
|
||||
STATIC_OFFSET_CHECK( ref_host_t, host_parm_t, field, realtime, "broken ref_client_t offset" ); \
|
||||
STATIC_ASSERT_( szchk_##__LINE__, sizeof(((ref_host_t *)0)->field ) == sizeof( host.field ), "broken ref_client_t size" )
|
||||
|
||||
REF_CLIENT_CHECK( time );
|
||||
REF_CLIENT_CHECK( oldtime );
|
||||
REF_CLIENT_CHECK( viewentity );
|
||||
REF_CLIENT_CHECK( playernum );
|
||||
REF_CLIENT_CHECK( maxclients );
|
||||
REF_CLIENT_CHECK( models );
|
||||
REF_CLIENT_CHECK( paused );
|
||||
REF_CLIENT_CHECK( simorg );
|
||||
REF_HOST_CHECK( realtime );
|
||||
REF_HOST_CHECK( frametime );
|
||||
REF_HOST_CHECK( features );
|
||||
|
||||
void R_GetTextureParms( int *w, int *h, int texnum )
|
||||
{
|
||||
if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum );
|
||||
if( h ) *h = REF_GET_PARM( PARM_TEX_HEIGHT, texnum );
|
||||
}
|
||||
|
||||
static qboolean CheckSkybox( const char *name, char out[SKYBOX_MAX_SIDES][MAX_STRING] )
|
||||
{
|
||||
static const char *skybox_ext[3] = { "dds", "tga", "bmp" };
|
||||
static const char *skybox_delim[2] = { "", "_" }; // no space for HL style, underscore for Q1 style
|
||||
int i;
|
||||
|
||||
// search for skybox images
|
||||
for( i = 0; i < ARRAYSIZE( skybox_ext ); i++ )
|
||||
{
|
||||
int j;
|
||||
|
||||
for( j = 0; j < ARRAYSIZE( skybox_delim ); j++ )
|
||||
{
|
||||
int k, num_checked_sides = 0;
|
||||
|
||||
for( k = 0; k < SKYBOX_MAX_SIDES; k++ )
|
||||
{
|
||||
char sidename[MAX_VA_STRING];
|
||||
|
||||
Q_snprintf( sidename, sizeof( sidename ), "%s%s%s.%s", name, skybox_delim[j], r_skyBoxSuffix[k], skybox_ext[i] );
|
||||
if( g_fsapi.FileExists( sidename, false ))
|
||||
{
|
||||
Q_strncpy( out[k], sidename, sizeof( out[k] ));
|
||||
num_checked_sides++;
|
||||
}
|
||||
}
|
||||
|
||||
if( num_checked_sides == SKYBOX_MAX_SIDES )
|
||||
return true; // image exists
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void R_SetupSky( const char *name )
|
||||
{
|
||||
string loadname;
|
||||
char sidenames[SKYBOX_MAX_SIDES][MAX_STRING];
|
||||
int skyboxTextures[SKYBOX_MAX_SIDES] = { 0 };
|
||||
int i, len;
|
||||
qboolean result;
|
||||
|
||||
if( !COM_CheckString( name ))
|
||||
{
|
||||
ref.dllFuncs.R_SetupSky( NULL ); // unload skybox
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( loadname, sizeof( loadname ), "gfx/env/%s", name );
|
||||
COM_StripExtension( loadname );
|
||||
|
||||
// kill the underline suffix to find them manually later
|
||||
len = Q_strlen( loadname );
|
||||
|
||||
if( loadname[len - 1] == '_' )
|
||||
loadname[len - 1] = '\0';
|
||||
result = CheckSkybox( loadname, sidenames );
|
||||
|
||||
// to prevent infinite recursion if default skybox was missed
|
||||
if( !result && Q_stricmp( name, DEFAULT_SKYBOX_NAME ))
|
||||
{
|
||||
Con_Reportf( S_WARN "missed or incomplete skybox '%s'\n", name );
|
||||
R_SetupSky( DEFAULT_SKYBOX_NAME ); // force to default
|
||||
return;
|
||||
}
|
||||
|
||||
ref.dllFuncs.R_SetupSky( NULL ); // unload skybox
|
||||
Con_DPrintf( "SKY: " );
|
||||
|
||||
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
||||
{
|
||||
skyboxTextures[i] = ref.dllFuncs.GL_LoadTexture( sidenames[i], NULL, 0, TF_CLAMP|TF_SKY );
|
||||
|
||||
if( !skyboxTextures[i] )
|
||||
break;
|
||||
|
||||
Con_DPrintf( "%s%s%s", name, r_skyBoxSuffix[i], i != 5 ? ", " : ". " );
|
||||
}
|
||||
|
||||
if( i == SKYBOX_MAX_SIDES )
|
||||
{
|
||||
SetBits( world.flags, FWORLD_CUSTOM_SKYBOX );
|
||||
Con_DPrintf( "done\n" );
|
||||
ref.dllFuncs.R_SetupSky( skyboxTextures );
|
||||
return; // loaded
|
||||
}
|
||||
|
||||
Con_DPrintf( "^2failed\n" );
|
||||
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
||||
{
|
||||
if( skyboxTextures[i] )
|
||||
ref.dllFuncs.GL_FreeTexture( skyboxTextures[i] );
|
||||
}
|
||||
}
|
||||
/*
|
||||
================
|
||||
GL_FreeImage
|
||||
|
||||
Frees image by name
|
||||
================
|
||||
*/
|
||||
void GAME_EXPORT GL_FreeImage( const char *name )
|
||||
{
|
||||
int texnum;
|
||||
|
@ -158,8 +42,18 @@ void GAME_EXPORT GL_FreeImage( const char *name )
|
|||
ref.dllFuncs.GL_FreeTexture( texnum );
|
||||
}
|
||||
|
||||
void R_UpdateRefState( void )
|
||||
{
|
||||
refState.time = cl.time;
|
||||
refState.oldtime = cl.oldtime;
|
||||
refState.realtime = host.realtime;
|
||||
refState.frametime = host.frametime;
|
||||
}
|
||||
|
||||
void GL_RenderFrame( const ref_viewpass_t *rvp )
|
||||
{
|
||||
R_UpdateRefState();
|
||||
|
||||
VectorCopy( rvp->vieworigin, refState.vieworg );
|
||||
VectorCopy( rvp->viewangles, refState.viewangles );
|
||||
|
||||
|
@ -171,6 +65,11 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
|
|||
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
|
||||
}
|
||||
|
||||
static world_static_t *pfnGetWorld( void )
|
||||
{
|
||||
return &world;
|
||||
}
|
||||
|
||||
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
|
||||
{
|
||||
clgame.dllFuncs.pfnStudioEvent( event, e );
|
||||
|
@ -182,7 +81,7 @@ static model_t *pfnGetDefaultSprite( enum ref_defaultsprite_e spr )
|
|||
{
|
||||
case REF_DOT_SPRITE: return cl_sprite_dot;
|
||||
case REF_CHROME_SPRITE: return cl_sprite_shell;
|
||||
default: Host_Error( "%s: unknown sprite %d\n", __func__, spr );
|
||||
default: Host_Error( "GetDefaultSprite: unknown sprite %d\n", spr );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -195,15 +94,19 @@ static void *pfnMod_Extradata( int type, model_t *m )
|
|||
case mod_studio: return Mod_StudioExtradata( m );
|
||||
case mod_sprite: // fallthrough
|
||||
case mod_brush: return NULL;
|
||||
default: Host_Error( "%s: unknown type %d\n", __func__, type );
|
||||
default: Host_Error( "Mod_Extradata: unknown type %d\n", type );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void CL_ExtraUpdate( void )
|
||||
static void pfnGetPredictedOrigin( vec3_t v )
|
||||
{
|
||||
clgame.dllFuncs.IN_Accumulate();
|
||||
S_ExtraUpdate();
|
||||
VectorCopy( cl.simorg, v );
|
||||
}
|
||||
|
||||
static color24 *pfnCL_GetPaletteColor( int color ) // clgame.palette[color]
|
||||
{
|
||||
return &clgame.palette[color];
|
||||
}
|
||||
|
||||
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
|
||||
|
@ -255,6 +158,11 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
|
|||
0;
|
||||
}
|
||||
|
||||
static poolhandle_t pfnImage_GetPool( void )
|
||||
{
|
||||
return host.imagepool;
|
||||
}
|
||||
|
||||
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
|
||||
{
|
||||
return &PFDesc[idx];
|
||||
|
@ -275,6 +183,25 @@ static screenfade_t *pfnRefGetScreenFade( void )
|
|||
return &clgame.fade;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_DoResetGamma
|
||||
gamma will be reset for
|
||||
some type of screenshots
|
||||
===============
|
||||
*/
|
||||
static qboolean R_DoResetGamma( void )
|
||||
{
|
||||
switch( cls.scrshot_action )
|
||||
{
|
||||
case scrshot_envshot:
|
||||
case scrshot_skyshot:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean R_Init_Video_( const int type )
|
||||
{
|
||||
host.apply_opengl_config = true;
|
||||
|
@ -319,12 +246,16 @@ static ref_api_t gEngfuncs =
|
|||
Con_DrawString,
|
||||
CL_DrawCenterPrint,
|
||||
|
||||
CL_GetLocalPlayer,
|
||||
CL_GetViewModel,
|
||||
CL_GetEntityByIndex,
|
||||
R_BeamGetEntity,
|
||||
CL_GetWaterEntity,
|
||||
CL_AddVisibleEntity,
|
||||
|
||||
Mod_SampleSizeForFace,
|
||||
Mod_BoxVisible,
|
||||
pfnGetWorld,
|
||||
Mod_PointInLeaf,
|
||||
Mod_CreatePolygonsForHull,
|
||||
|
||||
|
@ -341,9 +272,12 @@ static ref_api_t gEngfuncs =
|
|||
|
||||
Mod_ForName,
|
||||
pfnMod_Extradata,
|
||||
CL_ModelHandle,
|
||||
|
||||
CL_EntitySetRemapColors,
|
||||
CL_GetRemapInfoForEntity,
|
||||
CL_AllocRemapInfo,
|
||||
CL_FreeRemapInfo,
|
||||
CL_UpdateRemapInfo,
|
||||
|
||||
CL_ExtraUpdate,
|
||||
Host_Error,
|
||||
|
@ -351,6 +285,9 @@ static ref_api_t gEngfuncs =
|
|||
COM_RandomFloat,
|
||||
COM_RandomLong,
|
||||
pfnRefGetScreenFade,
|
||||
CL_TextMessageGet,
|
||||
pfnGetPredictedOrigin,
|
||||
pfnCL_GetPaletteColor,
|
||||
pfnCL_GetScreenInfo,
|
||||
pfnSetLocalLightLevel,
|
||||
Sys_CheckParm,
|
||||
|
@ -384,11 +321,9 @@ static ref_api_t gEngfuncs =
|
|||
SW_LockBuffer,
|
||||
SW_UnlockBuffer,
|
||||
|
||||
BuildGammaTable,
|
||||
LightToTexGamma,
|
||||
LightToTexGammaEx,
|
||||
TextureToGamma,
|
||||
ScreenGammaTable,
|
||||
LinearGammaTable,
|
||||
R_DoResetGamma,
|
||||
|
||||
CL_GetLightStyle,
|
||||
CL_GetDynamicLight,
|
||||
|
@ -402,6 +337,7 @@ static ref_api_t gEngfuncs =
|
|||
PM_CL_TraceLine,
|
||||
CL_VisTraceLine,
|
||||
CL_TraceLine,
|
||||
pfnGetMoveVars,
|
||||
|
||||
Image_AddCmdFlags,
|
||||
Image_SetForceFlags,
|
||||
|
@ -413,6 +349,7 @@ static ref_api_t gEngfuncs =
|
|||
FS_CopyImage,
|
||||
FS_FreeImage,
|
||||
Image_SetMDLPointer,
|
||||
pfnImage_GetPool,
|
||||
pfnImage_GetPFDesc,
|
||||
|
||||
pfnDrawNormalTriangles,
|
||||
|
@ -477,7 +414,7 @@ static qboolean R_LoadProgs( const char *name )
|
|||
if( !(ref.hInstance = COM_LoadLibrary( name, false, true ) ))
|
||||
{
|
||||
FS_AllowDirectPaths( false );
|
||||
Con_Reportf( "%s: can't load renderer library %s: %s\n", __func__, name, COM_GetLibraryError() );
|
||||
Con_Reportf( "R_LoadProgs: can't load renderer library %s: %s\n", name, COM_GetLibraryError() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -486,7 +423,7 @@ static qboolean R_LoadProgs( const char *name )
|
|||
if( !( GetRefAPI = (REFAPI)COM_GetProcAddress( ref.hInstance, GET_REF_API )) )
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "%s: can't find GetRefAPI entry point in %s\n", __func__, name );
|
||||
Con_Reportf( "R_LoadProgs: can't find GetRefAPI entry point in %s\n", name );
|
||||
ref.hInstance = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -494,10 +431,10 @@ static qboolean R_LoadProgs( const char *name )
|
|||
// make local copy of engfuncs to prevent overwrite it with user dll
|
||||
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
|
||||
|
||||
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
|
||||
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ))
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "%s: can't init renderer API: wrong version\n", __func__ );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
|
||||
ref.hInstance = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -507,7 +444,7 @@ static qboolean R_LoadProgs( const char *name )
|
|||
if( !ref.dllFuncs.R_Init( ) )
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "%s: can't init renderer!\n", __func__ ); //, ref.dllFuncs.R_GetInitError() );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer!\n" ); //, ref.dllFuncs.R_GetInitError() );
|
||||
ref.hInstance = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -656,7 +593,7 @@ static void R_CollectRendererNames( void )
|
|||
"GL4ES",
|
||||
#endif
|
||||
#if XASH_REF_GLES3COMPAT_ENABLED
|
||||
"GLES3 (gl2_shim)",
|
||||
"GLES3 (gl2_shim)"
|
||||
#endif
|
||||
#if XASH_REF_SOFT_ENABLED
|
||||
"Software",
|
||||
|
@ -702,7 +639,6 @@ qboolean R_Init( void )
|
|||
|
||||
// cvars that are expected to exist by client.dll
|
||||
// refdll should just get pointer to them
|
||||
Cvar_Get( "r_lighting_modulate", "0.6", FCVAR_ARCHIVE, "compatibility cvar, does nothing" );
|
||||
Cvar_Get( "r_drawentities", "1", FCVAR_CHEAT, "render entities" );
|
||||
Cvar_Get( "cl_himodels", "1", FCVAR_ARCHIVE, "draw high-resolution player models in multiplayer" );
|
||||
|
||||
|
|
|
@ -18,18 +18,19 @@ GNU General Public License for more details.
|
|||
|
||||
#include "ref_api.h"
|
||||
|
||||
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
|
||||
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
|
||||
|
||||
struct ref_state_s
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
qboolean initialized;
|
||||
int numRenderers;
|
||||
qboolean initialized;
|
||||
|
||||
HINSTANCE hInstance;
|
||||
ref_interface_t dllFuncs;
|
||||
|
||||
// depends on build configuration
|
||||
const char **shortNames;
|
||||
const char **readableNames;
|
||||
int numRenderers;
|
||||
const char **shortNames;
|
||||
const char **readableNames;
|
||||
};
|
||||
|
||||
extern struct ref_state_s ref;
|
||||
|
@ -44,15 +45,14 @@ void R_GetTextureParms( int *w, int *h, int texnum );
|
|||
|
||||
void GL_RenderFrame( const struct ref_viewpass_s *rvp );
|
||||
|
||||
void R_SetupSky( const char *name );
|
||||
|
||||
// common engine and renderer cvars
|
||||
extern convar_t r_decals;
|
||||
extern convar_t r_adjust_fov;
|
||||
extern convar_t r_decals;
|
||||
extern convar_t r_adjust_fov;
|
||||
extern convar_t gl_clear;
|
||||
|
||||
qboolean R_Init( void );
|
||||
void R_Shutdown( void );
|
||||
void R_UpdateRefState( void );
|
||||
|
||||
extern triangleapi_t gTriApi;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/*
|
||||
s_dsp.c - digital signal processing algorithms for audio FX
|
||||
Copyright (C) 2009 Uncle Mike
|
||||
Copyright (C) 2016-2024 Alibek Omarov
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -154,8 +153,7 @@ static const sx_preset_t rgsxpre_hlalpha052[] =
|
|||
static const sx_preset_t *ptable = rgsxpre;
|
||||
|
||||
// cvars
|
||||
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing (deprecated)" );
|
||||
static CVAR_DEFINE_AUTO( room_off, "0", FCVAR_ARCHIVE, "disable DSP processing (GoldSrc compatible cvar)" );
|
||||
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing" );
|
||||
static CVAR_DEFINE_AUTO( dsp_coeff_table, "0", FCVAR_ARCHIVE, "select DSP coefficient table: 0 for release or 1 for alpha 0.52" );
|
||||
static CVAR_DEFINE_AUTO( room_type, "0", 0, "current room type preset" );
|
||||
|
||||
|
@ -233,7 +231,6 @@ void SX_Init( void )
|
|||
sxmod2cur = sxmod2 = 450 * ( idsp_dma_speed / SOUND_11k );
|
||||
|
||||
Cvar_RegisterVariable( &dsp_off );
|
||||
Cvar_RegisterVariable( &room_off );
|
||||
Cvar_RegisterVariable( &dsp_coeff_table );
|
||||
|
||||
Cvar_RegisterVariable( &roomwater_type );
|
||||
|
@ -336,7 +333,7 @@ DLY_MovePointer
|
|||
Checks overflow and moves pointer
|
||||
============
|
||||
*/
|
||||
static void DLY_MovePointer( dly_t *dly )
|
||||
_inline void DLY_MovePointer( dly_t *dly )
|
||||
{
|
||||
if( ++dly->idelayinput >= dly->cdelaysamplesmax )
|
||||
dly->idelayinput = 0;
|
||||
|
@ -809,9 +806,13 @@ DSP_Process
|
|||
(xash dsp interface)
|
||||
===========
|
||||
*/
|
||||
void DSP_Process( portable_samplepair_t *pbfront, int sampleCount )
|
||||
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount )
|
||||
{
|
||||
if( dsp_off.value || room_off.value || !sampleCount )
|
||||
if( dsp_off.value )
|
||||
return;
|
||||
|
||||
// don't process DSP while in menu
|
||||
if( cls.key_dest == key_menu || !sampleCount )
|
||||
return;
|
||||
|
||||
// preset is already installed by CheckNewDspPresets
|
||||
|
@ -832,7 +833,7 @@ DSP_ClearState
|
|||
*/
|
||||
void DSP_ClearState( void )
|
||||
{
|
||||
Cvar_DirectSet( &room_type, "0" );
|
||||
Cvar_SetValue( "room_type", 0.0f );
|
||||
SX_ReloadRoomFX();
|
||||
}
|
||||
|
||||
|
@ -845,7 +846,7 @@ CheckNewDspPresets
|
|||
*/
|
||||
void CheckNewDspPresets( void )
|
||||
{
|
||||
if( dsp_off.value || room_off.value )
|
||||
if( dsp_off.value != 0.0f )
|
||||
return;
|
||||
|
||||
if( FBitSet( dsp_coeff_table.flags, FCVAR_CHANGED ))
|
||||
|
@ -891,15 +892,15 @@ void CheckNewDspPresets( void )
|
|||
|
||||
cur = ptable + idsp_room;
|
||||
|
||||
Cvar_DirectSetValue( &sxmod_lowpass, cur->room_lp );
|
||||
Cvar_DirectSetValue( &sxmod_mod, cur->room_mod );
|
||||
Cvar_DirectSetValue( &sxrvb_size, cur->room_size );
|
||||
Cvar_DirectSetValue( &sxrvb_feedback, cur->room_refl );
|
||||
Cvar_DirectSetValue( &sxrvb_lp, cur->room_rvblp );
|
||||
Cvar_DirectSetValue( &sxdly_delay, cur->room_delay );
|
||||
Cvar_DirectSetValue( &sxdly_feedback, cur->room_feedback );
|
||||
Cvar_DirectSetValue( &sxdly_lp, cur->room_dlylp );
|
||||
Cvar_DirectSetValue( &sxste_delay, cur->room_left );
|
||||
Cvar_SetValue( "room_lp", cur->room_lp );
|
||||
Cvar_SetValue( "room_mod", cur->room_mod );
|
||||
Cvar_SetValue( "room_size", cur->room_size );
|
||||
Cvar_SetValue( "room_refl", cur->room_refl );
|
||||
Cvar_SetValue( "room_rvblp", cur->room_rvblp );
|
||||
Cvar_SetValue( "room_delay", cur->room_delay );
|
||||
Cvar_SetValue( "room_feedback", cur->room_feedback );
|
||||
Cvar_SetValue( "room_dlylp", cur->room_dlylp );
|
||||
Cvar_SetValue( "room_left", cur->room_left );
|
||||
}
|
||||
|
||||
room_typeprev = idsp_room;
|
||||
|
@ -928,7 +929,7 @@ static void SX_Profiling_f( void )
|
|||
|
||||
if( Cmd_Argc() > 1 )
|
||||
{
|
||||
Cvar_DirectSetValue( &room_type, Q_atof( Cmd_Argv( 1 )));
|
||||
Cvar_SetValue( "room_type", Q_atof( Cmd_Argv( 1 )));
|
||||
SX_ReloadRoomFX();
|
||||
CheckNewDspPresets(); // we just need idsp_room immediately, for message below
|
||||
}
|
||||
|
@ -938,7 +939,7 @@ static void SX_Profiling_f( void )
|
|||
start = Sys_DoubleTime();
|
||||
for( calls = 10000; calls; calls-- )
|
||||
{
|
||||
DSP_Process( testbuffer, 512 );
|
||||
DSP_Process( idsp_room, testbuffer, 512 );
|
||||
}
|
||||
end = Sys_DoubleTime();
|
||||
|
||||
|
@ -946,7 +947,7 @@ static void SX_Profiling_f( void )
|
|||
|
||||
if( Cmd_Argc() > 1 )
|
||||
{
|
||||
Cvar_DirectSetValue( &room_type, oldroom );
|
||||
Cvar_SetValue( "room_type", oldroom );
|
||||
SX_ReloadRoomFX();
|
||||
CheckNewDspPresets();
|
||||
}
|
||||
|
|
|
@ -52,11 +52,8 @@ void S_SoundList_f( void )
|
|||
{
|
||||
totalSize += sc->size;
|
||||
|
||||
if( FBitSet( sc->flags, SOUND_LOOPED ))
|
||||
Con_Printf( "L" );
|
||||
else
|
||||
Con_Printf( " " );
|
||||
|
||||
if( sc->loopStart >= 0 ) Con_Printf( "L" );
|
||||
else Con_Printf( " " );
|
||||
if( sfx->name[0] == '*' || !Q_strncmp( sfx->name, DEFAULT_SOUNDPATH, sizeof( DEFAULT_SOUNDPATH ) - 1 ))
|
||||
Con_Printf( " (%2db) %s : %s\n", sc->width * 8, Q_memprint( sc->size ), sfx->name );
|
||||
else Con_Printf( " (%2db) %s : " DEFAULT_SOUNDPATH "%s\n", sc->width * 8, Q_memprint( sc->size ), sfx->name );
|
||||
|
@ -113,7 +110,7 @@ static wavdata_t *S_CreateDefaultSound( void )
|
|||
|
||||
sc->width = 2;
|
||||
sc->channels = 1;
|
||||
sc->loopStart = 0;
|
||||
sc->loopStart = -1;
|
||||
sc->rate = SOUND_DMA_SPEED;
|
||||
sc->samples = SOUND_DMA_SPEED;
|
||||
sc->size = sc->samples * sc->width * sc->channels;
|
||||
|
@ -144,8 +141,8 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
|
|||
if( Q_stricmp( sfx->name, "*default" ))
|
||||
{
|
||||
// load it from disk
|
||||
if( s_warn_late_precache.value > 0 && cls.state == ca_active )
|
||||
Con_Printf( S_WARN "%s: late precache of %s\n", __func__, sfx->name );
|
||||
if( s_warn_late_precache.value > 0 && CL_Active() )
|
||||
Con_Printf( S_WARN "S_LoadSound: late precache of %s\n", sfx->name );
|
||||
|
||||
if( sfx->name[0] == '*' )
|
||||
sc = FS_LoadSound( sfx->name + 1, NULL, 0 );
|
||||
|
@ -158,7 +155,7 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
|
|||
Sound_Process( &sc, SOUND_11k, sc->width, SOUND_RESAMPLE );
|
||||
else if( sc->rate > SOUND_11k && sc->rate < SOUND_22k ) // some bad sounds
|
||||
Sound_Process( &sc, SOUND_22k, sc->width, SOUND_RESAMPLE );
|
||||
else if( sc->rate > SOUND_22k && sc->rate < SOUND_44k ) // some bad sounds
|
||||
else if( sc->rate > SOUND_22k && sc->rate <= SOUND_32k ) // some bad sounds
|
||||
Sound_Process( &sc, SOUND_44k, sc->width, SOUND_RESAMPLE );
|
||||
|
||||
sfx->cache = sc;
|
||||
|
@ -221,7 +218,7 @@ sfx_t *S_FindName( const char *pname, int *pfInCache )
|
|||
sfx = &s_knownSfx[i];
|
||||
memset( sfx, 0, sizeof( *sfx ));
|
||||
if( pfInCache ) *pfInCache = false;
|
||||
Q_strncpy( sfx->name, name, sizeof( sfx->name ));
|
||||
Q_strncpy( sfx->name, name, MAX_STRING );
|
||||
sfx->servercount = cl.servercount;
|
||||
sfx->hashValue = COM_HashKey( sfx->name, MAX_SFX_HASH );
|
||||
|
||||
|
@ -380,7 +377,7 @@ S_InitSounds
|
|||
void S_InitSounds( void )
|
||||
{
|
||||
// create unused 0-entry
|
||||
Q_strncpy( s_knownSfx->name, "*default", sizeof( s_knownSfx->name ));
|
||||
Q_strncpy( s_knownSfx->name, "*default", MAX_QPATH );
|
||||
s_knownSfx->hashValue = COM_HashKey( s_knownSfx->name, MAX_SFX_HASH );
|
||||
s_knownSfx->hashNext = s_sfxHashList[s_knownSfx->hashValue];
|
||||
s_sfxHashList[s_knownSfx->hashValue] = s_knownSfx;
|
||||
|
|
|
@ -64,12 +64,6 @@ float S_GetMasterVolume( void )
|
|||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( host.status == HOST_NOFOCUS && snd_mute_losefocus.value != 0.0f )
|
||||
{
|
||||
// we return zero volume to keep sounds running
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if( !s_listener.inmenu && soundfade.percent != 0 )
|
||||
{
|
||||
scale = bound( 0.0f, soundfade.percent / 100.0f, 1.0f );
|
||||
|
@ -97,7 +91,7 @@ void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime
|
|||
S_IsClient
|
||||
=================
|
||||
*/
|
||||
static qboolean S_IsClient( int entnum )
|
||||
qboolean S_IsClient( int entnum )
|
||||
{
|
||||
return ( entnum == s_listener.entnum );
|
||||
}
|
||||
|
@ -130,7 +124,7 @@ void S_FreeChannel( channel_t *ch )
|
|||
S_UpdateSoundFade
|
||||
=================
|
||||
*/
|
||||
static void S_UpdateSoundFade( void )
|
||||
void S_UpdateSoundFade( void )
|
||||
{
|
||||
float f, totaltime, elapsed;
|
||||
|
||||
|
@ -190,7 +184,7 @@ override any other sound playing on the same channel (see code comments below fo
|
|||
exceptions).
|
||||
=================
|
||||
*/
|
||||
static qboolean SND_FStreamIsPlaying( sfx_t *sfx )
|
||||
qboolean SND_FStreamIsPlaying( sfx_t *sfx )
|
||||
{
|
||||
int ch_idx;
|
||||
|
||||
|
@ -328,7 +322,7 @@ channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx, qboolean
|
|||
// don't restart looping sounds for the same entity
|
||||
wavdata_t *sc = channels[first_to_die].sfx->cache;
|
||||
|
||||
if( sc && FBitSet( sc->flags, SOUND_LOOPED ))
|
||||
if( sc && sc->loopStart != -1 )
|
||||
{
|
||||
channel_t *ch = &channels[first_to_die];
|
||||
|
||||
|
@ -382,7 +376,7 @@ channel_t *SND_PickStaticChannel( const vec3_t pos, sfx_t *sfx )
|
|||
// no empty slots, alloc a new static sound channel
|
||||
if( total_channels == MAX_CHANNELS )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: no free channels\n", __func__ );
|
||||
Con_DPrintf( S_ERROR "S_PickStaticChannel: no free channels\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -405,7 +399,7 @@ returns TRUE if sound was altered,
|
|||
returns FALSE if sound was not found (sound is not playing)
|
||||
=================
|
||||
*/
|
||||
static int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pitch, int flags )
|
||||
int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pitch, int flags )
|
||||
{
|
||||
channel_t *ch;
|
||||
int i;
|
||||
|
@ -463,7 +457,7 @@ static int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pit
|
|||
S_SpatializeChannel
|
||||
=================
|
||||
*/
|
||||
static void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol, float gain, float dot, float dist )
|
||||
void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol, float gain, float dot, float dist )
|
||||
{
|
||||
float lscale, rscale, scale;
|
||||
|
||||
|
@ -486,7 +480,7 @@ static void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol,
|
|||
SND_Spatialize
|
||||
=================
|
||||
*/
|
||||
static void SND_Spatialize( channel_t *ch )
|
||||
void SND_Spatialize( channel_t *ch )
|
||||
{
|
||||
vec3_t source_vec;
|
||||
float dist, dot, gain = 1.0f;
|
||||
|
@ -503,7 +497,7 @@ static void SND_Spatialize( channel_t *ch )
|
|||
|
||||
pSource = ch->sfx->cache;
|
||||
|
||||
if( ch->use_loop && pSource && FBitSet( pSource->flags, SOUND_LOOPED ))
|
||||
if( ch->use_loop && pSource && pSource->loopStart != -1 )
|
||||
looping = true;
|
||||
|
||||
if( !ch->staticsound )
|
||||
|
@ -641,7 +635,7 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
|
|||
if( !target_chan->leftvol && !target_chan->rightvol )
|
||||
{
|
||||
// looping sounds don't use this optimization because they should stick around until they're killed.
|
||||
if( !sfx->cache || !FBitSet( sfx->cache->flags, SOUND_LOOPED ))
|
||||
if( !sfx->cache || sfx->cache->loopStart == -1 )
|
||||
{
|
||||
// if this is a streaming sound, play the whole thing.
|
||||
if( chan != CHAN_STREAM )
|
||||
|
@ -654,6 +648,20 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
|
|||
|
||||
// Init client entity mouth movement vars
|
||||
SND_InitMouth( ent, chan );
|
||||
|
||||
for( ch_idx = NUM_AMBIENTS, check = channels + NUM_AMBIENTS; ch_idx < MAX_DYNAMIC_CHANNELS; ch_idx++, check++)
|
||||
{
|
||||
if( check == target_chan ) continue;
|
||||
|
||||
if( check->sfx == sfx && !check->pMixer.sample )
|
||||
{
|
||||
// skip up to 0.1 seconds of audio
|
||||
int skip = COM_RandomLong( 0, (long)( 0.1f * check->sfx->cache->rate ));
|
||||
|
||||
S_SetSampleStart( check, sfx->cache, skip );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -893,7 +901,7 @@ int S_GetCurrentStaticSounds( soundlist_t *pout, int size )
|
|||
VectorCopy( channels[i].origin, pout->origin );
|
||||
pout->volume = (float)channels[i].master_vol / 255.0f;
|
||||
pout->attenuation = channels[i].dist_mult * SND_CLIP_DISTANCE;
|
||||
pout->looping = ( channels[i].use_loop && FBitSet( channels[i].sfx->cache->flags, SOUND_LOOPED ));
|
||||
pout->looping = ( channels[i].use_loop && channels[i].sfx->cache->loopStart != -1 );
|
||||
pout->pitch = channels[i].basePitch;
|
||||
pout->channel = channels[i].entchannel;
|
||||
pout->wordIndex = channels[i].wordIndex;
|
||||
|
@ -928,7 +936,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
|
|||
if( !channels[i].sfx || !channels[i].sfx->name[0] || !Q_stricmp( channels[i].sfx->name, "*default" ))
|
||||
continue; // don't serialize default sounds
|
||||
|
||||
looped = ( channels[i].use_loop && FBitSet( channels[i].sfx->cache->flags, SOUND_LOOPED ));
|
||||
looped = ( channels[i].use_loop && channels[i].sfx->cache->loopStart != -1 );
|
||||
|
||||
if( channels[i].entchannel == CHAN_STATIC && looped && !Host_IsQuakeCompatible())
|
||||
continue; // never serialize static looped sounds. It will be restoring in game code
|
||||
|
@ -959,7 +967,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
|
|||
S_InitAmbientChannels
|
||||
===================
|
||||
*/
|
||||
static void S_InitAmbientChannels( void )
|
||||
void S_InitAmbientChannels( void )
|
||||
{
|
||||
int ambient_channel;
|
||||
channel_t *chan;
|
||||
|
@ -981,7 +989,7 @@ static void S_InitAmbientChannels( void )
|
|||
S_UpdateAmbientSounds
|
||||
===================
|
||||
*/
|
||||
static void S_UpdateAmbientSounds( void )
|
||||
void S_UpdateAmbientSounds( void )
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
float vol;
|
||||
|
@ -1413,7 +1421,7 @@ static void S_FreeRawChannels( void )
|
|||
S_ClearBuffer
|
||||
==================
|
||||
*/
|
||||
static void S_ClearBuffer( void )
|
||||
void S_ClearBuffer( void )
|
||||
{
|
||||
S_ClearRawChannels();
|
||||
|
||||
|
@ -1512,7 +1520,7 @@ static int S_GetSoundtime( void )
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
static void S_UpdateChannels( void )
|
||||
void S_UpdateChannels( void )
|
||||
{
|
||||
uint endtime;
|
||||
int samps;
|
||||
|
@ -1599,6 +1607,7 @@ void SND_UpdateSound( void )
|
|||
// release raw-channels that no longer used more than 10 secs
|
||||
S_FreeIdleRawChannels();
|
||||
|
||||
VectorCopy( cl.simvel, s_listener.velocity );
|
||||
s_listener.frametime = (cl.time - cl.oldtime);
|
||||
s_listener.waterlevel = cl.local.waterlevel;
|
||||
s_listener.active = CL_IsInGame();
|
||||
|
@ -1700,7 +1709,7 @@ console functions
|
|||
|
||||
===============================================================================
|
||||
*/
|
||||
static void S_Play_f( void )
|
||||
void S_Play_f( void )
|
||||
{
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
|
@ -1711,7 +1720,7 @@ static void S_Play_f( void )
|
|||
S_StartLocalSound( Cmd_Argv( 1 ), VOL_NORM, false );
|
||||
}
|
||||
|
||||
static void S_Play2_f( void )
|
||||
void S_Play2_f( void )
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
|
@ -1728,7 +1737,7 @@ static void S_Play2_f( void )
|
|||
}
|
||||
}
|
||||
|
||||
static void S_PlayVol_f( void )
|
||||
void S_PlayVol_f( void )
|
||||
{
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
|
@ -1754,7 +1763,7 @@ static void S_Say( const char *name, qboolean reliable )
|
|||
S_StartLocalSound( sentence, 1.0f, reliable );
|
||||
}
|
||||
|
||||
static void S_Say_f( void )
|
||||
void S_Say_f( void )
|
||||
{
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
|
@ -1765,7 +1774,7 @@ static void S_Say_f( void )
|
|||
S_Say( Cmd_Argv( 1 ), false );
|
||||
}
|
||||
|
||||
static void S_SayReliable_f( void )
|
||||
void S_SayReliable_f( void )
|
||||
{
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
|
@ -1781,7 +1790,7 @@ static void S_SayReliable_f( void )
|
|||
S_Music_f
|
||||
=================
|
||||
*/
|
||||
static void S_Music_f( void )
|
||||
void S_Music_f( void )
|
||||
{
|
||||
int c = Cmd_Argc();
|
||||
|
||||
|
@ -1845,7 +1854,7 @@ static void S_Music_f( void )
|
|||
S_StopSound_f
|
||||
=================
|
||||
*/
|
||||
static void S_StopSound_f( void )
|
||||
void S_StopSound_f( void )
|
||||
{
|
||||
S_StopAllSounds( true );
|
||||
}
|
||||
|
@ -1855,7 +1864,7 @@ static void S_StopSound_f( void )
|
|||
S_SoundFade_f
|
||||
=================
|
||||
*/
|
||||
static void S_SoundFade_f( void )
|
||||
void S_SoundFade_f( void )
|
||||
{
|
||||
int c = Cmd_Argc();
|
||||
float fadeTime = 5.0f;
|
||||
|
@ -1889,7 +1898,7 @@ void S_SoundInfo_f( void )
|
|||
S_VoiceRecordStart_f
|
||||
=================
|
||||
*/
|
||||
static void S_VoiceRecordStart_f( void )
|
||||
void S_VoiceRecordStart_f( void )
|
||||
{
|
||||
if( cls.state != ca_active || cls.legacymode )
|
||||
return;
|
||||
|
@ -1902,7 +1911,7 @@ static void S_VoiceRecordStart_f( void )
|
|||
S_VoiceRecordStop_f
|
||||
=================
|
||||
*/
|
||||
static void S_VoiceRecordStop_f( void )
|
||||
void S_VoiceRecordStop_f( void )
|
||||
{
|
||||
if( cls.state != ca_active || !Voice_IsRecording() )
|
||||
return;
|
||||
|
|
|
@ -17,56 +17,30 @@ GNU General Public License for more details.
|
|||
#include "sound.h"
|
||||
#include "client.h"
|
||||
|
||||
enum
|
||||
{
|
||||
IPAINTBUFFER = 0,
|
||||
IROOMBUFFER,
|
||||
ISTREAMBUFFER,
|
||||
CPAINTBUFFERS,
|
||||
};
|
||||
#define IPAINTBUFFER 0
|
||||
#define IROOMBUFFER 1
|
||||
#define ISTREAMBUFFER 2
|
||||
|
||||
enum
|
||||
{
|
||||
FILTERTYPE_NONE = 0,
|
||||
FILTERTYPE_LINEAR,
|
||||
FILTERTYPE_CUBIC,
|
||||
};
|
||||
#define FILTERTYPE_NONE 0
|
||||
#define FILTERTYPE_LINEAR 1
|
||||
#define FILTERTYPE_CUBIC 2
|
||||
|
||||
#define CCHANVOLUMES 2
|
||||
|
||||
#define SND_SCALE_BITS 7
|
||||
#define SND_SCALE_SHIFT ( 8 - SND_SCALE_BITS )
|
||||
#define SND_SCALE_LEVELS ( 1 << SND_SCALE_BITS )
|
||||
#define SND_SCALE_BITS 7
|
||||
#define SND_SCALE_SHIFT (8 - SND_SCALE_BITS)
|
||||
#define SND_SCALE_LEVELS (1 << SND_SCALE_BITS)
|
||||
|
||||
// sound mixing buffer
|
||||
#define CPAINTFILTERMEM 3
|
||||
#define CPAINTFILTERS 4 // maximum number of consecutive upsample passes per paintbuffer
|
||||
portable_samplepair_t *g_curpaintbuffer;
|
||||
portable_samplepair_t streambuffer[(PAINTBUFFER_SIZE+1)];
|
||||
portable_samplepair_t paintbuffer[(PAINTBUFFER_SIZE+1)];
|
||||
portable_samplepair_t roombuffer[(PAINTBUFFER_SIZE+1)];
|
||||
portable_samplepair_t facingbuffer[(PAINTBUFFER_SIZE+1)];
|
||||
portable_samplepair_t temppaintbuffer[(PAINTBUFFER_SIZE+1)];
|
||||
paintbuffer_t paintbuffers[CPAINTBUFFERS];
|
||||
|
||||
// fixed point stuff for real-time resampling
|
||||
#define FIX_BITS 28
|
||||
#define FIX_SCALE ( 1 << FIX_BITS )
|
||||
#define FIX_MASK (( 1 << FIX_BITS ) - 1 )
|
||||
#define FIX_FLOAT( a ) ((int)(( a ) * FIX_SCALE ))
|
||||
#define FIX( a ) (((int)( a )) << FIX_BITS )
|
||||
#define FIX_INTPART( a ) (((int)( a )) >> FIX_BITS )
|
||||
#define FIX_FRACPART( a ) (( a ) & FIX_MASK )
|
||||
int snd_scaletable[SND_SCALE_LEVELS][256];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
qboolean factive; // if true, mix to this paintbuffer using flags
|
||||
portable_samplepair_t *pbuf; // front stereo mix buffer, for 2 or 4 channel mixing
|
||||
int ifilter; // current filter memory buffer to use for upsampling pass
|
||||
portable_samplepair_t fltmem[CPAINTFILTERS][CPAINTFILTERMEM];
|
||||
} paintbuffer_t;
|
||||
|
||||
static portable_samplepair_t *g_curpaintbuffer;
|
||||
static portable_samplepair_t streambuffer[(PAINTBUFFER_SIZE+1)];
|
||||
static portable_samplepair_t paintbuffer[(PAINTBUFFER_SIZE+1)];
|
||||
static portable_samplepair_t roombuffer[(PAINTBUFFER_SIZE+1)];
|
||||
static portable_samplepair_t temppaintbuffer[(PAINTBUFFER_SIZE+1)];
|
||||
static paintbuffer_t paintbuffers[CPAINTBUFFERS];
|
||||
|
||||
static int snd_scaletable[SND_SCALE_LEVELS][256];
|
||||
void S_InitScaletable( void )
|
||||
{
|
||||
int i, j;
|
||||
|
@ -84,7 +58,7 @@ S_TransferPaintBuffer
|
|||
|
||||
===================
|
||||
*/
|
||||
static void S_TransferPaintBuffer( int endtime )
|
||||
void S_TransferPaintBuffer( int endtime )
|
||||
{
|
||||
int *snd_p, snd_linear_count;
|
||||
int lpos, lpaintedtime;
|
||||
|
@ -93,7 +67,7 @@ static void S_TransferPaintBuffer( int endtime )
|
|||
dword *pbuf;
|
||||
|
||||
pbuf = (dword *)dma.buffer;
|
||||
snd_p = (int *)g_curpaintbuffer;
|
||||
snd_p = (int *)PAINTBUFFER;
|
||||
lpaintedtime = paintedtime;
|
||||
sampleMask = ((dma.samples >> 1) - 1);
|
||||
|
||||
|
@ -137,20 +111,20 @@ static void S_TransferPaintBuffer( int endtime )
|
|||
//===============================================================================
|
||||
// Activate a paintbuffer. All active paintbuffers are mixed in parallel within
|
||||
// MIX_MixChannelsToPaintbuffer, according to flags
|
||||
static void MIX_ActivatePaintbuffer( int ipaintbuffer )
|
||||
_inline void MIX_ActivatePaintbuffer( int ipaintbuffer )
|
||||
{
|
||||
Assert( ipaintbuffer < CPAINTBUFFERS );
|
||||
paintbuffers[ipaintbuffer].factive = true;
|
||||
}
|
||||
|
||||
static void MIX_SetCurrentPaintbuffer( int ipaintbuffer )
|
||||
_inline void MIX_SetCurrentPaintbuffer( int ipaintbuffer )
|
||||
{
|
||||
Assert( ipaintbuffer < CPAINTBUFFERS );
|
||||
g_curpaintbuffer = paintbuffers[ipaintbuffer].pbuf;
|
||||
Assert( g_curpaintbuffer != NULL );
|
||||
}
|
||||
|
||||
static int MIX_GetCurrentPaintbufferIndex( void )
|
||||
_inline int MIX_GetCurrentPaintbufferIndex( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -162,7 +136,7 @@ static int MIX_GetCurrentPaintbufferIndex( void )
|
|||
return 0;
|
||||
}
|
||||
|
||||
static paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void )
|
||||
_inline paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void )
|
||||
{
|
||||
int ipaint = MIX_GetCurrentPaintbufferIndex();
|
||||
|
||||
|
@ -171,7 +145,7 @@ static paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void )
|
|||
}
|
||||
|
||||
// Don't mix into any paintbuffers
|
||||
static void MIX_DeactivateAllPaintbuffers( void )
|
||||
_inline void MIX_DeactivateAllPaintbuffers( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -180,7 +154,7 @@ static void MIX_DeactivateAllPaintbuffers( void )
|
|||
}
|
||||
|
||||
// set upsampling filter indexes back to 0
|
||||
static void MIX_ResetPaintbufferFilterCounters( void )
|
||||
_inline void MIX_ResetPaintbufferFilterCounters( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -189,13 +163,13 @@ static void MIX_ResetPaintbufferFilterCounters( void )
|
|||
}
|
||||
|
||||
// return pointer to front paintbuffer pbuf, given index
|
||||
static portable_samplepair_t *MIX_GetPFrontFromIPaint( int ipaintbuffer )
|
||||
_inline portable_samplepair_t *MIX_GetPFrontFromIPaint( int ipaintbuffer )
|
||||
{
|
||||
Assert( ipaintbuffer < CPAINTBUFFERS );
|
||||
return paintbuffers[ipaintbuffer].pbuf;
|
||||
}
|
||||
|
||||
static paintbuffer_t *MIX_GetPPaintFromIPaint( int ipaint )
|
||||
_inline paintbuffer_t *MIX_GetPPaintFromIPaint( int ipaint )
|
||||
{
|
||||
Assert( ipaint < CPAINTBUFFERS );
|
||||
return &paintbuffers[ipaint];
|
||||
|
@ -227,7 +201,7 @@ CHANNEL MIXING
|
|||
|
||||
===============================================================================
|
||||
*/
|
||||
static void S_PaintMonoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
|
||||
void S_PaintMonoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
|
||||
{
|
||||
int *lscale, *rscale;
|
||||
int i, data;
|
||||
|
@ -243,7 +217,7 @@ static void S_PaintMonoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pD
|
|||
}
|
||||
}
|
||||
|
||||
static void S_PaintStereoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
|
||||
void S_PaintStereoFrom8( portable_samplepair_t *pbuf, int *volume, byte *pData, int outCount )
|
||||
{
|
||||
int *lscale, *rscale;
|
||||
uint left, right;
|
||||
|
@ -263,7 +237,7 @@ static void S_PaintStereoFrom8( portable_samplepair_t *pbuf, int *volume, byte *
|
|||
}
|
||||
}
|
||||
|
||||
static void S_PaintMonoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
|
||||
void S_PaintMonoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
|
||||
{
|
||||
int left, right;
|
||||
int i, data;
|
||||
|
@ -278,7 +252,7 @@ static void S_PaintMonoFrom16( portable_samplepair_t *pbuf, int *volume, short *
|
|||
}
|
||||
}
|
||||
|
||||
static void S_PaintStereoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
|
||||
void S_PaintStereoFrom16( portable_samplepair_t *pbuf, int *volume, short *pData, int outCount )
|
||||
{
|
||||
uint *data;
|
||||
int left, right;
|
||||
|
@ -299,11 +273,11 @@ static void S_PaintStereoFrom16( portable_samplepair_t *pbuf, int *volume, short
|
|||
}
|
||||
}
|
||||
|
||||
static void S_Mix8MonoTimeCompress( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
|
||||
void S_Mix8MonoTimeCompress( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
|
||||
{
|
||||
}
|
||||
|
||||
static void S_Mix8Mono( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
|
||||
void S_Mix8Mono( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount, int timecompress )
|
||||
{
|
||||
int i, sampleIndex = 0;
|
||||
uint sampleFrac = inputOffset;
|
||||
|
@ -335,7 +309,7 @@ static void S_Mix8Mono( portable_samplepair_t *pbuf, int *volume, byte *pData, i
|
|||
}
|
||||
}
|
||||
|
||||
static void S_Mix8Stereo( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount )
|
||||
void S_Mix8Stereo( portable_samplepair_t *pbuf, int *volume, byte *pData, int inputOffset, uint rateScale, int outCount )
|
||||
{
|
||||
int i, sampleIndex = 0;
|
||||
uint sampleFrac = inputOffset;
|
||||
|
@ -361,7 +335,7 @@ static void S_Mix8Stereo( portable_samplepair_t *pbuf, int *volume, byte *pData,
|
|||
}
|
||||
}
|
||||
|
||||
static void S_Mix16Mono( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
|
||||
void S_Mix16Mono( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
|
||||
{
|
||||
int i, sampleIndex = 0;
|
||||
uint sampleFrac = inputOffset;
|
||||
|
@ -383,7 +357,7 @@ static void S_Mix16Mono( portable_samplepair_t *pbuf, int *volume, short *pData,
|
|||
}
|
||||
}
|
||||
|
||||
static void S_Mix16Stereo( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
|
||||
void S_Mix16Stereo( portable_samplepair_t *pbuf, int *volume, short *pData, int inputOffset, uint rateScale, int outCount )
|
||||
{
|
||||
int i, sampleIndex = 0;
|
||||
uint sampleFrac = inputOffset;
|
||||
|
@ -405,7 +379,7 @@ static void S_Mix16Stereo( portable_samplepair_t *pbuf, int *volume, short *pDat
|
|||
}
|
||||
}
|
||||
|
||||
static void S_MixChannel( channel_t *pChannel, void *pData, int outputOffset, int inputOffset, uint fracRate, int outCount, int timecompress )
|
||||
void S_MixChannel( channel_t *pChannel, void *pData, int outputOffset, int inputOffset, uint fracRate, int outCount, int timecompress )
|
||||
{
|
||||
int pvol[CCHANVOLUMES];
|
||||
paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr();
|
||||
|
@ -522,7 +496,7 @@ int S_MixDataToDevice( channel_t *pChannel, int sampleCount, int outRate, int ou
|
|||
return outOffset - startingOffset;
|
||||
}
|
||||
|
||||
static qboolean S_ShouldContinueMixing( channel_t *ch )
|
||||
qboolean S_ShouldContinueMixing( channel_t *ch )
|
||||
{
|
||||
if( ch->isSentence )
|
||||
{
|
||||
|
@ -543,13 +517,12 @@ static qboolean S_ShouldContinueMixing( channel_t *ch )
|
|||
// this routine will fill the paintbuffer to endtime. Otherwise, fewer samples are mixed.
|
||||
// if( endtime - paintedtime ) is not aligned on boundaries of 4,
|
||||
// we'll miss data if outputRate < SOUND_DMA_SPEED!
|
||||
static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate )
|
||||
void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate )
|
||||
{
|
||||
channel_t *ch;
|
||||
wavdata_t *pSource;
|
||||
int i, sampleCount;
|
||||
qboolean bZeroVolume;
|
||||
qboolean local = Host_IsLocalGame();
|
||||
|
||||
// mix each channel into paintbuffer
|
||||
ch = channels;
|
||||
|
@ -576,7 +549,7 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
|
|||
{
|
||||
// play, playvol
|
||||
}
|
||||
else if(( s_listener.inmenu || s_listener.paused ) && !ch->localsound && local )
|
||||
else if(( s_listener.inmenu || s_listener.paused ) && !ch->localsound )
|
||||
{
|
||||
// play only local sounds, keep pause for other
|
||||
continue;
|
||||
|
@ -594,7 +567,6 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
|
|||
|
||||
// Don't mix sound data for sounds with zero volume. If it's a non-looping sound,
|
||||
// just remove the sound when its volume goes to zero.
|
||||
|
||||
bZeroVolume = !ch->leftvol && !ch->rightvol;
|
||||
|
||||
if( !bZeroVolume )
|
||||
|
@ -604,7 +576,7 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
|
|||
bZeroVolume = true;
|
||||
}
|
||||
|
||||
if( !pSource || ( bZeroVolume && !FBitSet( pSource->flags, SOUND_LOOPED )))
|
||||
if( !pSource || ( bZeroVolume && pSource->loopStart == -1 ))
|
||||
{
|
||||
if( !pSource )
|
||||
{
|
||||
|
@ -657,7 +629,7 @@ static void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate
|
|||
}
|
||||
|
||||
// pass in index -1...count+2, return pointer to source sample in either paintbuffer or delay buffer
|
||||
static portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem )
|
||||
_inline portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem )
|
||||
{
|
||||
// The delay buffer is assumed to precede the paintbuffer by 6 duplicated samples
|
||||
if( i == -1 ) return (&(pfiltermem[0]));
|
||||
|
@ -675,7 +647,7 @@ static portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *pb
|
|||
// if NULL then perform no filtering.
|
||||
// count: how many samples to upsample. will become count*2 samples in buffer, in place.
|
||||
|
||||
static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
|
||||
void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
|
||||
{
|
||||
|
||||
// implement cubic interpolation on 2x upsampled buffer. Effectively delays buffer contents by 2 samples.
|
||||
|
@ -768,7 +740,7 @@ static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_sampl
|
|||
// prevfilter: filter memory. NOTE: this must match the filtertype ie: filterlinear[] for FILTERTYPE_LINEAR
|
||||
// if NULL then perform no filtering.
|
||||
// count: how many samples to upsample. will become count*2 samples in buffer, in place.
|
||||
static void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
|
||||
void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int count )
|
||||
{
|
||||
int i, upCount = count<<1;
|
||||
|
||||
|
@ -797,7 +769,7 @@ static void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samp
|
|||
// if NULL then perform no filtering.
|
||||
// cfltmem: max number of sample pairs filter can use
|
||||
// filtertype: FILTERTYPE_NONE, _LINEAR, _CUBIC etc. Must match prevfilter.
|
||||
static void S_MixBufferUpsample2x( int count, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int filtertype )
|
||||
void S_MixBufferUpsample2x( int count, portable_samplepair_t *pbuffer, portable_samplepair_t *pfiltermem, int cfltmem, int filtertype )
|
||||
{
|
||||
int upCount = count<<1;
|
||||
int i, j;
|
||||
|
@ -850,7 +822,7 @@ void MIX_ClearAllPaintBuffers( int SampleCount, qboolean clearFilters )
|
|||
// mixes pbuf1 + pbuf2 into pbuf3, count samples
|
||||
// fgain is output gain 0-1.0
|
||||
// NOTE: pbuf3 may equal pbuf1 or pbuf2!
|
||||
static void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, float fgain )
|
||||
void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, float fgain )
|
||||
{
|
||||
portable_samplepair_t *pbuf1, *pbuf2, *pbuf3;
|
||||
int i, gain;
|
||||
|
@ -866,14 +838,6 @@ static void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, flo
|
|||
pbuf2 = paintbuffers[ibuf2].pbuf;
|
||||
pbuf3 = paintbuffers[ibuf3].pbuf;
|
||||
|
||||
if( !gain )
|
||||
{
|
||||
// do not mix buf2 into buf3, just copy
|
||||
if( pbuf1 != pbuf3 )
|
||||
memcpy( pbuf3, pbuf1, sizeof( *pbuf1 ) * count );
|
||||
return;
|
||||
}
|
||||
|
||||
// destination buffer stereo - average n chans down to stereo
|
||||
|
||||
// destination 2ch:
|
||||
|
@ -891,7 +855,7 @@ static void MIX_MixPaintbuffers( int ibuf1, int ibuf2, int ibuf3, int count, flo
|
|||
}
|
||||
}
|
||||
|
||||
static void MIX_CompressPaintbuffer( int ipaint, int count )
|
||||
void MIX_CompressPaintbuffer( int ipaint, int count )
|
||||
{
|
||||
portable_samplepair_t *pbuf;
|
||||
paintbuffer_t *ppaint;
|
||||
|
@ -907,7 +871,7 @@ static void MIX_CompressPaintbuffer( int ipaint, int count )
|
|||
}
|
||||
}
|
||||
|
||||
static void S_MixUpsample( int sampleCount, int filtertype )
|
||||
void S_MixUpsample( int sampleCount, int filtertype )
|
||||
{
|
||||
paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr();
|
||||
int ifilter = ppaint->ifilter;
|
||||
|
@ -920,7 +884,7 @@ static void S_MixUpsample( int sampleCount, int filtertype )
|
|||
ppaint->ifilter++;
|
||||
}
|
||||
|
||||
static void MIX_MixRawSamplesBuffer( int end )
|
||||
void MIX_MixRawSamplesBuffer( int end )
|
||||
{
|
||||
portable_samplepair_t *pbuf, *roombuf, *streambuf;
|
||||
uint i, j, stop;
|
||||
|
@ -964,7 +928,7 @@ static void MIX_MixRawSamplesBuffer( int end )
|
|||
// IROOMBUFFER, IFACINGBUFFER, IFACINGAWAY
|
||||
// dsp fx are then applied to these buffers by the caller.
|
||||
// caller also remixes all into final IPAINTBUFFER output.
|
||||
static void MIX_UpsampleAllPaintbuffers( int end, int count )
|
||||
void MIX_UpsampleAllPaintbuffers( int end, int count )
|
||||
{
|
||||
// 11khz sounds are mixed into 3 buffers based on distance from listener, and facing direction
|
||||
// These buffers are facing, facingaway, room
|
||||
|
@ -1035,8 +999,7 @@ void MIX_PaintChannels( int endtime )
|
|||
MIX_UpsampleAllPaintbuffers( end, count );
|
||||
|
||||
// process all sounds with DSP
|
||||
if( cls.key_dest != key_menu )
|
||||
DSP_Process( MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
|
||||
DSP_Process( idsp_room, MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
|
||||
|
||||
// add music or soundtrack from movie (no dsp)
|
||||
MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() );
|
||||
|
|
|
@ -57,12 +57,6 @@ float S_GetMusicVolume( void )
|
|||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( host.status == HOST_NOFOCUS && snd_mute_losefocus.value != 0.0f )
|
||||
{
|
||||
// we return zero volume to keep sounds running
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if( !s_listener.inmenu && musicfade.percent != 0 )
|
||||
{
|
||||
scale = bound( 0.0f, musicfade.percent / 100.0f, 1.0f );
|
||||
|
@ -102,7 +96,6 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int
|
|||
|
||||
// open stream
|
||||
s_bgTrack.stream = FS_OpenStream( introTrack );
|
||||
|
||||
Q_strncpy( s_bgTrack.current, introTrack, sizeof( s_bgTrack.current ));
|
||||
memset( &musicfade, 0, sizeof( musicfade )); // clear any soundfade
|
||||
s_bgTrack.source = cls.key_dest;
|
||||
|
@ -148,7 +141,7 @@ S_StreamGetCurrentState
|
|||
save\restore code
|
||||
=================
|
||||
*/
|
||||
qboolean S_StreamGetCurrentState( char *currentTrack, size_t currentTrackSize, char *loopTrack, size_t loopTrackSize, int *position )
|
||||
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position )
|
||||
{
|
||||
if( !s_bgTrack.stream )
|
||||
return false; // not active
|
||||
|
@ -156,15 +149,15 @@ qboolean S_StreamGetCurrentState( char *currentTrack, size_t currentTrackSize, c
|
|||
if( currentTrack )
|
||||
{
|
||||
if( s_bgTrack.current[0] )
|
||||
Q_strncpy( currentTrack, s_bgTrack.current, currentTrackSize );
|
||||
else Q_strncpy( currentTrack, "*", currentTrackSize ); // no track
|
||||
Q_strncpy( currentTrack, s_bgTrack.current, MAX_STRING );
|
||||
else Q_strncpy( currentTrack, "*", MAX_STRING ); // no track
|
||||
}
|
||||
|
||||
if( loopTrack )
|
||||
{
|
||||
if( s_bgTrack.loopName[0] )
|
||||
Q_strncpy( loopTrack, s_bgTrack.loopName, loopTrackSize );
|
||||
else Q_strncpy( loopTrack, "*", loopTrackSize ); // no track
|
||||
Q_strncpy( loopTrack, s_bgTrack.loopName, MAX_STRING );
|
||||
else Q_strncpy( loopTrack, "*", MAX_STRING ); // no track
|
||||
}
|
||||
|
||||
if( position )
|
||||
|
|
|
@ -16,6 +16,204 @@ GNU General Public License for more details.
|
|||
#include "common.h"
|
||||
#include "sound.h"
|
||||
|
||||
// hardcoded macros to test for zero crossing
|
||||
#define ZERO_X_8( b ) (( b ) < 2 && ( b ) > -2 )
|
||||
#define ZERO_X_16( b ) (( b ) < 512 && ( b ) > -512 )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Search backward for a zero crossing starting at sample
|
||||
// Input : sample - starting point
|
||||
// Output : position of zero crossing
|
||||
//-----------------------------------------------------------------------------
|
||||
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample )
|
||||
{
|
||||
if( pWaveData == NULL )
|
||||
return sample;
|
||||
|
||||
if( pWaveData->type == WF_PCMDATA )
|
||||
{
|
||||
int sampleSize;
|
||||
|
||||
sampleSize = pWaveData->width * pWaveData->channels;
|
||||
|
||||
// this can never be zero -- other functions divide by this.
|
||||
// This should never happen, but avoid crashing
|
||||
if( sampleSize <= 0 ) sampleSize = 1;
|
||||
|
||||
if( pWaveData->width == 1 )
|
||||
{
|
||||
signed char *pData = (signed char *)(pWaveData->buffer + sample * sampleSize);
|
||||
qboolean zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
{
|
||||
while( sample > 0 && !zero )
|
||||
{
|
||||
if( ZERO_X_8( *pData ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample--;
|
||||
pData--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( sample > 0 && !zero )
|
||||
{
|
||||
if( ZERO_X_8( *pData ) && ZERO_X_8( pData[1] ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample--;
|
||||
pData--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
|
||||
qboolean zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
{
|
||||
while( sample > 0 && !zero )
|
||||
{
|
||||
if( ZERO_X_16(*pData ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData--;
|
||||
sample--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( sample > 0 && !zero )
|
||||
{
|
||||
if( ZERO_X_16( *pData ) && ZERO_X_16( pData[1] ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample--;
|
||||
pData--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Search forward for a zero crossing
|
||||
// Input : sample - starting point
|
||||
// Output : position of found zero crossing
|
||||
//-----------------------------------------------------------------------------
|
||||
int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample )
|
||||
{
|
||||
if( pWaveData == NULL )
|
||||
return sample;
|
||||
|
||||
if( pWaveData->type == WF_PCMDATA )
|
||||
{
|
||||
int sampleSize;
|
||||
|
||||
sampleSize = pWaveData->width * pWaveData->channels;
|
||||
|
||||
// this can never be zero -- other functions divide by this.
|
||||
// This should never happen, but avoid crashing
|
||||
if( sampleSize <= 0 ) sampleSize = 1;
|
||||
|
||||
if( pWaveData->width == 1 ) // 8-bit
|
||||
{
|
||||
signed char *pData = (signed char *)(pWaveData->buffer + sample * sampleSize);
|
||||
qboolean zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
{
|
||||
while( sample < pWaveData->samples && !zero )
|
||||
{
|
||||
if( ZERO_X_8( *pData ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample++;
|
||||
pData++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( sample < pWaveData->samples && !zero )
|
||||
{
|
||||
if( ZERO_X_8( *pData ) && ZERO_X_8( pData[1] ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample++;
|
||||
pData++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
|
||||
qboolean zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
{
|
||||
while( sample > 0 && !zero )
|
||||
{
|
||||
if( ZERO_X_16( *pData ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData++;
|
||||
sample++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( sample > 0 && !zero )
|
||||
{
|
||||
if( ZERO_X_16( *pData ) && ZERO_X_16( pData[1] ))
|
||||
{
|
||||
zero = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample++;
|
||||
pData++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: wrap the position wrt looping
|
||||
// Input : samplePosition - absolute position
|
||||
|
@ -27,7 +225,7 @@ int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean us
|
|||
// convert to a position within the loop
|
||||
// At the end of the loop, we return a short buffer, and subsequent call
|
||||
// will loop back and get the rest of the buffer
|
||||
if( FBitSet( pSource->flags, SOUND_LOOPED ) && samplePosition >= pSource->samples && use_loop )
|
||||
if( pSource->loopStart >= 0 && samplePosition >= pSource->samples && use_loop )
|
||||
{
|
||||
// size of loop
|
||||
int loopSize = pSource->samples - pSource->loopStart;
|
||||
|
@ -81,3 +279,28 @@ int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int s
|
|||
|
||||
return sampleCount;
|
||||
}
|
||||
|
||||
// move the current position to newPosition
|
||||
void S_SetSampleStart( channel_t *pChan, wavdata_t *pSource, int newPosition )
|
||||
{
|
||||
if( pSource )
|
||||
newPosition = S_ZeroCrossingAfter( pSource, newPosition );
|
||||
|
||||
pChan->pMixer.sample = newPosition;
|
||||
}
|
||||
|
||||
// end playback at newEndPosition
|
||||
void S_SetSampleEnd( channel_t *pChan, wavdata_t *pSource, int newEndPosition )
|
||||
{
|
||||
// forced end of zero means play the whole sample
|
||||
if( !newEndPosition ) newEndPosition = 1;
|
||||
|
||||
if( pSource )
|
||||
newEndPosition = S_ZeroCrossingBefore( pSource, newEndPosition );
|
||||
|
||||
// past current position? limit.
|
||||
if( newEndPosition < pChan->pMixer.sample )
|
||||
newEndPosition = pChan->pMixer.sample;
|
||||
|
||||
pChan->pMixer.forcedEndSample = newEndPosition;
|
||||
}
|
||||
|
|
|
@ -18,126 +18,10 @@ GNU General Public License for more details.
|
|||
#include "const.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#define TRIM_SCAN_MAX 255
|
||||
#define TRIM_SAMPLES_BELOW_8 2
|
||||
#define TRIM_SAMPLES_BELOW_16 512 // 65k * 2 / 256
|
||||
|
||||
#define CVOXFILESENTENCEMAX 4096
|
||||
|
||||
static int cszrawsentences = 0;
|
||||
static char *rgpszrawsentence[CVOXFILESENTENCEMAX];
|
||||
static const char *voxperiod = "_period", *voxcomma = "_comma";
|
||||
|
||||
static qboolean S_ShouldTrimSample8( const int8_t *buf, int channels )
|
||||
{
|
||||
if( abs( buf[0] ) > TRIM_SAMPLES_BELOW_8 )
|
||||
return false;
|
||||
|
||||
if( channels >= 2 && abs( buf[1] ) > TRIM_SAMPLES_BELOW_8 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static qboolean S_ShouldTrimSample16( const int16_t *buf, int channels )
|
||||
{
|
||||
if( abs( buf[0] ) > TRIM_SAMPLES_BELOW_16 )
|
||||
return false;
|
||||
|
||||
if( channels >= 2 && abs( buf[1] ) > TRIM_SAMPLES_BELOW_16 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int S_TrimStart( const wavdata_t *wav, int start )
|
||||
{
|
||||
size_t channels = wav->channels, width = wav->width, i;
|
||||
|
||||
if( wav->type != WF_PCMDATA )
|
||||
return start;
|
||||
|
||||
if( width == 1 )
|
||||
{
|
||||
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * start];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample8( data, wav->channels ))
|
||||
break;
|
||||
|
||||
start += channels;
|
||||
data += channels;
|
||||
}
|
||||
}
|
||||
else if( width == 2 )
|
||||
{
|
||||
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * start];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample16( data, wav->channels ))
|
||||
break;
|
||||
|
||||
start += channels;
|
||||
data += channels;
|
||||
}
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
static int S_TrimEnd( const wavdata_t *wav, int end )
|
||||
{
|
||||
size_t channels = wav->channels, width = wav->width, i;
|
||||
|
||||
if( wav->type != WF_PCMDATA )
|
||||
return end;
|
||||
|
||||
if( width == 1 )
|
||||
{
|
||||
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * end];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample8( data, wav->channels ))
|
||||
break;
|
||||
|
||||
end -= channels;
|
||||
data -= channels;
|
||||
}
|
||||
}
|
||||
else if( width == 2 )
|
||||
{
|
||||
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * end];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample16( data, wav->channels ))
|
||||
break;
|
||||
|
||||
end -= channels;
|
||||
data -= channels;
|
||||
}
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
static void S_TrimStartEndTimes( channel_t *ch, wavdata_t *wav, int start, int end )
|
||||
{
|
||||
ch->pMixer.sample = start = S_TrimStart( wav, start );
|
||||
|
||||
// don't overrun the buffer while trimming end
|
||||
if( end == 0 )
|
||||
end = wav->samples - wav->channels;
|
||||
|
||||
if( end < start )
|
||||
end = start;
|
||||
|
||||
ch->pMixer.forcedEndSample = S_TrimEnd( wav, end );
|
||||
}
|
||||
|
||||
// return number of samples mixed
|
||||
int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset )
|
||||
{
|
||||
|
@ -194,7 +78,11 @@ void VOX_LoadWord( channel_t *ch )
|
|||
|
||||
if( end <= start ) end = 0;
|
||||
|
||||
S_TrimStartEndTimes( ch, data, start * 0.01f * samples, end * 0.01f * samples );
|
||||
if( start )
|
||||
S_SetSampleStart( ch, data, start * 0.01f * samples );
|
||||
|
||||
if( end )
|
||||
S_SetSampleEnd( ch, data, end * 0.01f * samples );
|
||||
}
|
||||
|
||||
void VOX_FreeWord( channel_t *ch )
|
||||
|
@ -261,7 +149,7 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
|
|||
|
||||
if( len > nsize )
|
||||
{
|
||||
Con_Printf( "%s: invalid directory in: %s\n", __func__, psz );
|
||||
Con_Printf( "VOX_GetDirectory: invalid directory in: %s\n", psz );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -467,7 +355,7 @@ void VOX_LoadSound( channel_t *ch, const char *pszin )
|
|||
|
||||
if( !psz )
|
||||
{
|
||||
Con_Printf( "%s: no sentence named %s\n", __func__, pszin );
|
||||
Con_Printf( "VOX_LoadSound: no sentence named %s\n", pszin );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -475,13 +363,13 @@ void VOX_LoadSound( channel_t *ch, const char *pszin )
|
|||
|
||||
if( !psz )
|
||||
{
|
||||
Con_Printf( "%s: failed getting directory for %s\n", __func__, pszin );
|
||||
Con_Printf( "VOX_LoadSound: failed getting directory for %s\n", pszin );
|
||||
return;
|
||||
}
|
||||
|
||||
if( Q_strlen( psz ) >= sizeof( buffer ) )
|
||||
{
|
||||
Con_Printf( "%s: sentence is too long %s", __func__, psz );
|
||||
Con_Printf( "VOX_LoadSound: sentence is too long %s", psz );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,181 +20,209 @@ extern poolhandle_t sndpool;
|
|||
|
||||
#include "xash3d_mathlib.h"
|
||||
|
||||
#define XASH_AUDIO_CD_QUALITY 1 // some platforms might need this
|
||||
|
||||
// sound engine rate defines
|
||||
#if XASH_AUDIO_CD_QUALITY
|
||||
#define SOUND_11k 11025 // 11khz sample rate
|
||||
#define SOUND_22k 22050 // 22khz sample rate
|
||||
#define SOUND_44k 44100 // 44khz sample rate
|
||||
#else // XASH_AUDIO_CD_QUALITY
|
||||
#define SOUND_11k 12000 // 11khz sample rate
|
||||
#define SOUND_22k 24000 // 22khz sample rate
|
||||
#define SOUND_44k 48000 // 44khz sample rate
|
||||
#endif // XASH_AUDIO_CD_QUALITY
|
||||
#define SOUND_DMA_SPEED 44100 // hardware playback rate
|
||||
#define SOUND_11k 11025 // 11khz sample rate
|
||||
#define SOUND_16k 16000 // 16khz sample rate
|
||||
#define SOUND_22k 22050 // 22khz sample rate
|
||||
#define SOUND_32k 32000 // 32khz sample rate
|
||||
#define SOUND_44k 44100 // 44khz sample rate
|
||||
#define DMA_MSEC_PER_SAMPLE ((float)(1000.0 / SOUND_DMA_SPEED))
|
||||
|
||||
#define SOUND_DMA_SPEED SOUND_44k // hardware playback rate
|
||||
// fixed point stuff for real-time resampling
|
||||
#define FIX_BITS 28
|
||||
#define FIX_SCALE (1 << FIX_BITS)
|
||||
#define FIX_MASK ((1 << FIX_BITS)-1)
|
||||
#define FIX_FLOAT(a) ((int)((a) * FIX_SCALE))
|
||||
#define FIX(a) (((int)(a)) << FIX_BITS)
|
||||
#define FIX_INTPART(a) (((int)(a)) >> FIX_BITS)
|
||||
#define FIX_FRACTION(a,b) (FIX(a)/(b))
|
||||
#define FIX_FRACPART(a) ((a) & FIX_MASK)
|
||||
|
||||
// NOTE: clipped sound at 32760 to avoid overload
|
||||
#define CLIP( x ) (( x ) > 32760 ? 32760 : (( x ) < -32760 ? -32760 : ( x )))
|
||||
#define CLIP( x ) (( x ) > 32760 ? 32760 : (( x ) < -32760 ? -32760 : ( x )))
|
||||
|
||||
#define PAINTBUFFER_SIZE 1024 // 44k: was 512
|
||||
#define PAINTBUFFER_SIZE 1024 // 44k: was 512
|
||||
#define PAINTBUFFER (g_curpaintbuffer)
|
||||
#define CPAINTBUFFERS 3
|
||||
|
||||
#define S_RAW_SOUND_IDLE_SEC 10 // time interval for idling raw sound before it's freed
|
||||
#define S_RAW_SOUND_BACKGROUNDTRACK -2
|
||||
#define S_RAW_SOUND_SOUNDTRACK -1
|
||||
#define S_RAW_SAMPLES_PRECISION_BITS 14
|
||||
// sound mixing buffer
|
||||
#define CPAINTFILTERMEM 3
|
||||
#define CPAINTFILTERS 4 // maximum number of consecutive upsample passes per paintbuffer
|
||||
|
||||
#define S_RAW_SOUND_IDLE_SEC 10 // time interval for idling raw sound before it's freed
|
||||
#define S_RAW_SOUND_BACKGROUNDTRACK -2
|
||||
#define S_RAW_SOUND_SOUNDTRACK -1
|
||||
#define S_RAW_SAMPLES_PRECISION_BITS 14
|
||||
|
||||
#define CIN_FRAMETIME (1.0f / 30.0f)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int left;
|
||||
int right;
|
||||
int left;
|
||||
int right;
|
||||
} portable_samplepair_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
qboolean factive; // if true, mix to this paintbuffer using flags
|
||||
portable_samplepair_t *pbuf; // front stereo mix buffer, for 2 or 4 channel mixing
|
||||
int ifilter; // current filter memory buffer to use for upsampling pass
|
||||
portable_samplepair_t fltmem[CPAINTFILTERS][CPAINTFILTERMEM];
|
||||
} paintbuffer_t;
|
||||
|
||||
typedef struct sfx_s
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
wavdata_t *cache;
|
||||
char name[MAX_QPATH];
|
||||
wavdata_t *cache;
|
||||
|
||||
int servercount;
|
||||
uint hashValue;
|
||||
struct sfx_s *hashNext;
|
||||
int servercount;
|
||||
uint hashValue;
|
||||
struct sfx_s *hashNext;
|
||||
} sfx_t;
|
||||
|
||||
extern portable_samplepair_t paintbuffer[];
|
||||
extern portable_samplepair_t roombuffer[];
|
||||
extern portable_samplepair_t temppaintbuffer[];
|
||||
extern portable_samplepair_t *g_curpaintbuffer;
|
||||
extern paintbuffer_t paintbuffers[];
|
||||
|
||||
// structure used for fading in and out client sound volume.
|
||||
typedef struct
|
||||
{
|
||||
float initial_percent;
|
||||
float percent; // how far to adjust client's volume down by.
|
||||
float starttime; // GetHostTime() when we started adjusting volume
|
||||
float fadeouttime; // # of seconds to get to faded out state
|
||||
float holdtime; // # of seconds to hold
|
||||
float fadeintime; // # of seconds to restore
|
||||
float initial_percent;
|
||||
float percent; // how far to adjust client's volume down by.
|
||||
float starttime; // GetHostTime() when we started adjusting volume
|
||||
float fadeouttime; // # of seconds to get to faded out state
|
||||
float holdtime; // # of seconds to hold
|
||||
float fadeintime; // # of seconds to restore
|
||||
} soundfade_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float percent;
|
||||
float percent;
|
||||
} musicfade_t;
|
||||
|
||||
typedef struct snd_format_s
|
||||
{
|
||||
uint speed;
|
||||
byte width;
|
||||
byte channels;
|
||||
unsigned int speed;
|
||||
unsigned int width;
|
||||
unsigned int channels;
|
||||
} snd_format_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
snd_format_t format;
|
||||
int samples; // mono samples in buffer
|
||||
int samplepos; // in mono samples
|
||||
qboolean initialized; // sound engine is active
|
||||
byte *buffer;
|
||||
const char *backendName;
|
||||
snd_format_t format;
|
||||
int samples; // mono samples in buffer
|
||||
int samplepos; // in mono samples
|
||||
byte *buffer;
|
||||
qboolean initialized; // sound engine is active
|
||||
const char *backendName;
|
||||
} dma_t;
|
||||
|
||||
#include "vox.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double sample;
|
||||
wavdata_t *pData;
|
||||
double forcedEndSample;
|
||||
qboolean finished;
|
||||
double sample;
|
||||
|
||||
wavdata_t *pData;
|
||||
double forcedEndSample;
|
||||
qboolean finished;
|
||||
} mixer_t;
|
||||
|
||||
typedef struct rawchan_s
|
||||
{
|
||||
int entnum;
|
||||
int master_vol;
|
||||
int leftvol; // 0-255 left volume
|
||||
int rightvol; // 0-255 right volume
|
||||
float dist_mult; // distance multiplier (attenuation/clipK)
|
||||
vec3_t origin; // only use if fixed_origin is set
|
||||
volatile uint s_rawend;
|
||||
float oldtime; // catch time jumps
|
||||
wavdata_t sound_info; // advance play position
|
||||
size_t max_samples; // buffer length
|
||||
portable_samplepair_t rawsamples[1]; // variable sized
|
||||
int entnum;
|
||||
int master_vol;
|
||||
int leftvol; // 0-255 left volume
|
||||
int rightvol; // 0-255 right volume
|
||||
float dist_mult; // distance multiplier (attenuation/clipK)
|
||||
vec3_t origin; // only use if fixed_origin is set
|
||||
volatile uint s_rawend;
|
||||
wavdata_t sound_info; // advance play position
|
||||
float oldtime; // catch time jumps
|
||||
size_t max_samples; // buffer length
|
||||
portable_samplepair_t rawsamples[1]; // variable sized
|
||||
} rawchan_t;
|
||||
|
||||
typedef struct channel_s
|
||||
{
|
||||
char name[16]; // keep sentence name
|
||||
sfx_t *sfx; // sfx number
|
||||
char name[16]; // keept sentence name
|
||||
sfx_t *sfx; // sfx number
|
||||
|
||||
int leftvol; // 0-255 left volume
|
||||
int rightvol; // 0-255 right volume
|
||||
int leftvol; // 0-255 left volume
|
||||
int rightvol; // 0-255 right volume
|
||||
|
||||
int entnum; // entity soundsource
|
||||
int entchannel; // sound channel (CHAN_STREAM, CHAN_VOICE, etc.)
|
||||
vec3_t origin; // only use if fixed_origin is set
|
||||
float dist_mult; // distance multiplier (attenuation/clipK)
|
||||
int master_vol; // 0-255 master volume
|
||||
int basePitch; // base pitch percent (100% is normal pitch playback)
|
||||
float pitch; // real-time pitch after any modulation or shift by dynamic data
|
||||
qboolean use_loop; // don't loop default and local sounds
|
||||
qboolean staticsound; // use origin instead of fetching entnum's origin
|
||||
qboolean localsound; // it's a local menu sound (not looped, not paused)
|
||||
mixer_t pMixer;
|
||||
int entnum; // entity soundsource
|
||||
int entchannel; // sound channel (CHAN_STREAM, CHAN_VOICE, etc.)
|
||||
vec3_t origin; // only use if fixed_origin is set
|
||||
float dist_mult; // distance multiplier (attenuation/clipK)
|
||||
int master_vol; // 0-255 master volume
|
||||
qboolean isSentence; // bit who indicated sentence
|
||||
int basePitch; // base pitch percent (100% is normal pitch playback)
|
||||
float pitch; // real-time pitch after any modulation or shift by dynamic data
|
||||
qboolean use_loop; // don't loop default and local sounds
|
||||
qboolean staticsound; // use origin instead of fetching entnum's origin
|
||||
qboolean localsound; // it's a local menu sound (not looped, not paused)
|
||||
mixer_t pMixer;
|
||||
|
||||
// sentence mixer
|
||||
qboolean isSentence; // bit indicating sentence
|
||||
int wordIndex;
|
||||
mixer_t *currentWord; // NULL if sentence is finished
|
||||
voxword_t words[CVOXWORDMAX];
|
||||
int wordIndex;
|
||||
mixer_t *currentWord; // NULL if sentence is finished
|
||||
voxword_t words[CVOXWORDMAX];
|
||||
} channel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t origin; // simorg + view_ofs
|
||||
vec3_t forward;
|
||||
vec3_t right;
|
||||
vec3_t up;
|
||||
vec3_t origin; // simorg + view_ofs
|
||||
vec3_t velocity;
|
||||
vec3_t forward;
|
||||
vec3_t right;
|
||||
vec3_t up;
|
||||
|
||||
int entnum;
|
||||
int waterlevel;
|
||||
float frametime; // used for sound fade
|
||||
qboolean active;
|
||||
qboolean inmenu; // listener in-menu ?
|
||||
qboolean paused;
|
||||
qboolean streaming; // playing AVI-file
|
||||
qboolean stream_paused; // pause only background track
|
||||
int entnum;
|
||||
int waterlevel;
|
||||
float frametime; // used for sound fade
|
||||
qboolean active;
|
||||
qboolean inmenu; // listener in-menu ?
|
||||
qboolean paused;
|
||||
qboolean streaming; // playing AVI-file
|
||||
qboolean stream_paused; // pause only background track
|
||||
} listener_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
string current; // a currently playing track
|
||||
string loopName; // may be empty
|
||||
stream_t *stream;
|
||||
int source; // may be game, menu, etc
|
||||
string current; // a currently playing track
|
||||
string loopName; // may be empty
|
||||
stream_t *stream;
|
||||
int source; // may be game, menu, etc
|
||||
} bg_track_t;
|
||||
|
||||
//====================================================================
|
||||
|
||||
#define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS)
|
||||
#define MAX_CHANNELS (256 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp
|
||||
#define MAX_RAW_CHANNELS 48
|
||||
#define MAX_RAW_SAMPLES 8192
|
||||
#define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS)
|
||||
#define MAX_CHANNELS (256 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp
|
||||
#define MAX_RAW_CHANNELS 48
|
||||
#define MAX_RAW_SAMPLES 8192
|
||||
|
||||
extern sound_t ambient_sfx[NUM_AMBIENTS];
|
||||
extern qboolean snd_ambient;
|
||||
extern channel_t channels[MAX_CHANNELS];
|
||||
extern rawchan_t *raw_channels[MAX_RAW_CHANNELS];
|
||||
extern int total_channels;
|
||||
extern int paintedtime;
|
||||
extern int soundtime;
|
||||
extern listener_t s_listener;
|
||||
extern int idsp_room;
|
||||
extern dma_t dma;
|
||||
extern sound_t ambient_sfx[NUM_AMBIENTS];
|
||||
extern qboolean snd_ambient;
|
||||
extern channel_t channels[MAX_CHANNELS];
|
||||
extern rawchan_t *raw_channels[MAX_RAW_CHANNELS];
|
||||
extern int total_channels;
|
||||
extern int paintedtime;
|
||||
extern int soundtime;
|
||||
extern listener_t s_listener;
|
||||
extern int idsp_room;
|
||||
extern dma_t dma;
|
||||
|
||||
extern convar_t s_musicvolume;
|
||||
extern convar_t s_lerping;
|
||||
extern convar_t s_test; // cvar to test new effects
|
||||
extern convar_t s_musicvolume;
|
||||
extern convar_t s_lerping;
|
||||
extern convar_t s_test; // cvar to testify new effects
|
||||
extern convar_t s_samplecount;
|
||||
extern convar_t s_warn_late_precache;
|
||||
extern convar_t snd_mute_losefocus;
|
||||
extern convar_t s_warn_late_precache;
|
||||
|
||||
void S_InitScaletable( void );
|
||||
wavdata_t *S_LoadSound( sfx_t *sfx );
|
||||
|
@ -227,7 +255,8 @@ void S_InitSounds( void );
|
|||
void SX_Init( void );
|
||||
void SX_Free( void );
|
||||
void CheckNewDspPresets( void );
|
||||
void DSP_Process( portable_samplepair_t *pbfront, int sampleCount );
|
||||
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount );
|
||||
float DSP_GetGain( int idsp );
|
||||
void DSP_ClearState( void );
|
||||
|
||||
qboolean S_Init( void );
|
||||
|
@ -265,6 +294,7 @@ void SND_ForceCloseMouth( int entnum );
|
|||
//
|
||||
void S_StreamSoundTrack( void );
|
||||
void S_StreamBackgroundTrack( void );
|
||||
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
|
||||
void S_PrintBackgroundTrackState( void );
|
||||
void S_FadeMusicVolume( float fadePercent );
|
||||
|
||||
|
@ -275,6 +305,8 @@ int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample );
|
|||
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample );
|
||||
int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean use_loop );
|
||||
int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount, qboolean use_loop );
|
||||
void S_SetSampleStart( channel_t *pChan, wavdata_t *pSource, int newPosition );
|
||||
void S_SetSampleEnd( channel_t *pChan, wavdata_t *pSource, int newEndPosition );
|
||||
|
||||
//
|
||||
// s_vox.c
|
||||
|
|
|
@ -250,7 +250,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
|
|||
|
||||
if( IsEndOfText( trim ))
|
||||
{
|
||||
Con_Reportf( "%s: unexpected '}' found, line %d\n", __func__, lineNumber );
|
||||
Con_Reportf( "TextMessage: unexpected '}' found, line %d\n", lineNumber );
|
||||
return;
|
||||
}
|
||||
Q_strncpy( currentName, trim, sizeof( currentName ));
|
||||
|
@ -263,7 +263,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
|
|||
// save name on name heap
|
||||
if( lastNamePos + length > 32768 )
|
||||
{
|
||||
Con_Reportf( "%s: error while parsing!\n", __func__ );
|
||||
Con_Reportf( "TextMessage: error while parsing!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
|
|||
}
|
||||
if( IsStartOfText( trim ))
|
||||
{
|
||||
Con_Reportf( "%s: unexpected '{' found, line %d\n", __func__, lineNumber );
|
||||
Con_Reportf( "TextMessage: unexpected '{' found, line %d\n", lineNumber );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -302,7 +302,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
|
|||
}
|
||||
}
|
||||
|
||||
Con_Reportf( "%s: parsed %d text messages\n", __func__, messageCount );
|
||||
Con_Reportf( "TextMessage: parsed %d text messages\n", messageCount );
|
||||
nameHeapSize = lastNamePos;
|
||||
textHeapSize = 0;
|
||||
|
||||
|
@ -347,7 +347,7 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
|
|||
}
|
||||
|
||||
if(( pCurrentText - (char *)clgame.titles ) != ( textHeapSize + nameHeapSize + messageSize ))
|
||||
Con_DPrintf( S_ERROR "%s: overflow text message buffer!\n", __func__ );
|
||||
Con_DPrintf( S_ERROR "TextMessage: overflow text message buffer!\n" );
|
||||
|
||||
clgame.numTitles = messageCount;
|
||||
}
|
||||
|
|
|
@ -23,180 +23,55 @@ GNU General Public License for more details.
|
|||
#include "input.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define VGUI_MAX_TEXTURES 1024
|
||||
CVAR_DEFINE_AUTO( vgui_utf8, "0", FCVAR_ARCHIVE, "enable utf-8 support for vgui text" );
|
||||
|
||||
typedef struct vgui_static_s
|
||||
static void GAME_EXPORT *VGUI_EngineMalloc( size_t size );
|
||||
static void GAME_EXPORT VGUI_GetMousePos( int *, int * );
|
||||
static void GAME_EXPORT VGUI_CursorSelect( VGUI_DefaultCursor );
|
||||
static byte GAME_EXPORT VGUI_GetColor( int, int );
|
||||
static int GAME_EXPORT VGUI_UtfProcessChar( int in );
|
||||
static qboolean GAME_EXPORT VGUI_IsInGame( void );
|
||||
|
||||
static struct
|
||||
{
|
||||
qboolean initialized;
|
||||
VGUI_DefaultCursor cursor;
|
||||
vguiapi_t dllFuncs;
|
||||
|
||||
int textures[VGUI_MAX_TEXTURES];
|
||||
int texture_id;
|
||||
int bound_texture;
|
||||
byte color[4];
|
||||
qboolean enable_texture;
|
||||
VGUI_DefaultCursor cursor;
|
||||
|
||||
HINSTANCE hInstance;
|
||||
|
||||
enum VGUI_KeyCode virtualKeyTrans[256];
|
||||
} vgui_static_t;
|
||||
|
||||
static vgui_static_t vgui = {
|
||||
false, -1
|
||||
} vgui =
|
||||
{
|
||||
false,
|
||||
{
|
||||
false, // Not initialized yet
|
||||
NULL, // VGUI_DrawInit,
|
||||
NULL, // VGUI_DrawShutdown,
|
||||
NULL, // VGUI_SetupDrawingText,
|
||||
NULL, // VGUI_SetupDrawingRect,
|
||||
NULL, // VGUI_SetupDrawingImage,
|
||||
NULL, // VGUI_BindTexture,
|
||||
NULL, // VGUI_EnableTexture,
|
||||
NULL, // VGUI_CreateTexture,
|
||||
NULL, // VGUI_UploadTexture,
|
||||
NULL, // VGUI_UploadTextureBlock,
|
||||
NULL, // VGUI_DrawQuad,
|
||||
NULL, // VGUI_GetTextureSizes,
|
||||
NULL, // VGUI_GenerateTexture,
|
||||
VGUI_EngineMalloc,
|
||||
VGUI_CursorSelect,
|
||||
VGUI_GetColor,
|
||||
VGUI_IsInGame,
|
||||
Key_EnableTextInput,
|
||||
VGUI_GetMousePos,
|
||||
VGUI_UtfProcessChar,
|
||||
Platform_GetClipboardText,
|
||||
Platform_SetClipboardText,
|
||||
Platform_GetKeyModifiers,
|
||||
},
|
||||
-1
|
||||
};
|
||||
static CVAR_DEFINE_AUTO( vgui_utf8, "0", FCVAR_ARCHIVE, "enable utf-8 support for vgui text" );
|
||||
|
||||
static void GAME_EXPORT VGUI_DrawInit( void )
|
||||
{
|
||||
memset( vgui.textures, 0, sizeof( vgui.textures ));
|
||||
vgui.texture_id = vgui.bound_texture = 0;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_DrawShutdown( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < vgui.texture_id; i++ )
|
||||
ref.dllFuncs.GL_FreeTexture( vgui.textures[i] );
|
||||
}
|
||||
|
||||
static int GAME_EXPORT VGUI_GenerateTexture( void )
|
||||
{
|
||||
if( ++vgui.texture_id >= VGUI_MAX_TEXTURES )
|
||||
Host_Error( "%s: VGUI_MAX_TEXTURES limit exceeded\n", __func__ );
|
||||
|
||||
return vgui.texture_id;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_UploadTexture( int id, const char *buffer, int width, int height )
|
||||
{
|
||||
rgbdata_t r_image = { 0 };
|
||||
char texName[32];
|
||||
|
||||
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: bad texture %i. Ignored\n", __func__, id );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
|
||||
|
||||
r_image.width = width;
|
||||
r_image.height = height;
|
||||
r_image.type = PF_RGBA_32;
|
||||
r_image.size = width * height * 4;
|
||||
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
|
||||
r_image.buffer = (byte*)buffer;
|
||||
|
||||
vgui.textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_CreateTexture( int id, int width, int height )
|
||||
{
|
||||
rgbdata_t r_image = { 0 };
|
||||
char texName[32];
|
||||
|
||||
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: bad texture %i. Ignored\n", __func__, id );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
|
||||
|
||||
r_image.width = width;
|
||||
r_image.height = height;
|
||||
r_image.type = PF_RGBA_32;
|
||||
r_image.size = width * height * 4;
|
||||
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
|
||||
r_image.buffer = NULL;
|
||||
|
||||
vgui.textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE );
|
||||
vgui.bound_texture = id;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
|
||||
{
|
||||
if( id <= 0 || id >= VGUI_MAX_TEXTURES || vgui.textures[id] == 0 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: bad texture %i. Ignored\n", __func__, id );
|
||||
return;
|
||||
}
|
||||
|
||||
ref.dllFuncs.VGUI_UploadTextureBlock( drawX, drawY, rgba, blockWidth, blockHeight );
|
||||
vgui.bound_texture = id;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_BindTexture( int id )
|
||||
{
|
||||
if( id <= 0 || id >= VGUI_MAX_TEXTURES || !vgui.textures[id] )
|
||||
id = 1; // NOTE: same as bogus index 2700 in GoldSrc
|
||||
|
||||
ref.dllFuncs.GL_Bind( XASH_TEXTURE0, vgui.textures[id] );
|
||||
vgui.bound_texture = id;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_GetTextureSizes( int *w, int *h )
|
||||
{
|
||||
int texnum;
|
||||
|
||||
if( vgui.bound_texture )
|
||||
texnum = vgui.textures[vgui.bound_texture];
|
||||
else
|
||||
texnum = R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
|
||||
|
||||
R_GetTextureParms( w, h, texnum );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_SetupDrawingRect( int *pColor )
|
||||
{
|
||||
ref.dllFuncs.VGUI_SetupDrawing( true );
|
||||
Vector4Set( vgui.color, pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_SetupDrawingText( int *pColor )
|
||||
{
|
||||
ref.dllFuncs.VGUI_SetupDrawing( false );
|
||||
Vector4Set( vgui.color, pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
|
||||
{
|
||||
float x, y, w, h;
|
||||
|
||||
if( !ul || !lr )
|
||||
return;
|
||||
|
||||
x = ul->point[0];
|
||||
y = ul->point[1];
|
||||
w = lr->point[0] - x;
|
||||
h = lr->point[1] - y;
|
||||
|
||||
SPR_AdjustSize( &x, &y, &w, &h );
|
||||
|
||||
if( vgui.enable_texture )
|
||||
{
|
||||
float s1, s2, t1, t2;
|
||||
|
||||
s1 = ul->coord[0];
|
||||
t1 = ul->coord[1];
|
||||
s2 = lr->coord[0];
|
||||
t2 = lr->coord[1];
|
||||
|
||||
ref.dllFuncs.Color4ub( vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] );
|
||||
ref.dllFuncs.R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, vgui.textures[vgui.bound_texture] );
|
||||
}
|
||||
else
|
||||
{
|
||||
ref.dllFuncs.FillRGBABlend( x, y, w, h, vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] );
|
||||
}
|
||||
}
|
||||
|
||||
static void GAME_EXPORT VGUI_EnableTexture( qboolean enable )
|
||||
{
|
||||
vgui.enable_texture = enable;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT *VGUI_EngineMalloc( size_t size )
|
||||
{
|
||||
|
@ -242,46 +117,33 @@ qboolean VGui_IsActive( void )
|
|||
return vgui.initialized;
|
||||
}
|
||||
|
||||
static void VGui_FillAPIFromRef( vguiapi_t *to, const ref_interface_t *from )
|
||||
{
|
||||
to->DrawInit = from->VGUI_DrawInit;
|
||||
to->DrawShutdown = from->VGUI_DrawShutdown;
|
||||
to->SetupDrawingText = from->VGUI_SetupDrawingText;
|
||||
to->SetupDrawingRect = from->VGUI_SetupDrawingRect;
|
||||
to->SetupDrawingImage = from->VGUI_SetupDrawingImage;
|
||||
to->BindTexture = from->VGUI_BindTexture;
|
||||
to->EnableTexture = from->VGUI_EnableTexture;
|
||||
to->CreateTexture = from->VGUI_CreateTexture;
|
||||
to->UploadTexture = from->VGUI_UploadTexture;
|
||||
to->UploadTextureBlock = from->VGUI_UploadTextureBlock;
|
||||
to->DrawQuad = from->VGUI_DrawQuad;
|
||||
to->GetTextureSizes = from->VGUI_GetTextureSizes;
|
||||
to->GenerateTexture = from->VGUI_GenerateTexture;
|
||||
}
|
||||
|
||||
void VGui_RegisterCvars( void )
|
||||
{
|
||||
Cvar_RegisterVariable( &vgui_utf8 );
|
||||
}
|
||||
|
||||
static const vguiapi_t gEngfuncs =
|
||||
{
|
||||
false, // Not initialized yet
|
||||
VGUI_DrawInit, // VGUI_DrawInit,
|
||||
VGUI_DrawShutdown, // VGUI_DrawShutdown,
|
||||
VGUI_SetupDrawingText, // VGUI_SetupDrawingText,
|
||||
VGUI_SetupDrawingRect, // VGUI_SetupDrawingRect,
|
||||
VGUI_SetupDrawingText, // VGUI_SetupDrawingImage, (same as text)
|
||||
VGUI_BindTexture, // VGUI_BindTexture,
|
||||
VGUI_EnableTexture, // VGUI_EnableTexture,
|
||||
VGUI_CreateTexture, // VGUI_CreateTexture,
|
||||
VGUI_UploadTexture, // VGUI_UploadTexture,
|
||||
VGUI_UploadTextureBlock, // VGUI_UploadTextureBlock,
|
||||
VGUI_DrawQuad, // VGUI_DrawQuad,
|
||||
VGUI_GetTextureSizes, // VGUI_GetTextureSizes,
|
||||
VGUI_GenerateTexture, // VGUI_GenerateTexture,
|
||||
VGUI_EngineMalloc,
|
||||
VGUI_CursorSelect,
|
||||
VGUI_GetColor,
|
||||
VGUI_IsInGame,
|
||||
Key_EnableTextInput,
|
||||
VGUI_GetMousePos,
|
||||
VGUI_UtfProcessChar,
|
||||
Platform_GetClipboardText,
|
||||
Platform_SetClipboardText,
|
||||
Platform_GetKeyModifiers,
|
||||
};
|
||||
|
||||
qboolean VGui_LoadProgs( HINSTANCE hInstance )
|
||||
{
|
||||
void (*F)( vguiapi_t* );
|
||||
qboolean client = hInstance != NULL;
|
||||
|
||||
memcpy( &vgui.dllFuncs, &gEngfuncs, sizeof( vgui.dllFuncs ));
|
||||
|
||||
// not loading interface from client.dll, load vgui_support.dll instead
|
||||
if( !client )
|
||||
{
|
||||
|
@ -305,7 +167,7 @@ qboolean VGui_LoadProgs( HINSTANCE hInstance )
|
|||
{
|
||||
if( FS_FileExists( vguiloader, false ))
|
||||
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
|
||||
else Con_Reportf( "%s: not found\n", __func__ );
|
||||
else Con_Reportf( "vgui_support: not found\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -316,15 +178,16 @@ qboolean VGui_LoadProgs( HINSTANCE hInstance )
|
|||
|
||||
if( F )
|
||||
{
|
||||
VGui_FillAPIFromRef( &vgui.dllFuncs, &ref.dllFuncs );
|
||||
F( &vgui.dllFuncs );
|
||||
|
||||
vgui.initialized = vgui.dllFuncs.initialized = true;
|
||||
Con_Reportf( "%s: initialized legacy API in %s module\n", __func__, client ? "client" : "support" );
|
||||
Con_Reportf( "vgui_support: initialized legacy API in %s module\n", client ? "client" : "support" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Con_Reportf( S_ERROR "%s: Failed to find VGUI support API entry point in %s module\n", __func__, client ? "client" : "support" );
|
||||
Con_Reportf( S_ERROR "Failed to find VGUI support API entry point in %s module\n", client ? "client" : "support" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -370,9 +233,8 @@ void VGui_Shutdown( void )
|
|||
if( vgui.hInstance )
|
||||
COM_FreeLibrary( vgui.hInstance );
|
||||
|
||||
// drop pointers to now unloaded vgui_support
|
||||
memcpy( &vgui.dllFuncs, &gEngfuncs, sizeof( vgui.dllFuncs ));
|
||||
vgui.hInstance = NULL;
|
||||
vgui.initialized = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ GNU General Public License for more details.
|
|||
#include "vid_common.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
|
||||
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
|
||||
static CVAR_DEFINE( vid_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
|
||||
static CVAR_DEFINE( vid_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
||||
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" );
|
||||
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
|
||||
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
|
||||
|
@ -27,13 +31,24 @@ static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "p
|
|||
CVAR_DEFINE_AUTO( vid_highdpi, "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
|
||||
CVAR_DEFINE_AUTO( vid_maximized, "0", FCVAR_RENDERINFO, "window maximized state, read-only" );
|
||||
CVAR_DEFINE( vid_fullscreen, "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen state (0 windowed, 1 fullscreen, 2 borderless)" );
|
||||
CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
|
||||
CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
|
||||
CVAR_DEFINE( window_xpos, "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
|
||||
CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );
|
||||
|
||||
glwstate_t glw_state;
|
||||
|
||||
/*
|
||||
=================
|
||||
VID_StartupGamma
|
||||
=================
|
||||
*/
|
||||
void VID_StartupGamma( void )
|
||||
{
|
||||
BuildGammaTable( vid_gamma.value, vid_brightness.value );
|
||||
Con_Reportf( "VID_StartupGamma: gamma %g brightness %g\n", vid_gamma.value, vid_brightness.value );
|
||||
ClearBits( vid_brightness.flags, FCVAR_CHANGED );
|
||||
ClearBits( vid_gamma.flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VID_InitDefaultResolution
|
||||
|
@ -209,6 +224,8 @@ void VID_Init( void )
|
|||
Cvar_RegisterVariable( &vid_scale );
|
||||
Cvar_RegisterVariable( &vid_fullscreen );
|
||||
Cvar_RegisterVariable( &vid_maximized );
|
||||
Cvar_RegisterVariable( &vid_brightness );
|
||||
Cvar_RegisterVariable( &vid_gamma );
|
||||
Cvar_RegisterVariable( &window_xpos );
|
||||
Cvar_RegisterVariable( &window_ypos );
|
||||
|
||||
|
@ -216,6 +233,5 @@ void VID_Init( void )
|
|||
// but supported mode list is filled by backends, so numbers are not portable any more
|
||||
Cmd_AddRestrictedCommand( "vid_setmode", VID_Mode_f, "display video mode" );
|
||||
|
||||
V_Init(); // init gamma
|
||||
R_Init(); // init renderer
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ extern glwstate_t glw_state;
|
|||
extern convar_t vid_fullscreen;
|
||||
extern convar_t vid_maximized;
|
||||
extern convar_t vid_highdpi;
|
||||
extern convar_t window_width;
|
||||
extern convar_t window_height;
|
||||
extern convar_t window_xpos;
|
||||
extern convar_t window_ypos;
|
||||
extern convar_t gl_msaa_samples;
|
||||
|
@ -48,5 +46,6 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximiz
|
|||
void VID_SetDisplayTransform( int *render_w, int *render_h );
|
||||
void VID_CheckChanges( void );
|
||||
const char *VID_GetModeString( int vid_mode );
|
||||
void VID_StartupGamma( void );
|
||||
|
||||
#endif // VID_COMMON
|
||||
|
|
|
@ -25,12 +25,11 @@ voice_state_t voice = { 0 };
|
|||
CVAR_DEFINE_AUTO( voice_enable, "1", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "enable voice chat" );
|
||||
CVAR_DEFINE_AUTO( voice_loopback, "0", FCVAR_PRIVILEGED, "loopback voice back to the speaker" );
|
||||
CVAR_DEFINE_AUTO( voice_scale, "1.0", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "incoming voice volume scale" );
|
||||
CVAR_DEFINE_AUTO( voice_transmit_scale, "1.0", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "outcoming voice volume scale" );
|
||||
CVAR_DEFINE_AUTO( voice_avggain, "0.5", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "automatic voice gain control (average)" );
|
||||
CVAR_DEFINE_AUTO( voice_maxgain, "5.0", FCVAR_PRIVILEGED|FCVAR_ARCHIVE, "automatic voice gain control (maximum)" );
|
||||
CVAR_DEFINE_AUTO( voice_inputfromfile, "0", FCVAR_PRIVILEGED, "input voice from voice_input.wav" );
|
||||
|
||||
static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale );
|
||||
static void Voice_ApplyGainAdjust( int16_t *samples, int count );
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
@ -40,25 +39,6 @@ static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale );
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
static qboolean Voice_InitCustomMode( void )
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
voice.width = sizeof( opus_int16 );
|
||||
voice.samplerate = VOICE_OPUS_CUSTOM_SAMPLERATE;
|
||||
voice.frame_size = VOICE_OPUS_CUSTOM_FRAME_SIZE;
|
||||
|
||||
voice.custom_mode = opus_custom_mode_create( SOUND_44k, voice.frame_size, &err );
|
||||
|
||||
if( !voice.custom_mode )
|
||||
{
|
||||
Con_Printf( S_ERROR "Can't create Opus Custom mode: %s\n", opus_strerror( err ));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=========================
|
||||
Voice_InitOpusDecoder
|
||||
|
@ -67,17 +47,24 @@ Voice_InitOpusDecoder
|
|||
*/
|
||||
static qboolean Voice_InitOpusDecoder( void )
|
||||
{
|
||||
int err = 0;
|
||||
int err;
|
||||
|
||||
for( int i = 0; i < cl.maxclients; i++ )
|
||||
voice.width = sizeof( opus_int16 );
|
||||
voice.samplerate = VOICE_OPUS_CUSTOM_SAMPLERATE;
|
||||
voice.frame_size = VOICE_OPUS_CUSTOM_FRAME_SIZE;
|
||||
|
||||
voice.custom_mode = opus_custom_mode_create( SOUND_44k, voice.frame_size, &err );
|
||||
if( !voice.custom_mode )
|
||||
{
|
||||
voice.decoders[i] = opus_custom_decoder_create( voice.custom_mode, VOICE_PCM_CHANNELS, &err );
|
||||
Con_Printf( S_ERROR "Can't create Opus Custom mode: %s\n", opus_strerror( err ));
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !voice.decoders[i] )
|
||||
{
|
||||
Con_Printf( S_ERROR "Can't create Opus decoder for %i: %s\n", i, opus_strerror( err ));
|
||||
return false;
|
||||
}
|
||||
voice.decoder = opus_custom_decoder_create( voice.custom_mode, VOICE_PCM_CHANNELS, &err );
|
||||
if( !voice.decoder )
|
||||
{
|
||||
Con_Printf( S_ERROR "Can't create Opus encoder: %s\n", opus_strerror( err ));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -91,7 +78,7 @@ Voice_InitOpusEncoder
|
|||
*/
|
||||
static qboolean Voice_InitOpusEncoder( int quality )
|
||||
{
|
||||
int err = 0;
|
||||
int err;
|
||||
|
||||
voice.encoder = opus_custom_encoder_create( voice.custom_mode, VOICE_PCM_CHANNELS, &err );
|
||||
if( !voice.encoder )
|
||||
|
@ -130,13 +117,10 @@ Voice_ShutdownOpusDecoder
|
|||
*/
|
||||
static void Voice_ShutdownOpusDecoder( void )
|
||||
{
|
||||
for( int i = 0; i < MAX_CLIENTS; i++ )
|
||||
if( voice.decoder )
|
||||
{
|
||||
if( !voice.decoders[i] )
|
||||
continue;
|
||||
|
||||
opus_custom_decoder_destroy( voice.decoders[i] );
|
||||
voice.decoders[i] = NULL;
|
||||
opus_custom_decoder_destroy( voice.decoder );
|
||||
voice.decoder = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,10 +137,7 @@ static void Voice_ShutdownOpusEncoder( void )
|
|||
opus_custom_encoder_destroy( voice.encoder );
|
||||
voice.encoder = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void Voice_ShutdownCustomMode( void )
|
||||
{
|
||||
if( voice.custom_mode )
|
||||
{
|
||||
opus_custom_mode_destroy( voice.custom_mode );
|
||||
|
@ -203,7 +184,7 @@ static uint Voice_GetOpusCompressedData( byte *out, uint maxsize, uint *frames )
|
|||
if( !voice.input_file )
|
||||
{
|
||||
// adjust gain before encoding, but only for input from voice
|
||||
Voice_ApplyGainAdjust((opus_int16*)(voice.input_buffer + ofs), voice.frame_size, voice_transmit_scale.value);
|
||||
Voice_ApplyGainAdjust((opus_int16*)(voice.input_buffer + ofs), voice.frame_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -257,10 +238,10 @@ Voice_ApplyGainAdjust
|
|||
|
||||
=========================
|
||||
*/
|
||||
static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
|
||||
static void Voice_ApplyGainAdjust( int16_t *samples, int count )
|
||||
{
|
||||
float gain, modifiedMax;
|
||||
int average, blockOffset = 0;
|
||||
int average, adjustedSample, blockOffset = 0;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
|
@ -279,8 +260,10 @@ static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
|
|||
localMax = absSample;
|
||||
|
||||
localSum += absSample;
|
||||
|
||||
gain = voice.autogain.current_gain + i * voice.autogain.gain_multiplier;
|
||||
samples[blockOffset + i] = bound( SHRT_MIN, (int)( sample * gain ), SHRT_MAX );
|
||||
adjustedSample = Q_min( SHRT_MAX, Q_max(( int )( sample * gain ), SHRT_MIN ));
|
||||
samples[blockOffset + i] = adjustedSample;
|
||||
}
|
||||
|
||||
if( blockOffset % voice.autogain.block_size == 0 )
|
||||
|
@ -288,9 +271,9 @@ static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
|
|||
average = localSum / blockSize;
|
||||
modifiedMax = average + ( localMax - average ) * voice_avggain.value;
|
||||
|
||||
voice.autogain.current_gain = voice.autogain.next_gain * scale;
|
||||
voice.autogain.next_gain = Q_min( (float)SHRT_MAX / modifiedMax, voice_maxgain.value ) * scale;
|
||||
voice.autogain.gain_multiplier = ( voice.autogain.next_gain - voice.autogain.current_gain ) / ( blockSize - 1 );
|
||||
voice.autogain.current_gain = voice.autogain.next_gain * voice_scale.value;
|
||||
voice.autogain.next_gain = Q_min( (float)SHRT_MAX / modifiedMax, voice_maxgain.value ) * voice_scale.value;
|
||||
voice.autogain.gain_multiplier = ( voice.autogain.next_gain - voice.autogain.current_gain ) / ( voice.autogain.block_size - 1 );
|
||||
}
|
||||
blockOffset += blockSize;
|
||||
}
|
||||
|
@ -445,9 +428,6 @@ void Voice_Disconnect( void )
|
|||
voice.players_status[i].talking_ack = false;
|
||||
}
|
||||
}
|
||||
|
||||
VoiceCapture_Shutdown();
|
||||
voice.device_opened = false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -460,7 +440,7 @@ Feed the decoded data to engine sound subsystem
|
|||
static void Voice_StartChannel( uint samples, byte *data, int entnum )
|
||||
{
|
||||
SND_ForceInitMouth( entnum );
|
||||
S_RawEntSamples( entnum, samples, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, data, bound( 0, 255 * voice_scale.value, 255 ));
|
||||
S_RawEntSamples( entnum, samples, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, data, 255 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -472,11 +452,10 @@ Received encoded voice data, decode it
|
|||
*/
|
||||
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
|
||||
{
|
||||
const int playernum = ent - 1;
|
||||
int samples = 0;
|
||||
int ofs = 0;
|
||||
|
||||
if( playernum < 0 || playernum >= cl.maxclients || !voice.decoders[playernum] )
|
||||
if( !voice.decoder )
|
||||
return;
|
||||
|
||||
// decode frame by frame
|
||||
|
@ -496,7 +475,7 @@ void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
|
|||
if( ofs + compressed_size > size )
|
||||
break;
|
||||
|
||||
frame_samples = opus_custom_decode( voice.decoders[playernum], data + ofs, compressed_size,
|
||||
frame_samples = opus_custom_decode( voice.decoder, data + ofs, compressed_size,
|
||||
(opus_int16*)voice.decompress_buffer + samples, voice.frame_size );
|
||||
|
||||
ofs += compressed_size;
|
||||
|
@ -520,8 +499,8 @@ void CL_AddVoiceToDatagram( void )
|
|||
|
||||
if( cls.state != ca_active || !Voice_IsRecording() || !voice.encoder )
|
||||
return;
|
||||
|
||||
size = Voice_GetOpusCompressedData( voice.compress_buffer, sizeof( voice.compress_buffer ), &frames );
|
||||
|
||||
size = Voice_GetOpusCompressedData( voice.output_buffer, sizeof( voice.output_buffer ), &frames );
|
||||
|
||||
if( size > 0 && MSG_GetNumBytesLeft( &cls.datagram ) >= size + 32 )
|
||||
{
|
||||
|
@ -529,7 +508,7 @@ void CL_AddVoiceToDatagram( void )
|
|||
MSG_WriteByte( &cls.datagram, voice_loopback.value != 0 );
|
||||
MSG_WriteByte( &cls.datagram, frames );
|
||||
MSG_WriteShort( &cls.datagram, size );
|
||||
MSG_WriteBytes( &cls.datagram, voice.compress_buffer, size );
|
||||
MSG_WriteBytes( &cls.datagram, voice.output_buffer, size );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,7 +524,6 @@ void Voice_RegisterCvars( void )
|
|||
Cvar_RegisterVariable( &voice_enable );
|
||||
Cvar_RegisterVariable( &voice_loopback );
|
||||
Cvar_RegisterVariable( &voice_scale );
|
||||
Cvar_RegisterVariable( &voice_transmit_scale );
|
||||
Cvar_RegisterVariable( &voice_avggain );
|
||||
Cvar_RegisterVariable( &voice_maxgain );
|
||||
Cvar_RegisterVariable( &voice_inputfromfile );
|
||||
|
@ -563,9 +541,8 @@ static void Voice_Shutdown( void )
|
|||
int i;
|
||||
|
||||
Voice_RecordStop();
|
||||
Voice_ShutdownOpusDecoder();
|
||||
Voice_ShutdownOpusEncoder();
|
||||
Voice_ShutdownCustomMode();
|
||||
Voice_ShutdownOpusDecoder();
|
||||
VoiceCapture_Shutdown();
|
||||
|
||||
if( voice.local.talking_ack )
|
||||
|
@ -611,62 +588,48 @@ Voice_Init
|
|||
Initialize the voice subsystem
|
||||
=========================
|
||||
*/
|
||||
qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
|
||||
qboolean Voice_Init( const char *pszCodecName, int quality )
|
||||
{
|
||||
if( !voice_enable.value )
|
||||
return false;
|
||||
|
||||
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
|
||||
{
|
||||
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
|
||||
return false;
|
||||
}
|
||||
|
||||
// reinitialize only if codec parameters are different
|
||||
if( Q_strcmp( pszCodecName, voice.codec ) || voice.quality != quality )
|
||||
if( !Q_strcmp( voice.codec, pszCodecName ) && voice.quality == quality )
|
||||
return true;
|
||||
|
||||
Voice_Shutdown();
|
||||
|
||||
voice.autogain.block_size = 128;
|
||||
|
||||
if( !Voice_InitOpusDecoder( ))
|
||||
{
|
||||
// no reason to init encoder and open audio device
|
||||
// if we can't hear other players
|
||||
Con_Printf( S_ERROR "Voice chat disabled.\n" );
|
||||
Voice_Shutdown();
|
||||
|
||||
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
|
||||
{
|
||||
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
|
||||
return false;
|
||||
}
|
||||
|
||||
voice.autogain.block_size = 128;
|
||||
|
||||
if( !Voice_InitCustomMode( ))
|
||||
{
|
||||
// no reason to init encoder and open audio device
|
||||
// if we can't hear other players
|
||||
Voice_Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
// we can hear others players, so it's fine to fail now
|
||||
voice.initialized = true;
|
||||
Q_strncpy( voice.codec, pszCodecName, sizeof( voice.codec ));
|
||||
|
||||
if( !Voice_InitOpusEncoder( quality ))
|
||||
{
|
||||
Con_Printf( S_WARN "Other players will not be able to hear you.\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
voice.quality = quality;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !preinit )
|
||||
// we can hear others players, so it's fine to fail now
|
||||
voice.initialized = true;
|
||||
Q_strncpy( voice.codec, pszCodecName, sizeof( voice.codec ));
|
||||
|
||||
if( !Voice_InitOpusEncoder( quality ))
|
||||
{
|
||||
Voice_ShutdownOpusDecoder();
|
||||
if( !Voice_InitOpusDecoder())
|
||||
{
|
||||
// no reason to init encoder and open audio device
|
||||
// if we can't hear other players
|
||||
Con_Printf( S_ERROR "Can't create decoders, voice chat is disabled.\n" );
|
||||
Voice_Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
voice.device_opened = VoiceCapture_Init();
|
||||
|
||||
if( !voice.device_opened )
|
||||
Con_Printf( S_WARN "No microphone is available.\n" );
|
||||
Con_Printf( S_WARN "Other players will not be able to hear you.\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
voice.quality = quality;
|
||||
|
||||
if( !VoiceCapture_Init( ))
|
||||
Con_Printf( S_WARN "No microphone is available.\n" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct OpusCustomMode OpusCustomMode;
|
|||
#define VOICE_PCM_CHANNELS 1 // always mono
|
||||
|
||||
// never change these parameters when using opuscustom
|
||||
#define VOICE_OPUS_CUSTOM_SAMPLERATE 44100
|
||||
#define VOICE_OPUS_CUSTOM_SAMPLERATE SOUND_44k
|
||||
// must follow opus custom requirements
|
||||
// also be divisible with MAX_RAW_SAMPLES
|
||||
#define VOICE_OPUS_CUSTOM_FRAME_SIZE 1024
|
||||
|
@ -53,7 +53,6 @@ typedef struct voice_state_s
|
|||
|
||||
qboolean initialized;
|
||||
qboolean is_recording;
|
||||
qboolean device_opened;
|
||||
double start_time;
|
||||
|
||||
voice_status_t local;
|
||||
|
@ -62,7 +61,7 @@ typedef struct voice_state_s
|
|||
// opus stuff
|
||||
OpusCustomMode *custom_mode;
|
||||
OpusCustomEncoder *encoder;
|
||||
OpusCustomDecoder *decoders[MAX_CLIENTS];
|
||||
OpusCustomDecoder *decoder;
|
||||
|
||||
// audio info
|
||||
uint width;
|
||||
|
@ -71,7 +70,7 @@ typedef struct voice_state_s
|
|||
|
||||
// buffers
|
||||
byte input_buffer[MAX_RAW_SAMPLES];
|
||||
byte compress_buffer[MAX_RAW_SAMPLES];
|
||||
byte output_buffer[MAX_RAW_SAMPLES];
|
||||
byte decompress_buffer[MAX_RAW_SAMPLES];
|
||||
fs_offset_t input_buffer_pos; // in bytes
|
||||
|
||||
|
@ -93,7 +92,7 @@ extern voice_state_t voice;
|
|||
void CL_AddVoiceToDatagram( void );
|
||||
|
||||
void Voice_RegisterCvars( void );
|
||||
qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit );
|
||||
qboolean Voice_Init( const char *pszCodecName, int quality );
|
||||
void Voice_Idle( double frametime );
|
||||
qboolean Voice_IsRecording( void );
|
||||
void Voice_RecordStop( void );
|
||||
|
|
|
@ -16,20 +16,22 @@ GNU General Public License for more details.
|
|||
#ifndef VOX_H
|
||||
#define VOX_H
|
||||
|
||||
#define CVOXWORDMAX 64
|
||||
#define SENTENCE_INDEX -99999 // unique sentence index
|
||||
#define CVOXWORDMAX 64
|
||||
#define CVOXFILESENTENCEMAX 4096
|
||||
|
||||
#define SENTENCE_INDEX -99999 // unique sentence index
|
||||
|
||||
typedef struct voxword_s
|
||||
{
|
||||
int volume; // increase percent, ie: 125 = 125% increase
|
||||
int pitch; // pitch shift up percent
|
||||
int start; // offset start of wave percent
|
||||
int end; // offset end of wave percent
|
||||
int cbtrim; // end of wave after being trimmed to 'end'
|
||||
int fKeepCached; // 1 if this word was already in cache before sentence referenced it
|
||||
int samplefrac; // if pitch shifting, this is position into wav * 256
|
||||
int timecompress; // % of wave to skip during playback (causes no pitch shift)
|
||||
sfx_t *sfx; // name and cache pointer
|
||||
int volume; // increase percent, ie: 125 = 125% increase
|
||||
int pitch; // pitch shift up percent
|
||||
int start; // offset start of wave percent
|
||||
int end; // offset end of wave percent
|
||||
int cbtrim; // end of wave after being trimmed to 'end'
|
||||
int fKeepCached; // 1 if this word was already in cache before sentence referenced it
|
||||
int samplefrac; // if pitch shifting, this is position into wav * 256
|
||||
int timecompress; // % of wave to skip during playback (causes no pitch shift)
|
||||
sfx_t *sfx; // name and cache pointer
|
||||
} voxword_t;
|
||||
|
||||
struct channel_s;
|
||||
|
|
|
@ -19,15 +19,13 @@ GNU General Public License for more details.
|
|||
|
||||
#define HASH_SIZE 128 // 128 * 4 * 4 == 2048 bytes
|
||||
|
||||
typedef struct base_command_hashmap_s base_command_hashmap_t;
|
||||
|
||||
struct base_command_hashmap_s
|
||||
typedef struct base_command_hashmap_s
|
||||
{
|
||||
base_command_t *basecmd; // base command: cvar, alias or command
|
||||
base_command_hashmap_t *next;
|
||||
base_command_type_e type; // type for faster searching
|
||||
char name[1]; // key for searching
|
||||
};
|
||||
base_command_t *basecmd; // base command: cvar, alias or command
|
||||
const char *name; // key for searching
|
||||
base_command_type_e type; // type for faster searching
|
||||
struct base_command_hashmap_s *next;
|
||||
} base_command_hashmap_t;
|
||||
|
||||
static base_command_hashmap_t *hashed_cmds[HASH_SIZE];
|
||||
|
||||
|
@ -126,12 +124,11 @@ void BaseCmd_Insert( base_command_type_e type, base_command_t *basecmd, const ch
|
|||
{
|
||||
base_command_hashmap_t *elem, *cur, *find;
|
||||
uint hash = BaseCmd_HashKey( name );
|
||||
size_t len = Q_strlen( name );
|
||||
|
||||
elem = Z_Malloc( sizeof( base_command_hashmap_t ) + len );
|
||||
elem = Z_Malloc( sizeof( base_command_hashmap_t ) );
|
||||
elem->basecmd = basecmd;
|
||||
elem->type = type;
|
||||
Q_strncpy( elem->name, name, len + 1 );
|
||||
elem->name = name;
|
||||
|
||||
// link the variable in alphanumerical order
|
||||
for( cur = NULL, find = hashed_cmds[hash];
|
||||
|
@ -162,7 +159,7 @@ void BaseCmd_Remove( base_command_type_e type, const char *name )
|
|||
|
||||
if( !i )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: Couldn't find %s in buckets\n", __func__, name );
|
||||
Con_Reportf( S_ERROR "Couldn't find %s in buckets\n", name );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ typedef enum base_command_type
|
|||
|
||||
typedef void base_command_t;
|
||||
|
||||
|
||||
|
||||
void BaseCmd_Init( void );
|
||||
base_command_t *BaseCmd_Find( base_command_type_e type, const char *name );
|
||||
void BaseCmd_FindAll( const char *name,
|
||||
|
|
|
@ -52,7 +52,7 @@ CSCR_ExpectString
|
|||
Return true if next token is pExpext and skip it
|
||||
===================
|
||||
*/
|
||||
static qboolean CSCR_ExpectString( parserstate_t *ps, const char *pExpect, qboolean skip, qboolean error )
|
||||
qboolean CSCR_ExpectString( parserstate_t *ps, const char *pExpect, qboolean skip, qboolean error )
|
||||
{
|
||||
char *tmp = COM_ParseFile( ps->buf, ps->token, sizeof( ps->token ));
|
||||
|
||||
|
@ -75,7 +75,7 @@ CSCR_ParseType
|
|||
Determine script variable type
|
||||
===================
|
||||
*/
|
||||
static cvartype_t CSCR_ParseType( parserstate_t *ps )
|
||||
cvartype_t CSCR_ParseType( parserstate_t *ps )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -96,7 +96,7 @@ static cvartype_t CSCR_ParseType( parserstate_t *ps )
|
|||
CSCR_ParseSingleCvar
|
||||
=========================
|
||||
*/
|
||||
static qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result )
|
||||
qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result )
|
||||
{
|
||||
// read the name
|
||||
ps->buf = COM_ParseFile( ps->buf, result->name, sizeof( result->name ));
|
||||
|
@ -170,7 +170,7 @@ CSCR_ParseHeader
|
|||
Check version and seek to first cvar name
|
||||
======================
|
||||
*/
|
||||
static qboolean CSCR_ParseHeader( parserstate_t *ps )
|
||||
qboolean CSCR_ParseHeader( parserstate_t *ps )
|
||||
{
|
||||
if( !CSCR_ExpectString( ps, "VERSION", false, true ))
|
||||
return false;
|
||||
|
|
|
@ -53,7 +53,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
|
|||
Cbuf_Init
|
||||
============
|
||||
*/
|
||||
static void Cbuf_Init( void )
|
||||
void Cbuf_Init( void )
|
||||
{
|
||||
cmd_text.data = cmd_text_buf;
|
||||
filteredcmd_text.data = filteredcmd_text_buf;
|
||||
|
@ -79,14 +79,14 @@ void Cbuf_Clear( void )
|
|||
Cbuf_GetSpace
|
||||
============
|
||||
*/
|
||||
static void *Cbuf_GetSpace( cmdbuf_t *buf, int length )
|
||||
void *Cbuf_GetSpace( cmdbuf_t *buf, int length )
|
||||
{
|
||||
void *data;
|
||||
|
||||
if(( buf->cursize + length ) > buf->maxsize )
|
||||
{
|
||||
buf->cursize = 0;
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
Host_Error( "Cbuf_GetSpace: overflow\n" );
|
||||
}
|
||||
|
||||
data = buf->data + buf->cursize;
|
||||
|
@ -156,7 +156,7 @@ static void Cbuf_InsertTextToBuffer( cmdbuf_t *buf, const char *text )
|
|||
|
||||
if(( buf->cursize + l ) >= buf->maxsize )
|
||||
{
|
||||
Con_Reportf( S_WARN "%s: overflow\n", __func__ );
|
||||
Con_Reportf( S_WARN "Cbuf_InsertText: overflow\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ void Cbuf_InsertText( const char *text )
|
|||
Cbuf_Execute
|
||||
============
|
||||
*/
|
||||
static void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged, int cmdsToExecute )
|
||||
void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged, int cmdsToExecute )
|
||||
{
|
||||
char *text;
|
||||
char line[MAX_CMD_LINE];
|
||||
|
@ -224,7 +224,7 @@ static void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged
|
|||
|
||||
if( i >= ( MAX_CMD_LINE - 1 ))
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: command string owerflow\n", __func__ );
|
||||
Con_DPrintf( S_ERROR "Cbuf_Execute: command string owerflow\n" );
|
||||
line[0] = 0;
|
||||
}
|
||||
else
|
||||
|
@ -356,7 +356,7 @@ hl.exe -dev 3 +map c1a0d
|
|||
hl.exe -nosound -game bshift
|
||||
===============
|
||||
*/
|
||||
static void Cmd_StuffCmds_f( void )
|
||||
void Cmd_StuffCmds_f( void )
|
||||
{
|
||||
host.stuffcmds_pending = true;
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ next frame. This allows commands like:
|
|||
bind g "cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster"
|
||||
============
|
||||
*/
|
||||
static void Cmd_Wait_f( void )
|
||||
void Cmd_Wait_f( void )
|
||||
{
|
||||
cmd_wait = true;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ Cmd_Echo_f
|
|||
Just prints the rest of the line to the console
|
||||
===============
|
||||
*/
|
||||
static void Cmd_Echo_f( void )
|
||||
void Cmd_Echo_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -398,7 +398,7 @@ Cmd_Alias_f
|
|||
Creates a new command that executes a command string (possibly ; seperated)
|
||||
===============
|
||||
*/
|
||||
static void Cmd_Alias_f( void )
|
||||
void Cmd_Alias_f( void )
|
||||
{
|
||||
cmdalias_t *a;
|
||||
char cmd[MAX_CMD_LINE];
|
||||
|
@ -529,6 +529,7 @@ typedef struct cmd_s
|
|||
static int cmd_argc;
|
||||
static const char *cmd_args = NULL;
|
||||
static char *cmd_argv[MAX_CMD_TOKENS];
|
||||
static char cmd_tokenized[MAX_CMD_BUFFER]; // will have 0 bytes inserted
|
||||
static cmd_t *cmd_functions; // possible commands to execute
|
||||
|
||||
/*
|
||||
|
@ -640,7 +641,7 @@ void Cmd_TokenizeString( const char *text )
|
|||
while( 1 )
|
||||
{
|
||||
// skip whitespace up to a /n
|
||||
while( *text && ((byte)*text ) <= ' ' && *text != '\r' && *text != '\n' )
|
||||
while( *text && *text <= ' ' && *text != '\r' && *text != '\n' )
|
||||
text++;
|
||||
|
||||
if( *text == '\n' || *text == '\r' )
|
||||
|
@ -682,7 +683,7 @@ static int Cmd_AddCommandEx( const char *funcname, const char *cmd_name, xcomman
|
|||
|
||||
if( !COM_CheckString( cmd_name ))
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: NULL name\n", funcname );
|
||||
Con_Reportf( S_ERROR "%s: NULL name\n", funcname );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -728,7 +729,7 @@ Cmd_AddCommand
|
|||
*/
|
||||
void Cmd_AddCommand( const char *cmd_name, xcommand_t function, const char *cmd_desc )
|
||||
{
|
||||
Cmd_AddCommandEx( __func__, cmd_name, function, cmd_desc, 0 );
|
||||
Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, cmd_desc, 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -739,7 +740,7 @@ Cmd_AddRestrictedCommand
|
|||
*/
|
||||
void Cmd_AddRestrictedCommand( const char *cmd_name, xcommand_t function, const char *cmd_desc )
|
||||
{
|
||||
Cmd_AddCommandEx( __func__, cmd_name, function, cmd_desc, CMD_PRIVILEGED );
|
||||
Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, cmd_desc, CMD_PRIVILEGED );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -749,7 +750,7 @@ Cmd_AddServerCommand
|
|||
*/
|
||||
void GAME_EXPORT Cmd_AddServerCommand( const char *cmd_name, xcommand_t function )
|
||||
{
|
||||
Cmd_AddCommandEx( __func__, cmd_name, function, "server command", CMD_SERVERDLL );
|
||||
Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, "server command", CMD_SERVERDLL );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -767,7 +768,7 @@ int GAME_EXPORT Cmd_AddClientCommand( const char *cmd_name, xcommand_t function
|
|||
flags |= CMD_PRIVILEGED;
|
||||
}
|
||||
|
||||
return Cmd_AddCommandEx( __func__, cmd_name, function, "client command", flags );
|
||||
return Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, "client command", flags );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -777,7 +778,7 @@ Cmd_AddGameUICommand
|
|||
*/
|
||||
int GAME_EXPORT Cmd_AddGameUICommand( const char *cmd_name, xcommand_t function )
|
||||
{
|
||||
return Cmd_AddCommandEx( __func__, cmd_name, function, "gameui command", CMD_GAMEUIDLL );
|
||||
return Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, "gameui command", CMD_GAMEUIDLL );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -787,7 +788,7 @@ Cmd_AddRefCommand
|
|||
*/
|
||||
int Cmd_AddRefCommand( const char *cmd_name, xcommand_t function, const char *description )
|
||||
{
|
||||
return Cmd_AddCommandEx( __func__, cmd_name, function, description, CMD_REFDLL );
|
||||
return Cmd_AddCommandEx( __FUNCTION__, cmd_name, function, description, CMD_REFDLL );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -881,7 +882,7 @@ Cmd_If_f
|
|||
Compare and et condition bit if true
|
||||
============
|
||||
*/
|
||||
static void Cmd_If_f( void )
|
||||
void Cmd_If_f( void )
|
||||
{
|
||||
// reset bit first
|
||||
cmd_condition &= ~BIT( cmd_condlevel );
|
||||
|
@ -942,14 +943,14 @@ Cmd_Else_f
|
|||
Invert condition bit
|
||||
============
|
||||
*/
|
||||
static void Cmd_Else_f( void )
|
||||
void Cmd_Else_f( void )
|
||||
{
|
||||
cmd_condition ^= BIT( cmd_condlevel );
|
||||
}
|
||||
|
||||
static qboolean Cmd_ShouldAllowCommand( cmd_t *cmd, qboolean isPrivileged )
|
||||
{
|
||||
const char *prefixes[] = { "cl_", "gl_", "r_", "m_", "hud_", "joy_", "con_", "scr_" };
|
||||
const char *prefixes[] = { "cl_", "gl_", "r_", "m_", "hud_" };
|
||||
int i;
|
||||
|
||||
// always allow local commands
|
||||
|
@ -1015,7 +1016,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
|
|||
*ptoken++ = *text++;
|
||||
*ptoken = 0;
|
||||
|
||||
len += Q_strncpy( pcmd, Cvar_VariableString( token ), sizeof( token ) - len );
|
||||
len += Q_strncpy( pcmd, Cvar_VariableString( token ), MAX_CMD_LINE - len );
|
||||
pcmd = command + len;
|
||||
|
||||
if( !*text ) break;
|
||||
|
@ -1178,7 +1179,7 @@ void Cmd_ForwardToServer( void )
|
|||
Cmd_List_f
|
||||
============
|
||||
*/
|
||||
static void Cmd_List_f( void )
|
||||
void Cmd_List_f( void )
|
||||
{
|
||||
cmd_t *cmd;
|
||||
int i = 0;
|
||||
|
|
|
@ -17,28 +17,22 @@ GNU General Public License for more details.
|
|||
#define COM_STRINGS_H
|
||||
|
||||
// default colored message headers
|
||||
#define S_BLACK "^0"
|
||||
#define S_RED "^1"
|
||||
#define S_GREEN "^2"
|
||||
#define S_YELLOW "^3"
|
||||
#define S_BLUE "^4"
|
||||
#define S_CYAN "^5"
|
||||
#define S_MAGENTA "^6"
|
||||
#define S_DEFAULT "^7"
|
||||
#define S_NOTE "^2Note:^7 "
|
||||
#define S_WARN "^3Warning:^7 "
|
||||
#define S_ERROR "^1Error:^7 "
|
||||
#define S_USAGE "Usage: "
|
||||
#define S_USAGE_INDENT " "
|
||||
|
||||
#define S_NOTE S_GREEN "Note: " S_DEFAULT
|
||||
#define S_WARN S_YELLOW "Warning: " S_DEFAULT
|
||||
#define S_ERROR S_RED "Error: " S_DEFAULT
|
||||
#define S_USAGE "Usage: "
|
||||
#define S_USAGE_INDENT "\t"
|
||||
|
||||
#define S_OPENGL_NOTE S_GREEN "OpenGL Note: " S_DEFAULT
|
||||
#define S_OPENGL_WARN S_YELLOW "OpenGL Warning: " S_DEFAULT
|
||||
#define S_OPENGL_ERROR S_RED "OpenGL Error: " S_DEFAULT
|
||||
#define S_OPENGL_NOTE "^2OpenGL Note:^7 "
|
||||
#define S_OPENGL_WARN "^3OpenGL Warning:^7 "
|
||||
#define S_OPENGL_ERROR "^3OpenGL Error:^7 "
|
||||
|
||||
// end game final default message
|
||||
#define DEFAULT_ENDGAME_MESSAGE "The End"
|
||||
|
||||
// path to the hash-pak that contain custom player decals
|
||||
#define CUSTOM_RES_PATH "custom.hpk"
|
||||
|
||||
// path to default playermodel in GoldSrc
|
||||
#define DEFAULT_PLAYER_PATH_HALFLIFE "models/player.mdl"
|
||||
|
||||
|
@ -59,7 +53,7 @@ GNU General Public License for more details.
|
|||
#define DEFAULT_SAVE_DIRECTORY "save/"
|
||||
|
||||
// fallback to this skybox
|
||||
#define DEFAULT_SKYBOX_NAME "desert"
|
||||
#define DEFAULT_SKYBOX_PATH "gfx/env/desert"
|
||||
|
||||
// playlist for startup videos
|
||||
#define DEFAULT_VIDEOLIST_PATH "media/StartupVids.txt"
|
||||
|
@ -71,7 +65,6 @@ GNU General Public License for more details.
|
|||
#define DEFAULT_UPDATE_PAGE "https://github.com/FWGS/xash3d-fwgs/releases/latest"
|
||||
|
||||
#define XASH_ENGINE_NAME "Xash3D FWGS"
|
||||
#define XASH_DEDICATED_SERVER_NAME "XashDS"
|
||||
#define XASH_VERSION "0.20" // engine current version
|
||||
#define XASH_COMPAT_VERSION "0.99" // version we are based on
|
||||
|
||||
|
|
|
@ -25,19 +25,16 @@ GNU General Public License for more details.
|
|||
|
||||
static const char *file_exts[] =
|
||||
{
|
||||
// ban text files that don't make sense as resource
|
||||
"cfg", "lst", "ini", "log",
|
||||
|
||||
// ban Windows code
|
||||
"exe", "vbs", "com", "bat",
|
||||
"dll", "sys", "ps1",
|
||||
|
||||
// ban common unix code
|
||||
// NOTE: in unix anything can be executed as long it has access flag
|
||||
"so", "sh", "dylib",
|
||||
|
||||
// ban mobile archives
|
||||
"apk", "ipa",
|
||||
"cfg",
|
||||
"lst",
|
||||
"exe",
|
||||
"vbs",
|
||||
"com",
|
||||
"bat",
|
||||
"dll",
|
||||
"ini",
|
||||
"log",
|
||||
"sys",
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
@ -393,9 +390,6 @@ byte *LZSS_Compress( byte *pInput, int inputLength, uint *pOutputSize )
|
|||
byte *pFinal = NULL;
|
||||
lzss_state_t state;
|
||||
|
||||
if( !pStart )
|
||||
return NULL;
|
||||
|
||||
memset( &state, 0, sizeof( state ));
|
||||
state.window_size = LZSS_WINDOW_SIZE;
|
||||
|
||||
|
@ -537,6 +531,47 @@ int GAME_EXPORT COM_FileSize( const char *filename )
|
|||
return FS_FileSize( filename, false );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
COM_AddAppDirectoryToSearchPath
|
||||
|
||||
=============
|
||||
*/
|
||||
void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
|
||||
{
|
||||
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
COM_ExpandFilename
|
||||
|
||||
Finds the file in the search path, copies over the name with the full path name.
|
||||
This doesn't search in the pak file.
|
||||
===========
|
||||
*/
|
||||
int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
|
||||
{
|
||||
char result[MAX_SYSPATH];
|
||||
|
||||
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
|
||||
return 0;
|
||||
|
||||
// filename examples:
|
||||
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
|
||||
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
|
||||
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
|
||||
{
|
||||
// check for enough room
|
||||
if( Q_strlen( result ) > nameOutBufferSize )
|
||||
return 0;
|
||||
|
||||
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
COM_TrimSpace
|
||||
|
@ -699,7 +734,7 @@ COM_LoadFileForMe
|
|||
byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
|
||||
{
|
||||
string name;
|
||||
byte *pfile;
|
||||
byte *file, *pfile;
|
||||
fs_offset_t iLength;
|
||||
|
||||
if( !COM_CheckString( filename ))
|
||||
|
@ -712,9 +747,21 @@ byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
|
|||
Q_strncpy( name, filename, sizeof( name ));
|
||||
COM_FixSlashes( name );
|
||||
|
||||
pfile = g_fsapi.LoadFileMalloc( name, &iLength, false );
|
||||
pfile = FS_LoadFile( name, &iLength, false );
|
||||
if( pLength ) *pLength = (int)iLength;
|
||||
|
||||
if( pfile )
|
||||
{
|
||||
file = malloc( iLength + 1 );
|
||||
if( file != NULL )
|
||||
{
|
||||
memcpy( file, pfile, iLength );
|
||||
file[iLength] = '\0';
|
||||
}
|
||||
Mem_Free( pfile );
|
||||
pfile = file;
|
||||
}
|
||||
|
||||
return pfile;
|
||||
}
|
||||
|
||||
|
@ -822,6 +869,18 @@ cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName )
|
|||
return (cvar_t *)Cvar_FindVar( szVarName );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
pfnCVarDirectSet
|
||||
|
||||
allow to set cvar directly
|
||||
=============
|
||||
*/
|
||||
void GAME_EXPORT pfnCVarDirectSet( cvar_t *var, const char *szValue )
|
||||
{
|
||||
Cvar_DirectSet( (convar_t *)var, szValue );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
COM_CompareFileTime
|
||||
|
@ -903,10 +962,7 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
|||
if( !COM_CheckString( filename ))
|
||||
return false;
|
||||
|
||||
ext = COM_FileExtension( lwrfilename );
|
||||
|
||||
// only allow extensionless files that start with !MD5
|
||||
if( !Q_strncmp( filename, "!MD5", 4 ) && ext[0] == 0 )
|
||||
if( !Q_strncmp( filename, "!MD5", 4 ))
|
||||
return true;
|
||||
|
||||
Q_strnlwr( filename, lwrfilename, sizeof( lwrfilename ));
|
||||
|
@ -929,6 +985,8 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
|||
if( Q_strlen( first ) != 4 )
|
||||
return false;
|
||||
|
||||
ext = COM_FileExtension( lwrfilename );
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( file_exts ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( ext, file_exts[i] ))
|
||||
|
@ -938,6 +996,21 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
|||
return true;
|
||||
}
|
||||
|
||||
const char *COM_GetResourceTypeName( resourcetype_t restype )
|
||||
{
|
||||
switch( restype )
|
||||
{
|
||||
case t_decal: return "decal";
|
||||
case t_eventscript: return "eventscript";
|
||||
case t_generic: return "generic";
|
||||
case t_model: return "model";
|
||||
case t_skin: return "skin";
|
||||
case t_sound: return "sound";
|
||||
case t_world: return "world";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
|
||||
{
|
||||
size_t size;
|
||||
|
@ -971,7 +1044,7 @@ used by CS:CZ
|
|||
*/
|
||||
void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
|
||||
{
|
||||
Msg( "%s: file %s, entry %s\n", __func__, fileName, entryName );
|
||||
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -985,7 +1058,7 @@ used by CS:CZ
|
|||
*/
|
||||
void *GAME_EXPORT pfnSequencePickSentence( const char *groupName, int pickMethod, int *picked )
|
||||
{
|
||||
Msg( "%s: group %s, pickMethod %i\n", __func__, groupName, pickMethod );
|
||||
Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod );
|
||||
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -157,16 +157,13 @@ extern convar_t gl_vsync;
|
|||
extern convar_t scr_loading;
|
||||
extern convar_t scr_download;
|
||||
extern convar_t cmd_scripting;
|
||||
extern convar_t host_allow_materials;
|
||||
extern convar_t cl_allow_levelshots;
|
||||
extern convar_t host_developer;
|
||||
extern convar_t host_limitlocal;
|
||||
extern convar_t host_maxfps;
|
||||
extern convar_t sys_timescale;
|
||||
extern convar_t cl_filterstuffcmd;
|
||||
extern convar_t rcon_password;
|
||||
extern convar_t hpk_custom_file;
|
||||
|
||||
#define Mod_AllowMaterials() ( host_allow_materials.value != 0.0f && !FBitSet( host.features, ENGINE_DISABLE_HDTEXTURES ))
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
@ -183,6 +180,15 @@ GAMEINFO stuff
|
|||
internal shared gameinfo structure (readonly for engine parts)
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct sysinfo_s
|
||||
{
|
||||
string exeName; // exe.filename
|
||||
string rcName; // .rc script name
|
||||
string basedirName; // name of base directory
|
||||
string gamedll;
|
||||
string clientlib;
|
||||
} sysinfo_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HOST_INIT = 0, // initalize operations
|
||||
|
@ -267,83 +273,98 @@ typedef struct
|
|||
|
||||
typedef enum bugcomp_e
|
||||
{
|
||||
// reverts fix for pfnPEntityOfEntIndex for bug compatibility with GoldSrc
|
||||
BUGCOMP_PENTITYOFENTINDEX_FLAG = BIT( 0 ),
|
||||
// default mode, we assume that user dlls are not relying on engine bugs
|
||||
BUGCOMP_OFF,
|
||||
|
||||
// rewrites mod's attempts to write GoldSrc-specific messages into Xash protocol
|
||||
// (new wrappers are added by request)
|
||||
BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG = BIT( 1 ),
|
||||
// GoldSrc mode, user dlls are relying on GoldSrc specific bugs
|
||||
// but fixing them may break regular Xash games
|
||||
BUGCOMP_GOLDSRC,
|
||||
} bugcomp_t;
|
||||
|
||||
typedef struct host_parm_s
|
||||
{
|
||||
// ==== shared through RefAPI's ref_host_t
|
||||
double realtime; // host.curtime
|
||||
double frametime; // time between engine frames
|
||||
uint features; // custom features that enables by mod-maker request
|
||||
// ==== shared through RefAPI's ref_host_t
|
||||
HINSTANCE hInst;
|
||||
HANDLE hMutex;
|
||||
|
||||
host_status_t status; // global host state
|
||||
game_status_t game; // game manager
|
||||
uint type; // running at
|
||||
poolhandle_t mempool; // static mempool for misc allocations
|
||||
poolhandle_t imagepool; // imagelib mempool
|
||||
poolhandle_t soundpool; // soundlib mempool
|
||||
string finalmsg; // server shutdown final message
|
||||
string downloadfile; // filename to be downloading
|
||||
int downloadcount; // how many files remain to downloading
|
||||
char deferred_cmd[128];// deferred commands
|
||||
|
||||
host_redirect_t rd; // remote console
|
||||
|
||||
void *hWnd; // main window
|
||||
host_status_t status; // global host state
|
||||
game_status_t game; // game manager
|
||||
uint type; // running at
|
||||
jmp_buf abortframe; // abort current frame
|
||||
dword errorframe; // to prevent multiple host error
|
||||
poolhandle_t mempool; // static mempool for misc allocations
|
||||
string finalmsg; // server shutdown final message
|
||||
string downloadfile; // filename to be downloading
|
||||
int downloadcount; // how many files remain to downloading
|
||||
char deferred_cmd[128]; // deferred commands
|
||||
host_redirect_t rd; // remote console
|
||||
|
||||
// command line parms
|
||||
char **argv;
|
||||
int argc;
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
uint framecount; // global framecount
|
||||
uint errorframe; // to prevent multiple host error
|
||||
uint32_t bugcomp; // bug compatibility level, for very "special" games
|
||||
double realframetime; // for some system events, e.g. console animations
|
||||
double starttime; // measure time to first frame
|
||||
double pureframetime; // count of sleeps can be inserted between frames
|
||||
double force_draw_version_time;
|
||||
double realtime; // host.curtime
|
||||
double frametime; // time between engine frames
|
||||
double realframetime; // for some system events, e.g. console animations
|
||||
|
||||
char draw_decals[MAX_DECALS][MAX_QPATH]; // list of unique decal indexes
|
||||
vec3_t player_mins[MAX_MAP_HULLS]; // 4 hulls allowed
|
||||
vec3_t player_maxs[MAX_MAP_HULLS]; // 4 hulls allowed
|
||||
uint framecount; // global framecount
|
||||
|
||||
qboolean allow_console; // allow console in dev-mode or multiplayer game
|
||||
qboolean allow_console_init; // initial value to allow the console
|
||||
qboolean key_overstrike; // key overstrike mode
|
||||
qboolean stuffcmds_pending; // should execute stuff commands
|
||||
qboolean allow_cheats; // this host will allow cheating
|
||||
qboolean change_game; // initialize when game is changed
|
||||
qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!)
|
||||
qboolean shutdown_issued; // engine is shutting down
|
||||
qboolean apply_game_config; // when true apply only to game cvars and ignore all other commands
|
||||
qboolean apply_opengl_config; // when true apply only to opengl cvars and ignore all other commands
|
||||
qboolean config_executed; // a bit who indicated was config.cfg already executed e.g. from valve.rc
|
||||
qboolean crashed; // set to true if crashed
|
||||
#if XASH_DLL_LOADER
|
||||
qboolean enabledll;
|
||||
#endif
|
||||
qboolean textmode;
|
||||
// list of unique decal indexes
|
||||
char draw_decals[MAX_DECALS][MAX_QPATH];
|
||||
|
||||
vec3_t player_mins[MAX_MAP_HULLS]; // 4 hulls allowed
|
||||
vec3_t player_maxs[MAX_MAP_HULLS]; // 4 hulls allowed
|
||||
|
||||
void* hWnd; // main window
|
||||
qboolean allow_console; // allow console in dev-mode or multiplayer game
|
||||
qboolean allow_console_init; // initial value to allow the console
|
||||
qboolean key_overstrike; // key overstrike mode
|
||||
qboolean stuffcmds_pending; // should execute stuff commands
|
||||
qboolean allow_cheats; // this host will allow cheating
|
||||
qboolean con_showalways; // show console always (developer and dedicated)
|
||||
qboolean change_game; // initialize when game is changed
|
||||
qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!)
|
||||
qboolean shutdown_issued; // engine is shutting down
|
||||
double force_draw_version_time;
|
||||
qboolean apply_game_config; // when true apply only to game cvars and ignore all other commands
|
||||
qboolean apply_opengl_config;// when true apply only to opengl cvars and ignore all other commands
|
||||
qboolean config_executed; // a bit who indicated was config.cfg already executed e.g. from valve.rc
|
||||
qboolean crashed; // set to true if crashed
|
||||
qboolean daemonized;
|
||||
qboolean enabledll;
|
||||
qboolean textmode;
|
||||
|
||||
// some settings were changed and needs to global update
|
||||
qboolean userinfo_changed;
|
||||
qboolean movevars_changed;
|
||||
qboolean renderinfo_changed;
|
||||
qboolean userinfo_changed;
|
||||
qboolean movevars_changed;
|
||||
qboolean renderinfo_changed;
|
||||
|
||||
char rootdir[MAX_OSPATH]; // member root directory
|
||||
char rodir[MAX_OSPATH]; // readonly root
|
||||
char gamefolder[MAX_QPATH]; // it's a default gamefolder
|
||||
poolhandle_t imagepool; // imagelib mempool
|
||||
poolhandle_t soundpool; // soundlib mempool
|
||||
|
||||
uint features; // custom features that enables by mod-maker request
|
||||
|
||||
// for IN_MouseMove() easy access
|
||||
int window_center_x;
|
||||
int window_center_y;
|
||||
string gamedll;
|
||||
string clientlib;
|
||||
int window_center_x;
|
||||
int window_center_y;
|
||||
|
||||
struct decallist_s *decalList; // used for keep decals, when renderer is restarted or changed
|
||||
int numdecals;
|
||||
|
||||
// bug compatibility level, for very "special" games
|
||||
bugcomp_t bugcomp;
|
||||
|
||||
// measure time to first frame
|
||||
double starttime;
|
||||
|
||||
// count of sleeps can be inserted between frames
|
||||
double pureframetime;
|
||||
} host_parm_t;
|
||||
|
||||
extern host_parm_t host;
|
||||
extern sysinfo_t SI;
|
||||
|
||||
#define CMD_SERVERDLL BIT( 0 ) // added by server.dll
|
||||
#define CMD_CLIENTDLL BIT( 1 ) // added by client.dll
|
||||
|
@ -357,13 +378,15 @@ typedef void (*xcommand_t)( void );
|
|||
//
|
||||
// filesystem_engine.c
|
||||
//
|
||||
void FS_Init( const char *basedir );
|
||||
qboolean FS_LoadProgs( void );
|
||||
void FS_Init( void );
|
||||
void FS_Shutdown( void );
|
||||
void *FS_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
// cmd.c
|
||||
//
|
||||
void Cbuf_Init( void );
|
||||
void Cbuf_Clear( void );
|
||||
void Cbuf_AddText( const char *text );
|
||||
void Cbuf_AddTextf( const char *text, ... ) _format( 1 );
|
||||
|
@ -387,6 +410,9 @@ void Cmd_RemoveCommand( const char *cmd_name );
|
|||
qboolean Cmd_Exists( const char *cmd_name );
|
||||
void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback );
|
||||
int Cmd_ListMaps( search_t *t , char *lastmapname, size_t len );
|
||||
qboolean Cmd_GetMapList( const char *s, char *completedname, int length );
|
||||
qboolean Cmd_GetDemoList( const char *s, char *completedname, int length );
|
||||
qboolean Cmd_GetMovieList( const char *s, char *completedname, int length );
|
||||
void Cmd_TokenizeString( const char *text );
|
||||
void Cmd_ExecuteString( const char *text );
|
||||
void Cmd_ForwardToServer( void );
|
||||
|
@ -396,8 +422,8 @@ void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
|
|||
// zone.c
|
||||
//
|
||||
void Memory_Init( void );
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
|
||||
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
||||
|
@ -433,12 +459,13 @@ void FS_FreeImage( rgbdata_t *pack );
|
|||
extern const bpc_desc_t PFDesc[]; // image get pixelformat
|
||||
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float reserved );
|
||||
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size );
|
||||
void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size );
|
||||
void Image_SetForceFlags( uint flags ); // set image force flags on loading
|
||||
size_t Image_DXTGetLinearSize( int type, int width, int height, int depth );
|
||||
qboolean Image_CustomPalette( void );
|
||||
void Image_ClearForceFlags( void );
|
||||
void Image_SetMDLPointer( byte *p );
|
||||
void Image_CheckPaletteQ1( void );
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
|
@ -455,6 +482,14 @@ typedef enum
|
|||
WF_TOTALCOUNT, // must be last
|
||||
} sndformat_t;
|
||||
|
||||
// soundlib global settings
|
||||
typedef enum
|
||||
{
|
||||
SL_USE_LERPING = BIT(0), // lerping sounds during resample
|
||||
SL_KEEP_8BIT = BIT(1), // don't expand 8bit sounds automatically up to 16 bit
|
||||
SL_ALLOW_OVERWRITE = BIT(2), // allow to overwrite stored sounds
|
||||
} slFlags_t;
|
||||
|
||||
// wavdata output flags
|
||||
typedef enum
|
||||
{
|
||||
|
@ -463,20 +498,21 @@ typedef enum
|
|||
SOUND_STREAM = BIT( 1 ), // this is a streaminfo, not a real sound
|
||||
|
||||
// Sound_Process manipulation flags
|
||||
SOUND_RESAMPLE = BIT( 12 ), // resample sound to specified rate
|
||||
SOUND_RESAMPLE = BIT(12), // resample sound to specified rate
|
||||
SOUND_CONVERT16BIT = BIT(13), // change sound resolution from 8 bit to 16
|
||||
} sndFlags_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word rate; // num samples per second (e.g. 11025 - 11 khz)
|
||||
byte width; // resolution - bum bits divided by 8 (8 bit is 1, 16 bit is 2)
|
||||
byte channels; // num channels (1 - mono, 2 - stereo)
|
||||
uint loopStart; // offset at this point sound will be looping while playing more than only once
|
||||
uint samples; // total samplecount in wav
|
||||
uint type; // compression type
|
||||
uint flags; // misc sound flags
|
||||
byte *buffer; // sound buffer
|
||||
size_t size; // for bounds checking
|
||||
word rate; // num samples per second (e.g. 11025 - 11 khz)
|
||||
byte width; // resolution - bum bits divided by 8 (8 bit is 1, 16 bit is 2)
|
||||
byte channels; // num channels (1 - mono, 2 - stereo)
|
||||
int loopStart; // offset at this point sound will be looping while playing more than only once
|
||||
int samples; // total samplecount in wav
|
||||
uint type; // compression type
|
||||
uint flags; // misc sound flags
|
||||
byte *buffer; // sound buffer
|
||||
size_t size; // for bounds checking
|
||||
} wavdata_t;
|
||||
|
||||
//
|
||||
|
@ -505,16 +541,20 @@ qboolean Host_IsQuakeCompatible( void );
|
|||
void EXPORT Host_Shutdown( void );
|
||||
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
|
||||
int Host_CompareFileTime( int ft1, int ft2 );
|
||||
void Host_NewInstance( const char *name, const char *finalmsg );
|
||||
void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
|
||||
void Host_AbortCurrentFrame( void ) NORETURN;
|
||||
void Host_WriteServerConfig( const char *name );
|
||||
void Host_WriteOpenGLConfig( void );
|
||||
void Host_WriteVideoConfig( void );
|
||||
void Host_WriteConfig( void );
|
||||
qboolean Host_IsLocalGame( void );
|
||||
qboolean Host_IsLocalClient( void );
|
||||
void Host_ShutdownServer( void );
|
||||
void Host_Error( const char *error, ... ) _format( 1 );
|
||||
void Host_ValidateEngineFeatures( uint32_t features );
|
||||
void Host_Frame( double time );
|
||||
void Host_PrintEngineFeatures( void );
|
||||
void Host_Frame( float time );
|
||||
void Host_InitDecals( void );
|
||||
void Host_Credits( void );
|
||||
|
||||
//
|
||||
|
@ -525,7 +565,7 @@ void COM_NewGame( char const *pMapName );
|
|||
void COM_LoadLevel( char const *pMapName, qboolean background );
|
||||
void COM_LoadGame( char const *pSaveFileName );
|
||||
void COM_ChangeLevel( char const *pNewLevel, char const *pLandmarkName, qboolean background );
|
||||
void COM_Frame( double time );
|
||||
void COM_Frame( float time );
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
@ -558,6 +598,7 @@ void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
|
|||
int COM_SaveFile( const char *filename, const void *data, int len );
|
||||
byte* COM_LoadFileForMe( const char *filename, int *pLength );
|
||||
qboolean COM_IsSafeFileToDownload( const char *filename );
|
||||
const char *COM_GetResourceTypeName( resourcetype_t restype );
|
||||
cvar_t *pfnCVarGetPointer( const char *szVarName );
|
||||
int pfnDrawConsoleString( int x, int y, char *string );
|
||||
void pfnDrawSetTextColor( float r, float g, float b );
|
||||
|
@ -565,6 +606,7 @@ void pfnDrawConsoleStringLen( const char *pText, int *length, int *height );
|
|||
void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c );
|
||||
void COM_TrimSpace( const char *source, char *dest );
|
||||
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
|
||||
void pfnCVarDirectSet( cvar_t *var, const char *szValue );
|
||||
int COM_CheckParm( char *parm, char **ppnext );
|
||||
void pfnGetGameDir( char *szGetGameDir );
|
||||
int pfnGetModelType( model_t *mod );
|
||||
|
@ -606,6 +648,7 @@ void pfnResetTutorMessageDecayData( void );
|
|||
//
|
||||
// con_utils.c
|
||||
//
|
||||
qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize );
|
||||
void Con_CompleteCommand( field_t *field );
|
||||
void Cmd_AutoComplete( char *complete_string );
|
||||
void Cmd_AutoCompleteClear( void );
|
||||
|
@ -661,15 +704,24 @@ void CL_LegacyUpdateInfo( void );
|
|||
void CL_CharEvent( int key );
|
||||
qboolean CL_DisableVisibility( void );
|
||||
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength );
|
||||
int CL_GetDemoComment( const char *demoname, char *comment );
|
||||
void COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName );
|
||||
int COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize );
|
||||
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
|
||||
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
|
||||
struct cmdalias_s *Cmd_AliasGetList( void );
|
||||
const char *Cmd_GetName( struct cmd_s *cmd );
|
||||
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
|
||||
void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale );
|
||||
void Log_Printf( const char *fmt, ... ) _format( 1 );
|
||||
void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
|
||||
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
|
||||
void SV_BroadcastPrintf( struct sv_client_s *ignore, const char *fmt, ... ) _format( 2 );
|
||||
int R_CreateDecalList( struct decallist_s *pList );
|
||||
void R_ClearAllDecals( void );
|
||||
void CL_ClearStaticEntities( void );
|
||||
qboolean S_StreamGetCurrentState( char *currentTrack, size_t currentTrackSize, char *loopTrack, size_t loopTrackSize, int *position );
|
||||
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
|
||||
struct cl_entity_s *CL_GetEntityByIndex( int index );
|
||||
void CL_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
|
||||
void CL_HudMessage( const char *pMessage );
|
||||
const char *CL_MsgInfo( int cmd );
|
||||
|
@ -678,14 +730,17 @@ void SV_DrawOrthoTriangles( void );
|
|||
double CL_GetDemoFramerate( void );
|
||||
qboolean UI_CreditsActive( void );
|
||||
void CL_StopPlayback( void );
|
||||
void CL_ExtraUpdate( void );
|
||||
int CL_GetMaxClients( void );
|
||||
int SV_GetMaxClients( void );
|
||||
qboolean CL_IsRecordDemo( void );
|
||||
qboolean CL_IsTimeDemo( void );
|
||||
qboolean CL_IsPlaybackDemo( void );
|
||||
qboolean SV_Initialized( void );
|
||||
qboolean CL_LoadProgs( const char *name );
|
||||
void CL_ProcessFile( qboolean successfully_received, const char *filename );
|
||||
int SV_GetSaveComment( const char *savename, char *comment );
|
||||
qboolean SV_NewGame( const char *mapName, qboolean loadGame );
|
||||
void SV_ClipPMoveToEntity( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr );
|
||||
void CL_ClipPMoveToEntity( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr );
|
||||
void SV_SysError( const char *error_string );
|
||||
|
@ -694,9 +749,11 @@ void SV_ExecLoadLevel( void );
|
|||
void SV_ExecLoadGame( void );
|
||||
void SV_ExecChangeLevel( void );
|
||||
void CL_WriteMessageHistory( void );
|
||||
void CL_SendCmd( void );
|
||||
void CL_Disconnect( void );
|
||||
void CL_ClearEdicts( void );
|
||||
void CL_Crashed( void );
|
||||
qboolean CL_NextDemo( void );
|
||||
char *SV_Serverinfo( void );
|
||||
void CL_Drop( void );
|
||||
void Con_Init( void );
|
||||
|
@ -721,6 +778,7 @@ qboolean Info_SetValueForStarKey( char *s, const char *key, const char *value, i
|
|||
qboolean Info_IsValid( const char *s );
|
||||
void Info_WriteVars( file_t *f );
|
||||
void Info_Print( const char *s );
|
||||
void Cmd_WriteVariables( file_t *f );
|
||||
int Cmd_CheckMapsList( int fRefresh );
|
||||
void COM_SetRandomSeed( int lSeed );
|
||||
int COM_RandomLong( int lMin, int lMax );
|
||||
|
@ -735,26 +793,13 @@ void VID_Init( void );
|
|||
void UI_SetActiveMenu( qboolean fActive );
|
||||
void UI_ShowConnectionWarning( void );
|
||||
void Cmd_Null_f( void );
|
||||
void Rcon_Print( host_redirect_t *rd, const char *pMsg );
|
||||
void Rcon_Print( const char *pMsg );
|
||||
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
|
||||
void COM_NormalizeAngles( vec3_t angles );
|
||||
int COM_FileSize( const char *filename );
|
||||
void COM_FreeFile( void *buffer );
|
||||
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
|
||||
char *va( const char *format, ... ) _format( 1 );
|
||||
qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer );
|
||||
|
||||
static inline qboolean Host_IsLocalGame( void )
|
||||
{
|
||||
if( SV_Active( ))
|
||||
return SV_GetMaxClients() == 1 ? true : false;
|
||||
return CL_GetMaxClients() == 1 ? true : false;
|
||||
}
|
||||
|
||||
static inline qboolean Host_IsLocalClient( void )
|
||||
{
|
||||
return CL_Initialized( ) && SV_Initialized( ) ? true : false;
|
||||
}
|
||||
|
||||
// soundlib shared exports
|
||||
qboolean S_Init( void );
|
||||
|
@ -765,14 +810,8 @@ void S_StopBackgroundTrack( void );
|
|||
void S_StopAllSounds( qboolean ambient );
|
||||
|
||||
// gamma routines
|
||||
void BuildGammaTable( float gamma, float brightness );
|
||||
byte LightToTexGamma( byte b );
|
||||
byte TextureToGamma( byte );
|
||||
uint LightToTexGammaEx( uint );
|
||||
uint ScreenGammaTable( uint );
|
||||
uint LinearGammaTable( uint );
|
||||
void V_Init( void );
|
||||
void V_CheckGamma( void );
|
||||
void V_CheckGammaEnd( void );
|
||||
|
||||
//
|
||||
// identification.c
|
||||
|
@ -793,34 +832,6 @@ void NET_MasterClear( void );
|
|||
void NET_MasterShutdown( void );
|
||||
qboolean NET_GetMaster( netadr_t from, uint *challenge, double *last_heartbeat );
|
||||
|
||||
//
|
||||
// sounds.c
|
||||
//
|
||||
typedef enum soundlst_group_e
|
||||
{
|
||||
BouncePlayerShell = 0,
|
||||
BounceWeaponShell,
|
||||
BounceConcrete,
|
||||
BounceGlass,
|
||||
BounceMetal,
|
||||
BounceFlesh,
|
||||
BounceWood,
|
||||
Ricochet,
|
||||
Explode,
|
||||
PlayerWaterEnter,
|
||||
PlayerWaterExit,
|
||||
EntityWaterEnter,
|
||||
EntityWaterExit,
|
||||
|
||||
SoundList_Groups // must be last
|
||||
} soundlst_group_t;
|
||||
|
||||
int SoundList_Count( soundlst_group_t group );
|
||||
const char *SoundList_GetRandom( soundlst_group_t group );
|
||||
const char *SoundList_Get( soundlst_group_t group, int idx );
|
||||
void SoundList_Init( void );
|
||||
void SoundList_Shutdown( void );
|
||||
|
||||
#ifdef REF_DLL
|
||||
#error "common.h in ref_dll"
|
||||
#endif
|
||||
|
|
|
@ -184,7 +184,7 @@ Cmd_GetMapList
|
|||
Prints or complete map filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -220,7 +220,7 @@ Cmd_GetDemoList
|
|||
Prints or complete demo filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -267,7 +267,7 @@ Cmd_GetMovieList
|
|||
Prints or complete movie filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -314,7 +314,7 @@ Cmd_GetMusicList
|
|||
Prints or complete background track filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetMusicList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -362,7 +362,7 @@ Cmd_GetSavesList
|
|||
Prints or complete savegame filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetSavesList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -409,7 +409,7 @@ Cmd_GetConfigList
|
|||
Prints or complete .cfg filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetConfigList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetConfigList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -456,7 +456,7 @@ Cmd_GetSoundList
|
|||
Prints or complete sound filename
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetSoundList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -465,7 +465,7 @@ static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length
|
|||
t = FS_Search( va( "%s%s*.*", DEFAULT_SOUNDPATH, s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
Q_strncpy( matchbuf, t->filenames[0] + sizeof( DEFAULT_SOUNDPATH ) - 1, sizeof( matchbuf ));
|
||||
Q_strncpy( matchbuf, t->filenames[0] + sizeof( DEFAULT_SOUNDPATH ) - 1, MAX_STRING );
|
||||
COM_StripExtension( matchbuf );
|
||||
if( completedname && length )
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
|
@ -478,7 +478,7 @@ static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length
|
|||
if( Q_stricmp( ext, "wav" ) && Q_stricmp( ext, "mp3" ))
|
||||
continue;
|
||||
|
||||
Q_strncpy( matchbuf, t->filenames[i] + sizeof( DEFAULT_SOUNDPATH ) - 1, sizeof( matchbuf ));
|
||||
Q_strncpy( matchbuf, t->filenames[i] + sizeof( DEFAULT_SOUNDPATH ) - 1, MAX_STRING );
|
||||
COM_StripExtension( matchbuf );
|
||||
Con_Printf( "%16s\n", matchbuf );
|
||||
numsounds++;
|
||||
|
@ -508,7 +508,7 @@ Cmd_GetItemsList
|
|||
Prints or complete item classname (weapons only)
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetItemsList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -555,7 +555,7 @@ Cmd_GetKeysList
|
|||
Autocomplete for bind command
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetKeysList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetKeysList( const char *s, char *completedname, int length )
|
||||
{
|
||||
size_t i, numkeys;
|
||||
string keys[256];
|
||||
|
@ -585,7 +585,7 @@ static qboolean Cmd_GetKeysList( const char *s, char *completedname, int length
|
|||
Con_Printf( "%16s\n", matchbuf );
|
||||
}
|
||||
|
||||
Con_Printf( "\n^3 %zu keys found.\n", numkeys );
|
||||
Con_Printf( "\n^3 %lu keys found.\n", numkeys );
|
||||
|
||||
if( completedname && length )
|
||||
{
|
||||
|
@ -636,7 +636,7 @@ Cmd_GetCommandsList
|
|||
Autocomplete for bind command
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetCommandsList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetCommandsList( const char *s, char *completedname, int length )
|
||||
{
|
||||
size_t i;
|
||||
string matchbuf;
|
||||
|
@ -701,7 +701,7 @@ Cmd_GetCustomList
|
|||
Prints or complete .HPK filenames
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetCustomList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetCustomList( const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
|
@ -747,13 +747,17 @@ Cmd_GetGameList
|
|||
Prints or complete gamedir name
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
|
||||
{
|
||||
int i, numgamedirs;
|
||||
string gamedirs[MAX_MODS];
|
||||
string matchbuf;
|
||||
int len;
|
||||
|
||||
// stand-alone games doesn't have cmd "game"
|
||||
if( !Cmd_Exists( "game" ))
|
||||
return false;
|
||||
|
||||
// compare gamelist with current keyword
|
||||
len = Q_strlen( s );
|
||||
|
||||
|
@ -764,14 +768,14 @@ static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length
|
|||
}
|
||||
|
||||
if( !numgamedirs ) return false;
|
||||
Q_strncpy( matchbuf, gamedirs[0], sizeof( matchbuf ));
|
||||
Q_strncpy( matchbuf, gamedirs[0], MAX_STRING );
|
||||
if( completedname && length )
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( numgamedirs == 1 ) return true;
|
||||
|
||||
for( i = 0; i < numgamedirs; i++ )
|
||||
{
|
||||
Q_strncpy( matchbuf, gamedirs[i], sizeof( matchbuf ));
|
||||
Q_strncpy( matchbuf, gamedirs[i], MAX_STRING );
|
||||
Con_Printf( "%16s\n", matchbuf );
|
||||
}
|
||||
|
||||
|
@ -796,7 +800,7 @@ Cmd_GetCDList
|
|||
Prints or complete CD command name
|
||||
=====================================
|
||||
*/
|
||||
static qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
|
||||
qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
|
||||
{
|
||||
int i, numcdcommands;
|
||||
string cdcommands[8];
|
||||
|
@ -825,14 +829,14 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
|
|||
}
|
||||
|
||||
if( !numcdcommands ) return false;
|
||||
Q_strncpy( matchbuf, cdcommands[0], sizeof( matchbuf ));
|
||||
Q_strncpy( matchbuf, cdcommands[0], MAX_STRING );
|
||||
if( completedname && length )
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( numcdcommands == 1 ) return true;
|
||||
|
||||
for( i = 0; i < numcdcommands; i++ )
|
||||
{
|
||||
Q_strncpy( matchbuf, cdcommands[i], sizeof( matchbuf ));
|
||||
Q_strncpy( matchbuf, cdcommands[i], MAX_STRING );
|
||||
Con_Printf( "%16s\n", matchbuf );
|
||||
}
|
||||
|
||||
|
@ -850,7 +854,7 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
|
|||
return true;
|
||||
}
|
||||
|
||||
static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
||||
qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
||||
{
|
||||
qboolean use_filter = false;
|
||||
byte buf[MAX_SYSPATH];
|
||||
|
@ -866,7 +870,7 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
|||
return true; // exist
|
||||
|
||||
// setup mpfilter
|
||||
Q_snprintf( mpfilter, sizeof( mpfilter ), "maps/%s", GI->mp_filter );
|
||||
size = Q_snprintf( mpfilter, sizeof( mpfilter ), "maps/%s", GI->mp_filter );
|
||||
t = FS_Search( "maps/*.bsp", false, onlyingamedir );
|
||||
|
||||
if( !t )
|
||||
|
@ -900,11 +904,13 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
|||
|
||||
if( f )
|
||||
{
|
||||
qboolean have_spawnpoints = false;
|
||||
dlump_t entities;
|
||||
int num_spawnpoints = 0;
|
||||
dheader_t *header;
|
||||
dlump_t entities;
|
||||
|
||||
memset( buf, 0, MAX_SYSPATH );
|
||||
FS_Read( f, buf, MAX_SYSPATH );
|
||||
header = (dheader_t *)buf;
|
||||
|
||||
// check all the lumps and some other errors
|
||||
if( !Mod_TestBmodelLumps( f, t->filenames[i], buf, true, &entities ))
|
||||
|
@ -935,24 +941,13 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
|||
char token[MAX_TOKEN];
|
||||
qboolean worldspawn = true;
|
||||
|
||||
Q_strncpy( message, "No Title", sizeof( message ));
|
||||
Q_strncpy( message, "No Title", MAX_STRING );
|
||||
pfile = ents;
|
||||
|
||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||||
{
|
||||
if( token[0] == '}' && worldspawn )
|
||||
{
|
||||
worldspawn = false;
|
||||
|
||||
// if mod has mp_filter set up, then it's a mod that
|
||||
// might not have valid mp_entity set in GI
|
||||
// if mod is multiplayer only, assume all maps are valid
|
||||
if( use_filter || GI->gamemode == GAME_MULTIPLAYER_ONLY )
|
||||
{
|
||||
have_spawnpoints = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( !Q_strcmp( token, "message" ) && worldspawn )
|
||||
{
|
||||
// get the message contents
|
||||
|
@ -961,23 +956,17 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
|||
else if( !Q_strcmp( token, "classname" ))
|
||||
{
|
||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||
|
||||
if( !Q_strcmp( token, GI->mp_entity ))
|
||||
{
|
||||
have_spawnpoints = true;
|
||||
break;
|
||||
}
|
||||
if( !Q_strcmp( token, GI->mp_entity ) || use_filter )
|
||||
num_spawnpoints++;
|
||||
}
|
||||
|
||||
if( have_spawnpoints )
|
||||
break; // valid map
|
||||
if( num_spawnpoints ) break; // valid map
|
||||
}
|
||||
Mem_Free( ents );
|
||||
}
|
||||
|
||||
if( f ) FS_Close( f );
|
||||
|
||||
if( have_spawnpoints )
|
||||
if( num_spawnpoints )
|
||||
{
|
||||
// format: mapname "maptitle"\n
|
||||
Q_snprintf( result, sizeof( result ), "%s \"%s\"\n", mapname, message );
|
||||
|
@ -1072,7 +1061,7 @@ Autocomplete filename
|
|||
for various cmds
|
||||
============
|
||||
*/
|
||||
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
|
||||
qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
|
||||
{
|
||||
autocomplete_list_t *list;
|
||||
|
||||
|
@ -1356,13 +1345,13 @@ static void Cmd_WriteHelp(const char *name, const char *unused, const char *desc
|
|||
if( length == 0 ) FS_Printf( f, "%s \"%s\"\n", name, desc );
|
||||
}
|
||||
|
||||
static void Cmd_WriteOpenGLVariables( file_t *f )
|
||||
void Cmd_WriteOpenGLVariables( file_t *f )
|
||||
{
|
||||
Cvar_LookupVars( FCVAR_GLCONFIG, NULL, f, (setpair_t)Cmd_WriteOpenGLCvar );
|
||||
}
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
static void Host_FinalizeConfig( file_t *f, const char *config )
|
||||
void Host_FinalizeConfig( file_t *f, const char *config )
|
||||
{
|
||||
string backup, newcfg;
|
||||
|
||||
|
@ -1395,7 +1384,7 @@ void Host_WriteConfig( void )
|
|||
f = FS_Open( "config.cfg.new", "w", false );
|
||||
if( f )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
Con_Reportf( "Host_WriteConfig()\n" );
|
||||
FS_Printf( f, "//=======================================================================\n");
|
||||
FS_Printf( f, "//\t\t\tCopyright XashXT Group & Flying With Gauss %s (C)\n", Q_timestamp( TIME_YEAR_ONLY ));
|
||||
FS_Printf( f, "//\t\t\tconfig.cfg - archive of cvars\n" );
|
||||
|
@ -1478,7 +1467,7 @@ void Host_WriteOpenGLConfig( void )
|
|||
f = FS_Open( va( "%s.new", name ), "w", false );
|
||||
if( f )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
Con_Reportf( "Host_WriteGLConfig()\n" );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "//\t\t\tCopyright XashXT Group & Flying With Gauss %s (C)\n", Q_timestamp( TIME_YEAR_ONLY ));
|
||||
FS_Printf( f, "//\t\t %s - archive of renderer implementation cvars\n", name );
|
||||
|
@ -1508,7 +1497,7 @@ void Host_WriteVideoConfig( void )
|
|||
f = FS_Open( "video.cfg.new", "w", false );
|
||||
if( f )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
Con_Reportf( "Host_WriteVideoConfig()\n" );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "//\t\t\tCopyright XashXT Group & Flying With Gauss %s (C)\n", Q_timestamp( TIME_YEAR_ONLY ));
|
||||
FS_Printf( f, "//\t\tvideo.cfg - archive of renderer variables\n");
|
||||
|
|
|
@ -129,22 +129,6 @@ static void Sys_StackTrace( PEXCEPTION_POINTERS pInfo )
|
|||
stackframe.AddrBStore.Mode = AddrModeFlat;
|
||||
stackframe.AddrStack.Offset = context.IntSp;
|
||||
stackframe.AddrStack.Mode = AddrModeFlat;
|
||||
#elif _M_ARM
|
||||
image = IMAGE_FILE_MACHINE_ARMNT;
|
||||
stackframe.AddrPC.Offset = context.Pc;
|
||||
stackframe.AddrPC.Mode = AddrModeFlat;
|
||||
stackframe.AddrFrame.Offset = context.R11;
|
||||
stackframe.AddrFrame.Mode = AddrModeFlat;
|
||||
stackframe.AddrStack.Offset = context.Sp;
|
||||
stackframe.AddrStack.Mode = AddrModeFlat;
|
||||
#elif _M_ARM64
|
||||
image = IMAGE_FILE_MACHINE_ARM64;
|
||||
stackframe.AddrPC.Offset = context.Pc;
|
||||
stackframe.AddrPC.Mode = AddrModeFlat;
|
||||
stackframe.AddrFrame.Offset = context.Fp;
|
||||
stackframe.AddrFrame.Mode = AddrModeFlat;
|
||||
stackframe.AddrStack.Offset = context.Sp;
|
||||
stackframe.AddrStack.Mode = AddrModeFlat;
|
||||
#elif
|
||||
#error
|
||||
#endif
|
||||
|
@ -325,6 +309,7 @@ void Sys_SetupCrashHandler( void )
|
|||
{
|
||||
SetErrorMode( SEM_FAILCRITICALERRORS ); // no abort/retry/fail errors
|
||||
oldFilter = SetUnhandledExceptionFilter( Sys_Crash );
|
||||
host.hInst = GetModuleHandle( NULL );
|
||||
}
|
||||
|
||||
void Sys_RestoreCrashHandler( void )
|
||||
|
@ -387,9 +372,9 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
|
|||
bp = (void**)ucontext->uc_mcontext.mc_rbp;
|
||||
sp = (void**)ucontext->uc_mcontext.mc_rsp;
|
||||
#elif XASH_NETBSD
|
||||
pc = (void*)ucontext->uc_mcontext.__gregs[_REG_RIP];
|
||||
bp = (void**)ucontext->uc_mcontext.__gregs[_REG_RBP];
|
||||
sp = (void**)ucontext->uc_mcontext.__gregs[_REG_RSP];
|
||||
pc = (void*)ucontext->uc_mcontext.__gregs[REG_RIP];
|
||||
bp = (void**)ucontext->uc_mcontext.__gregs[REG_RBP];
|
||||
sp = (void**)ucontext->uc_mcontext.__gregs[REG_RSP];
|
||||
#elif XASH_OPENBSD
|
||||
pc = (void*)ucontext->sc_rip;
|
||||
bp = (void**)ucontext->sc_rbp;
|
||||
|
@ -505,14 +490,13 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
|
|||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#endif
|
||||
host.crashed = true;
|
||||
Platform_MessageBox( "Xash Error", message, false );
|
||||
MSGBOX( message );
|
||||
|
||||
// log saved, now we can try to save configs and close log correctly, it may crash
|
||||
if( host.type == HOST_NORMAL )
|
||||
CL_Crashed();
|
||||
host.status = HOST_CRASHED;
|
||||
|
||||
host.crashed = true;
|
||||
|
||||
Sys_Quit();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ GNU General Public License for more details.
|
|||
#include "common.h"
|
||||
#include "custom.h"
|
||||
#include "ref_common.h"
|
||||
#include "hpak.h" // be aware of HPK limits
|
||||
|
||||
static rgbdata_t *CustomDecal_LoadImage( const char *path, void *raw, int size )
|
||||
{
|
||||
|
@ -94,7 +93,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
|
|||
|
||||
if( FBitSet( flags, FCUST_FROMHPAK ))
|
||||
{
|
||||
if( !HPAK_GetDataPointer( hpk_custom_file.string, pResource, (byte **)&pCust->pBuffer, NULL ))
|
||||
if( !HPAK_GetDataPointer( CUSTOM_RES_PATH, pResource, (byte **)&pCust->pBuffer, NULL ))
|
||||
bError = true;
|
||||
}
|
||||
else
|
||||
|
@ -116,11 +115,11 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
|
|||
{
|
||||
if( !FBitSet( flags, FCUST_IGNOREINIT ))
|
||||
{
|
||||
if( pResource->nDownloadSize >= HPAK_ENTRY_MIN_SIZE && pResource->nDownloadSize <= HPAK_ENTRY_MAX_SIZE )
|
||||
if( pResource->nDownloadSize >= (1 * 1024) && pResource->nDownloadSize <= ( 128 * 1024 ))
|
||||
{
|
||||
pCust->bTranslated = true;
|
||||
pCust->nUserData1 = 0;
|
||||
pCust->nUserData2 = 7;
|
||||
pCust->nUserData2 = 1;
|
||||
|
||||
if( !FBitSet( flags, FCUST_WIPEDATA ))
|
||||
pCust->pInfo = CustomDecal_LoadImage( pResource->szFileName, pCust->pBuffer, pCust->resource.nDownloadSize );
|
||||
|
|
|
@ -152,10 +152,8 @@ static qboolean Cvar_UpdateInfo( convar_t *var, const char *value, qboolean noti
|
|||
if ( Host_IsDedicated() )
|
||||
{
|
||||
// g-cont. this is a very strange behavior...
|
||||
char *info = SV_Serverinfo();
|
||||
|
||||
Info_SetValueForKey( info, var->name, value, MAX_SERVERINFO_STRING ),
|
||||
SV_BroadcastCommand( "fullserverinfo \"%s\"\n", info );
|
||||
Info_SetValueForKey( SV_Serverinfo(), var->name, value, MAX_SERVERINFO_STRING ),
|
||||
SV_BroadcastCommand( "fullserverinfo \"%s\"\n", SV_Serverinfo( ));
|
||||
}
|
||||
#if !XASH_DEDICATED
|
||||
else
|
||||
|
@ -197,7 +195,7 @@ Cvar_ValidateString
|
|||
deal with userinfo etc
|
||||
============
|
||||
*/
|
||||
static const char *Cvar_ValidateString( convar_t *var, const char *value )
|
||||
const char *Cvar_ValidateString( convar_t *var, const char *value )
|
||||
{
|
||||
const char *pszValue;
|
||||
static char szNew[MAX_STRING];
|
||||
|
@ -280,7 +278,7 @@ Cvar_UnlinkVar
|
|||
unlink the variable
|
||||
============
|
||||
*/
|
||||
static int Cvar_UnlinkVar( const char *var_name, int group )
|
||||
int Cvar_UnlinkVar( const char *var_name, int group )
|
||||
{
|
||||
int count = 0;
|
||||
convar_t **prev;
|
||||
|
@ -565,27 +563,6 @@ void Cvar_RegisterVariable( convar_t *var )
|
|||
#endif
|
||||
}
|
||||
|
||||
static qboolean Cvar_CanSet( const convar_t *cv )
|
||||
{
|
||||
if( FBitSet( cv->flags, FCVAR_READ_ONLY ))
|
||||
{
|
||||
Con_Printf( "%s is read-only.\n", cv->name );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( FBitSet( cv->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
||||
{
|
||||
Con_Printf( "%s is cheat protected.\n", cv->name );
|
||||
return false;
|
||||
}
|
||||
|
||||
// just tell user about deferred changes
|
||||
if( FBitSet( cv->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
||||
Con_Printf( "%s will be changed upon restarting.\n", cv->name );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Set2
|
||||
|
@ -655,9 +632,22 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
|||
force = true;
|
||||
|
||||
if( !force )
|
||||
{
|
||||
if( !Cvar_CanSet( var ))
|
||||
{
|
||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
||||
{
|
||||
Con_Printf( "%s is read-only.\n", var->name );
|
||||
return var;
|
||||
}
|
||||
|
||||
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
||||
{
|
||||
Con_Printf( "%s is cheat protected.\n", var->name );
|
||||
return var;
|
||||
}
|
||||
|
||||
// just tell user about deferred changes
|
||||
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
||||
Con_Printf( "%s will be changed upon restarting.\n", var->name );
|
||||
}
|
||||
|
||||
pszValue = Cvar_ValidateString( var, value );
|
||||
|
@ -687,7 +677,7 @@ Cvar_DirectSet
|
|||
way to change value for many cvars
|
||||
============
|
||||
*/
|
||||
void GAME_EXPORT Cvar_DirectSet( convar_t *var, const char *value )
|
||||
void Cvar_DirectSet( convar_t *var, const char *value )
|
||||
{
|
||||
const char *pszValue;
|
||||
|
||||
|
@ -704,8 +694,21 @@ void GAME_EXPORT Cvar_DirectSet( convar_t *var, const char *value )
|
|||
return; // how this possible?
|
||||
}
|
||||
|
||||
if( !Cvar_CanSet( var ))
|
||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
||||
{
|
||||
Con_Printf( "%s is read-only.\n", var->name );
|
||||
return;
|
||||
}
|
||||
|
||||
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
||||
{
|
||||
Con_Printf( "%s is cheat protected.\n", var->name );
|
||||
return;
|
||||
}
|
||||
|
||||
// just tell user about deferred changes
|
||||
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
||||
Con_Printf( "%s will be changed upon restarting.\n", var->name );
|
||||
|
||||
// check value
|
||||
if( !value )
|
||||
|
@ -738,24 +741,6 @@ void GAME_EXPORT Cvar_DirectSet( convar_t *var, const char *value )
|
|||
Cvar_Changed( var );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_DirectSetValue
|
||||
|
||||
functionally is the same as Cvar_SetValue but for direct cvar access
|
||||
============
|
||||
*/
|
||||
void Cvar_DirectSetValue( convar_t *var, float value )
|
||||
{
|
||||
char val[32];
|
||||
|
||||
if( fabs( value - (int)value ) < 0.000001 )
|
||||
Q_snprintf( val, sizeof( val ), "%d", (int)value );
|
||||
else Q_snprintf( val, sizeof( val ), "%f", value );
|
||||
|
||||
Cvar_DirectSet( var, val );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_FullSet
|
||||
|
@ -794,7 +779,7 @@ void GAME_EXPORT Cvar_Set( const char *var_name, const char *value )
|
|||
if( !var_name )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf( "%s: passed NULL variable name\n", __func__ );
|
||||
Con_Printf( "Cvar_Set: passed NULL variable name\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -803,7 +788,7 @@ void GAME_EXPORT Cvar_Set( const char *var_name, const char *value )
|
|||
if( !var )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf( "%s: variable '%s' not found\n", __func__, var_name );
|
||||
Con_Printf( "Cvar_Set: variable '%s' not found\n", var_name );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -848,7 +833,7 @@ float GAME_EXPORT Cvar_VariableValue( const char *var_name )
|
|||
if( !var_name )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf( "%s: passed NULL variable name\n", __func__ );
|
||||
Con_Printf( "Cvar_VariableValue: passed NULL variable name\n" );
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -885,7 +870,7 @@ const char *Cvar_VariableString( const char *var_name )
|
|||
if( !var_name )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf( "%s: passed NULL variable name\n", __func__ );
|
||||
Con_Printf( "Cvar_VariableString: passed NULL variable name\n" );
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -955,7 +940,7 @@ static void Cvar_SetGL( const char *name, const char *value )
|
|||
|
||||
static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
|
||||
{
|
||||
const char *prefixes[] = { "cl_", "gl_", "m_", "r_", "hud_", "joy_", "con_", "scr_" };
|
||||
const char *prefixes[] = { "cl_", "gl_", "m_", "r_", "hud_" };
|
||||
int i;
|
||||
|
||||
if( isPrivileged )
|
||||
|
@ -1093,7 +1078,7 @@ Cvar_Toggle_f
|
|||
Toggles a cvar for easy single key binding
|
||||
============
|
||||
*/
|
||||
static void Cvar_Toggle_f( void )
|
||||
void Cvar_Toggle_f( void )
|
||||
{
|
||||
int v;
|
||||
|
||||
|
@ -1116,7 +1101,7 @@ Allows setting and defining of arbitrary cvars from console, even if they
|
|||
weren't declared in C code.
|
||||
============
|
||||
*/
|
||||
static void Cvar_Set_f( void )
|
||||
void Cvar_Set_f( void )
|
||||
{
|
||||
int i, c, l = 0, len;
|
||||
char combined[MAX_CMD_TOKENS];
|
||||
|
@ -1149,8 +1134,10 @@ Cvar_SetGL_f
|
|||
As Cvar_Set, but also flags it as glconfig
|
||||
============
|
||||
*/
|
||||
static void Cvar_SetGL_f( void )
|
||||
void Cvar_SetGL_f( void )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( Cmd_Argc() != 3 )
|
||||
{
|
||||
Con_Printf( S_USAGE "setgl <variable> <value>\n" );
|
||||
|
@ -1165,7 +1152,7 @@ static void Cvar_SetGL_f( void )
|
|||
Cvar_Reset_f
|
||||
============
|
||||
*/
|
||||
static void Cvar_Reset_f( void )
|
||||
void Cvar_Reset_f( void )
|
||||
{
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
|
@ -1181,7 +1168,7 @@ static void Cvar_Reset_f( void )
|
|||
Cvar_List_f
|
||||
============
|
||||
*/
|
||||
static void Cvar_List_f( void )
|
||||
void Cvar_List_f( void )
|
||||
{
|
||||
convar_t *var;
|
||||
const char *match = NULL;
|
||||
|
|
|
@ -66,7 +66,6 @@ convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, c
|
|||
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
|
||||
void Cvar_FullSet( const char *var_name, const char *value, int flags );
|
||||
void Cvar_DirectSet( convar_t *var, const char *value );
|
||||
void Cvar_DirectSetValue( convar_t *var, float value );
|
||||
void Cvar_Set( const char *var_name, const char *value );
|
||||
void Cvar_SetValue( const char *var_name, float value );
|
||||
const char *Cvar_BuildAutoDescription( const char *szName, int flags );
|
||||
|
|
|
@ -134,6 +134,15 @@ void Con_Init( void )
|
|||
|
||||
}
|
||||
|
||||
void R_ClearAllDecals( void )
|
||||
{
|
||||
|
||||
}
|
||||
int R_CreateDecalList( struct decallist_s *pList )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GAME_EXPORT S_StopSound(int entnum, int channel, const char *soundname)
|
||||
{
|
||||
|
||||
|
@ -238,14 +247,4 @@ void CL_HudMessage( const char *pMessage )
|
|||
|
||||
}
|
||||
|
||||
byte TextureToGamma( byte b )
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
byte LightToTexGamma( byte b )
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
#endif // XASH_DEDICATED
|
||||
|
|
|
@ -16,7 +16,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "common.h"
|
||||
#include "library.h"
|
||||
#include "platform/platform.h"
|
||||
|
@ -27,15 +26,6 @@ fs_globals_t *FI;
|
|||
static pfnCreateInterface_t fs_pfnCreateInterface;
|
||||
static HINSTANCE fs_hInstance;
|
||||
|
||||
static void COM_StripDirectorySlash( char *pname )
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = Q_strlen( pname );
|
||||
if( len > 0 && pname[len - 1] == '/' )
|
||||
pname[len - 1] = 0;
|
||||
}
|
||||
|
||||
void *FS_GetNativeObject( const char *obj )
|
||||
{
|
||||
if( fs_pfnCreateInterface )
|
||||
|
@ -90,7 +80,7 @@ static void FS_UnloadProgs( void )
|
|||
#define FILESYSTEM_STDIO_DLL "filesystem_stdio." OS_LIB_EXT
|
||||
#endif
|
||||
|
||||
static qboolean FS_LoadProgs( void )
|
||||
qboolean FS_LoadProgs( void )
|
||||
{
|
||||
const char *name = FILESYSTEM_STDIO_DLL;
|
||||
FSAPI GetFSAPI;
|
||||
|
@ -99,150 +89,63 @@ static qboolean FS_LoadProgs( void )
|
|||
|
||||
if( !fs_hInstance )
|
||||
{
|
||||
Sys_Error( "%s: can't load filesystem library %s: %s\n", __func__, name, COM_GetLibraryError() );
|
||||
Host_Error( "FS_LoadProgs: can't load filesystem library %s: %s\n", name, COM_GetLibraryError() );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !( GetFSAPI = (FSAPI)COM_GetProcAddress( fs_hInstance, GET_FS_API )))
|
||||
{
|
||||
FS_UnloadProgs();
|
||||
Sys_Error( "%s: can't find GetFSAPI entry point in %s\n", __func__, name );
|
||||
Host_Error( "FS_LoadProgs: can't find GetFSAPI entry point in %s\n", name );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( GetFSAPI( FS_API_VERSION, &g_fsapi, &FI, &fs_memfuncs ) != FS_API_VERSION )
|
||||
if( !GetFSAPI( FS_API_VERSION, &g_fsapi, &FI, &fs_memfuncs ))
|
||||
{
|
||||
FS_UnloadProgs();
|
||||
Sys_Error( "%s: can't initialize filesystem API: wrong version\n", __func__ );
|
||||
Host_Error( "FS_LoadProgs: can't initialize filesystem API: wrong version\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !( fs_pfnCreateInterface = (pfnCreateInterface_t)COM_GetProcAddress( fs_hInstance, "CreateInterface" )))
|
||||
{
|
||||
FS_UnloadProgs();
|
||||
Sys_Error( "%s: can't find CreateInterface entry point in %s\n", __func__, name );
|
||||
Host_Error( "FS_LoadProgs: can't find CreateInterface entry point in %s\n", name );
|
||||
return false;
|
||||
}
|
||||
|
||||
Con_DPrintf( "%s: filesystem_stdio successfully loaded\n", __func__ );
|
||||
Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static qboolean FS_DetermineRootDirectory( char *out, size_t size )
|
||||
{
|
||||
const char *path = getenv( "XASH3D_BASEDIR" );
|
||||
|
||||
if( COM_CheckString( path ))
|
||||
{
|
||||
Q_strncpy( out, path, size );
|
||||
return true;
|
||||
}
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
Q_strncpy( out, IOS_GetDocsDir(), size );
|
||||
return true;
|
||||
#elif XASH_ANDROID && XASH_SDL
|
||||
path = SDL_AndroidGetExternalStoragePath();
|
||||
if( path != NULL )
|
||||
{
|
||||
Q_strncpy( out, path, size );
|
||||
return true;
|
||||
}
|
||||
Sys_Error( "couldn't determine Android external storage path: %s", SDL_GetError( ));
|
||||
return false;
|
||||
#elif XASH_PSVITA
|
||||
if( PSVita_GetBasePath( out, size ))
|
||||
return true;
|
||||
Sys_Error( "couldn't find Xash3D data directory" );
|
||||
return false;
|
||||
#elif ( XASH_SDL == 2 ) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2
|
||||
path = SDL_GetBasePath();
|
||||
if( path != NULL )
|
||||
{
|
||||
Q_strncpy( out, path, size );
|
||||
SDL_free(( void *)path );
|
||||
return true;
|
||||
}
|
||||
|
||||
#if XASH_POSIX || XASH_WIN32
|
||||
if( getcwd( out, size ))
|
||||
return true;
|
||||
Sys_Error( "couldn't determine current directory: %s, getcwd: %s", SDL_GetError(), strerror( errno ));
|
||||
#else // !( XASH_POSIX || XASH_WIN32 )
|
||||
Sys_Error( "couldn't determine current directory: %s", SDL_GetError( ));
|
||||
#endif // !( XASH_POSIX || XASH_WIN32 )
|
||||
return false;
|
||||
#else // generic case
|
||||
if( getcwd( out, size ))
|
||||
return true;
|
||||
|
||||
Sys_Error( "couldn't determine current directory: %s", strerror( errno ));
|
||||
return false;
|
||||
#endif // generic case
|
||||
}
|
||||
|
||||
static qboolean FS_DetermineReadOnlyRootDirectory( char *out, size_t size )
|
||||
{
|
||||
const char *env_rodir = getenv( "XASH3D_RODIR" );
|
||||
|
||||
if( _Sys_GetParmFromCmdLine( "-rodir", out, size ))
|
||||
return true;
|
||||
|
||||
if( COM_CheckString( env_rodir ))
|
||||
{
|
||||
Q_strncpy( out, env_rodir, size );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
FS_Init
|
||||
================
|
||||
*/
|
||||
void FS_Init( const char *basedir )
|
||||
void FS_Init( void )
|
||||
{
|
||||
string gamedir;
|
||||
char rodir[MAX_OSPATH], rootdir[MAX_OSPATH];
|
||||
rodir[0] = rootdir[0] = 0;
|
||||
|
||||
if( !FS_DetermineRootDirectory( rootdir, sizeof( rootdir )) || !COM_CheckStringEmpty( rootdir ))
|
||||
{
|
||||
Sys_Error( "couldn't determine current directory (empty string)" );
|
||||
return;
|
||||
}
|
||||
COM_FixSlashes( rootdir );
|
||||
COM_StripDirectorySlash( rootdir );
|
||||
|
||||
FS_DetermineReadOnlyRootDirectory( rodir, sizeof( rodir ));
|
||||
COM_FixSlashes( rodir );
|
||||
COM_StripDirectorySlash( rodir );
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-game", gamedir ))
|
||||
Q_strncpy( gamedir, basedir, sizeof( gamedir )); // gamedir == basedir
|
||||
|
||||
FS_LoadProgs();
|
||||
if( !g_fsapi.InitStdio( true, rootdir, basedir, gamedir, rodir ))
|
||||
{
|
||||
Sys_Error( "Can't init filesystem_stdio!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: this function will cause engine to stop in case of fail
|
||||
// when it will have an option to return string error, restore Sys_Error
|
||||
g_fsapi.SetCurrentDirectory( rootdir );
|
||||
|
||||
Cmd_AddRestrictedCommand( "fs_rescan", FS_Rescan_f, "rescan filesystem search pathes" );
|
||||
Cmd_AddRestrictedCommand( "fs_path", FS_Path_f_, "show filesystem search pathes" );
|
||||
Cmd_AddRestrictedCommand( "fs_clearpaths", FS_ClearPaths_f, "clear filesystem search pathes" );
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-dll", host.gamedll ))
|
||||
host.gamedll[0] = 0;
|
||||
if( !Sys_GetParmFromCmdLine( "-game", gamedir ))
|
||||
Q_strncpy( gamedir, SI.basedirName, sizeof( gamedir )); // gamedir == basedir
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-clientlib", host.clientlib ))
|
||||
host.clientlib[0] = 0;
|
||||
if( !FS_InitStdio( true, host.rootdir, SI.basedirName, gamedir, host.rodir ))
|
||||
{
|
||||
Host_Error( "Can't init filesystem_stdio!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-dll", SI.gamedll ))
|
||||
SI.gamedll[0] = 0;
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-clientlib", SI.clientlib ))
|
||||
SI.clientlib[0] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -255,5 +158,11 @@ void FS_Shutdown( void )
|
|||
if( g_fsapi.ShutdownStdio )
|
||||
g_fsapi.ShutdownStdio();
|
||||
|
||||
memset( &SI, 0, sizeof( sysinfo_t ));
|
||||
|
||||
FS_UnloadProgs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
gamma.c - gamma routines
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "enginefeatures.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gamma conversion support
|
||||
//-----------------------------------------------------------------------------
|
||||
static byte lightgammatable[256];
|
||||
static int lineargammatable[1024];
|
||||
static int screengammatable[1024];
|
||||
|
||||
void BuildGammaTable( float lightgamma, float brightness )
|
||||
{
|
||||
int i, inf;
|
||||
float f, g, g1, g3;
|
||||
|
||||
lightgamma = bound( 1.8f, lightgamma, 3.0f );
|
||||
brightness = bound( 0.0f, brightness, 10.0f );
|
||||
|
||||
if( brightness <= 0.0f )
|
||||
g3 = 0.125f;
|
||||
else if( brightness > 1.0f )
|
||||
g3 = 0.05f;
|
||||
else g3 = 0.125f - (brightness * brightness) * 0.075f;
|
||||
|
||||
g = 1.0f / lightgamma;
|
||||
g1 = GAMMA * g;
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
f = pow( i / 255.f, GAMMA );
|
||||
|
||||
// scale up
|
||||
if( brightness > 1.0f )
|
||||
f = f * brightness;
|
||||
|
||||
// shift up
|
||||
if( f <= g3 ) f = (f / g3) * 0.125f;
|
||||
else f = 0.125f + ((f - g3) / (1.0f - g3)) * 0.875f;
|
||||
|
||||
// convert linear space to desired gamma space
|
||||
inf = (int)( 255.0f * pow( f, g ));
|
||||
|
||||
lightgammatable[i] = bound( 0, inf, 255 );
|
||||
}
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
{
|
||||
// convert from screen gamma space to linear space
|
||||
lineargammatable[i] = 1023 * pow( i / 1023.0f, g1 );
|
||||
|
||||
// convert from linear gamma space to screen space
|
||||
screengammatable[i] = 1023 * pow( i / 1023.0f, 1.0f / g1 );
|
||||
}
|
||||
}
|
||||
|
||||
byte LightToTexGamma( byte b )
|
||||
{
|
||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||
return b;
|
||||
else
|
||||
return lightgammatable[b];
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -16,8 +16,6 @@ GNU General Public License for more details.
|
|||
#include "common.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
static jmp_buf g_abortframe;
|
||||
|
||||
void COM_InitHostState( void )
|
||||
{
|
||||
memset( GameState, 0, sizeof( game_status_t ));
|
||||
|
@ -59,8 +57,6 @@ void COM_NewGame( char const *pMapName )
|
|||
GameState->landmarkName[0] = 0;
|
||||
GameState->loadGame = false;
|
||||
GameState->newGame = true;
|
||||
|
||||
SV_ShutdownGame(); // exit from current game
|
||||
}
|
||||
|
||||
void COM_LoadLevel( char const *pMapName, qboolean background )
|
||||
|
@ -78,8 +74,6 @@ void COM_LoadLevel( char const *pMapName, qboolean background )
|
|||
GameState->landmarkName[0] = 0;
|
||||
GameState->loadGame = false;
|
||||
GameState->newGame = false;
|
||||
|
||||
SV_ShutdownGame(); // exit from current game
|
||||
}
|
||||
|
||||
void COM_LoadGame( char const *pMapName )
|
||||
|
@ -123,7 +117,7 @@ void COM_ChangeLevel( char const *pNewLevel, char const *pLandmarkName, qboolean
|
|||
GameState->newGame = false;
|
||||
}
|
||||
|
||||
static void Host_ShutdownGame( void )
|
||||
void Host_ShutdownGame( void )
|
||||
{
|
||||
SV_ShutdownGame();
|
||||
|
||||
|
@ -139,7 +133,7 @@ static void Host_ShutdownGame( void )
|
|||
}
|
||||
}
|
||||
|
||||
static void Host_RunFrame( double time )
|
||||
void Host_RunFrame( float time )
|
||||
{
|
||||
// at this time, we don't need to get events from OS on dedicated
|
||||
#if !XASH_DEDICATED
|
||||
|
@ -170,23 +164,11 @@ static void Host_RunFrame( double time )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Host_AbortCurrentFrame
|
||||
|
||||
aborts the current host frame and goes on with the next one
|
||||
================
|
||||
*/
|
||||
void Host_AbortCurrentFrame( void )
|
||||
{
|
||||
longjmp( g_abortframe, 1 );
|
||||
}
|
||||
|
||||
void COM_Frame( double time )
|
||||
void COM_Frame( float time )
|
||||
{
|
||||
int loopCount = 0;
|
||||
|
||||
if( setjmp( g_abortframe ))
|
||||
if( setjmp( host.abortframe ))
|
||||
return;
|
||||
|
||||
while( 1 )
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue