Compare commits

..

6 Commits

315 changed files with 14100 additions and 17117 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,23 +1,22 @@
task: task:
# Seems packages for it were removed from the mirrors name: freebsd-12-amd64
# name: freebsd-12-amd64 freebsd_instance:
# freebsd_instance: image_family: freebsd-12-3
# image_family: freebsd-12-4 setup_script:
# setup_script: - pkg update
# - pkg update - pkg install -y git sdl2 python fontconfig
# - pkg install -y pkgconf git sdl2 python fontconfig opus - git submodule update --init --recursive
# - git submodule update --init --recursive test_script:
# test_script: - ./scripts/cirrus/build_freebsd.sh dedicated
# - ./scripts/cirrus/build_freebsd.sh dedicated - ./scripts/cirrus/build_freebsd.sh full
# - ./scripts/cirrus/build_freebsd.sh full
task: task:
name: freebsd-13-amd64 name: freebsd-13-amd64
freebsd_instance: freebsd_instance:
image_family: freebsd-13-2 image_family: freebsd-13-1
setup_script: setup_script:
- pkg update - pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus - pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive - git submodule update --init --recursive
test_script: test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated - ./scripts/cirrus/build_freebsd.sh dedicated
@@ -29,19 +28,7 @@ task:
image_family: freebsd-14-0-snap image_family: freebsd-14-0-snap
setup_script: setup_script:
- pkg update - pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus - pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-15-amd64
freebsd_instance:
image_family: freebsd-15-0-snap
setup_script:
- pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus
- git submodule update --init --recursive - git submodule update --init --recursive
test_script: test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated - ./scripts/cirrus/build_freebsd.sh dedicated

View File

@@ -13,8 +13,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
# Linux build specifically want oldest Ubuntu as possible
# to be crossdistribution compatible, otherwise use ubuntu-latest
- os: ubuntu-20.04 - os: ubuntu-20.04
targetos: linux targetos: linux
targetarch: amd64 targetarch: amd64
@@ -36,20 +34,20 @@ jobs:
# targetos: motomagx # targetos: motomagx
# targetarch: armv6 # targetarch: armv6
- os: ubuntu-latest - os: ubuntu-20.04
targetos: nswitch targetos: nswitch
targetarch: arm64 targetarch: arm64
- os: ubuntu-latest - os: ubuntu-20.04
targetos: psvita targetos: psvita
targetarch: armv7hf targetarch: armv7hf
- os: windows-latest - os: windows-latest
targetos: win32 targetos: win32
targetarch: amd64 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 targetos: win32
targetarch: i386 targetarch: i386
env: env:
SDL_VERSION: 2.28.5 SDL_VERSION: 2.26.2
GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CPU_ARCH: ${{ matrix.targetarch }}
ANDROID_SDK_TOOLS_VER: 4333796 ANDROID_SDK_TOOLS_VER: 4333796
steps: steps:
@@ -82,7 +80,7 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: Build flatpak (Compat.i386) - name: Build flatpak (Compat.i386)
uses: FWGS/flatpak-github-actions/flatpak-builder@v6.1 uses: FWGS/flatpak-github-actions/flatpak-builder@v5
with: with:
bundle: ${{ matrix.app }}.flatpak bundle: ${{ matrix.app }}.flatpak
manifest-path: scripts/flatpak/${{ matrix.app }}.yml manifest-path: scripts/flatpak/${{ matrix.app }}.yml

4
.gitignore vendored
View File

@@ -60,7 +60,6 @@ Makefile.dep
ALL_BUILD.* ALL_BUILD.*
INSTALL.* INSTALL.*
ZERO_CHECK.* ZERO_CHECK.*
CMakeLists.txt
# Visual Studio # Visual Studio
*.obj *.obj
@@ -334,6 +333,3 @@ __pycache__
.history/* .history/*
.cache/* .cache/*
enc_temp_folder/ enc_temp_folder/
# KDevelop4
*.kdev4

View File

@@ -18,7 +18,7 @@ def build(bld):
target = 'gl4es', target = 'gl4es',
features = 'c', features = 'c',
includes = ['gl4es/src', 'gl4es/src/gl', 'gl4es/src/glx', 'gl4es/include'], 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'], cflags = ['-w', '-fvisibility=hidden', '-std=gnu99'],
subsystem = bld.env.MSVC_SUBSYSTEM, subsystem = bld.env.MSVC_SUBSYSTEM,
export_includes = '.') export_includes = '.')

View File

@@ -1,24 +0,0 @@
# Developers donation page
On this page you can find links where you can support each developer individually, who has provided public sponsorship information.
### [a1batross](https://github.com/a1batross)
* Initial Xash3D SDL2/Linux port author, Xash3D FWGS engine maintainer, creator of non-commercial Flying With Gauss organization.
* Boosty page: https://boosty.to/a1ba
### [nekonomicon](https://github.com/nekonomicon)
* [hlsdk-portable](https://github.com/FWGS/hlsdk-portable), [mdldec](../utils/mdldec), [opensource-mods.md](opensource-mods.md) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=nekonomicon) (*BSD/clang port, PNG support, etc).
* Boosty page: https://boosty.to/nekonomicon
### [Velaron](https://github.com/Velaron)
* [cs16-client](https://github.com/Velaron/cs16-client) & [tf15-client](https://github.com/Velaron/tf15-client) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=Velaron) (Android port, voice chat, etc).
* BuyMeACoffee page: https://www.buymeacoffee.com/velaron
### [SNMetamorph](https://github.com/SNMetamorph)
* [PrimeXT](https://github.com/SNMetamorph/PrimeXT) & [GoldSrc Monitor](https://github.com/SNMetamorph/goldsrc-monitor) maintainer and Xash3D FWGS [contributor](https://github.com/FWGS/xash3d-fwgs/commits?author=SNMetamorph) (Windows port, voice chat, etc).
* BTC: `16GAzK3qei5AwBW7sggXp3yNcFHBtdpxXj`
* ETH (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
* USDT (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`
* USDC (ERC20): `0xb580eeca9756e3881f9d6d026e28db28eb72a383`

View File

@@ -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"
}
```

View File

@@ -1,116 +0,0 @@
# Game definition and information file
gameinfo.txt is an essential part of any Xash3D based game. It allows basic customization for games creators, like setting game title, DLL paths, etc.
This document defines gameinfo.txt syntax, supported keys and liblist.gam conversion rules for the latest version of the engine. Note for engine developers, keep this document in sync with an implementation.
## gameinfo.txt syntax
* gameinfo.txt is a simple list of keys and values, separated by newline.
* You can add single line comments using double slashes (//).
* Keys can accept integer, float, string or boolean values.
* Boolean keys use 0 as false and 1 as true value.
* To have spaces in string values, you must enclose them in double quotes. Then, to have double quotes, you must escape it with backslash, and to have a backslash you need to use double backslashes.
The example:
```
// this is a comment :)
// this is another comment
some_integer_key 123
this_is_float_key 13.37 // optional comment
enable_feature 1 // boolean, 1 to enable, 0 to disable
example_string_key string_value
example_spaces "string with spaces"
example_title "Fate\\Stay Night" // engine will parse it as Fate\Stay Night
```
## gameinfo.txt keys
This is a list of all gameinfo.txt keys supported by the engine. Be aware that the engine will silently skip all unrecognized keys.
| Key | Type | Default value | Description |
| ---------------- | ---------- | --------------- | ----------- |
| `ambient0` | string | Empty string | Automatic ambient sound |
| `ambient1` | string | Empty string | Automatic ambient sound |
| `ambient2` | string | Empty string | Automatic ambient sound |
| `ambient3` | string | Empty string | Automatic ambient sound |
| `basedir` | string | `valve` | Game base directory, used to share assets between games |
| `date` | string | Empty string | Game release date. Unused. |
| `dllpath` | string | `cl_dlls` | Game DLL path. Engine will search custom DLLs (client or menu, for example) in this directory, except `gamedll`, see below. |
| `fallback_dir` | string | Empty string | Additional game base directory |
| `gamedir` | string | Current gamedir | Game directory, ignored in FWGS, as game directory is defined by the game directory name |
| `gamedll` | string | `dlls/hl.dll` | Game server DLL for 32-bit x86 Windows (see LibraryNaming.md for details) |
| `gamemode` | string | Empty string | Game type. When set to `singleplayer_only` or `multiplayer_only` marks the game as SP or MP only respectively, hiding the option in game UI. Omitting this key or using custom values mark the game as both MP and SP compatible. |
| `icon` | string | `game.ico` | Game icon. Engine will automatically append .ico and may automatically switch to .tga icon as well |
| `max_beams` | integer | 128 | Beams limit, 64 min, 512 max |
| `max_edicts` | integer | 900 | Entities limit, 600 min, 8192 max (protocol limit). In FWGS, minimum is 64. |
| `max_particles` | integer | 4096 | Particles limit, 1024 min, 131072 max |
| `max_tempents` | integer | 500 | Temporary entities limit. 300 min, 2048 max |
| `mp_entity` | string | `info_player_deathmatch` | Entity used to mark maps as multiplayer |
| `mp_filter` | string | Empty string | When set, used to filter multiplayer maps instead of `mp_entity`.<br>If the map name starts with the same characters as this filter, it's considered a multiplayer map |
| `nomodels` | boolean | 0 | When set to 1, disallows changing player model in UI |
| `noskills` | boolean | 0 | When set to 1, disallows selection of game difficulty |
| `secure` | boolean | 0 | When set to 1, original Unkle Mike's engine will completely disable developer mode. FWGS ignores but preserves this value for compatibility. |
| `size` | integer | 0 | Game directory size in bytes, used in Change Game dialog only |
| `startmap` | string | `c0a0` | The name of the map used in new game |
| `sp_entity` | string | `info_player_start` | Entity used to mark map as single player. Used in map validation |
| `title` | string | `New Game` | Game title, used in window title, default server name, etc. |
| `trainmap` | string | `t0a0` | The name of the training map (Hazard Course) |
| `type` | string | Empty string | Game type, used in Change Game UI. |
| `url_info` | string | Empty string | Game homepage URL, used in Change Game UI |
| `url_update` | string | Empty string | Game updates URL, used in Settings UI |
| `version` | float | 1.0 | Game version, used in Change Game dialog and in server info |
## FWGS-specific gameinfo.txt keys
These strings are specific to Xash3D FWGS.
| Key | Type | Default value | Description |
| ----------------------- | ---------- | ------------------------ | ----------- |
| `animated_title` | boolean | 0 | Use animated title in main menu (WON Half-Life logo.avi imitation from Half-Life 25-th anniversary update)
| `autosave_aged_count` | integer | 2 | Auto saves limit used in saves rotation |
| `gamedll_linux` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 Linux (see LibraryNaming.md for details) |
| `gamedll_osx` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 macOS (see LibraryNaming.md for details) |
| `hd_background` | boolean | 0 | Use HD background for main menu (Half-Life 25-th anniversary update) |
| `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!<br>When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. |
| `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead |
| `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation |
## Note on GoldSrc liblist.gam support
As Xash3D accidentally supports GoldSrc games, it also supports parsing liblist.gam.\
Xash3D will use this file if gameinfo.txt is absent, or if its modification timestamp is older than liblist.gam.
For game creators who plan supporting only Xash3D, using this file is not recommended.
The table below defines conversion rules from liblist.gam to gameinfo.txt. Some keys' interpretation does differ from `gameinfo.txt`, in this case a note will be left. If `liblist.gam` key isn't present in this table, it's ignored.
| `liblist.gam` key | `gameinfo.txt` key | Note |
| ----------------- | ------------------ | ---- |
| `animated_title` | `animated_title` | |
| `edicts` | `max_edicts` | |
| `fallback_dir` | `fallback_dir` | |
| `game` | `title` | |
| `gamedir` | `gamedir` | |
| `gamedll` | `gamedll` | |
| `gamedll_linux` | `gamedll_linux` | |
| `gamedll_osx` | `gamedll_osx` | |
| `hd_background` | `hd_background` | |
| `icon` | `icon` | |
| `mpentity` | `mp_entity` | |
| `mpfilter` | `mp_filter` | |
| `nomodels` | `nomodels` | |
| `secure` | `secure` | In GoldSrc it's used to mark the multiplayer game as anti-cheat enabled.<br>Original Xash3D misinterprets its value for disallowing console and developer mode.<br>FWGS ignores this key but preserves for compatibility. |
| `startmap` | `startmap` | |
| `size` | `size` | |
| `trainingmap` | `trainmap` | |
| `trainmap` | `trainmap` | |
| `type` | `type` & `gamemode`| In `liblist.gam` this key works as both `type` and `gamemode`.<br>If value is `singleplayer_only` or `multiplayer_only` the game is marked as SP or MP only, and `gameinfo.txt` type set to `Single` or `Multiplayer`.<br>Any custom value will mark the game as both SP and MP compatible, and type is set to whatever custom value. |
| `url_dl` | `url_update` | |
| `url_info` | `url_info` | |
| `version` | `version` | |

View File

@@ -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.

View File

@@ -17,7 +17,7 @@ Mirrored on github - https://github.com/JoelTroch/am_src_rebirth
Mirrored on github - https://github.com/nekonomicon/BattleGrounds Mirrored on github - https://github.com/nekonomicon/BattleGrounds
## Bubblemod ## Bubblemod
Download page on official site(WM snapshot) - [http://www.bubblemod.org/dl_default.php](https://web.archive.org/web/20130717133158/http://www.bubblemod.org/dl_default.php) Download page on official site - http://www.bubblemod.org/dl_default.php (dead link!)
Mirrored on github - https://github.com/HLSources/BubbleMod Mirrored on github - https://github.com/HLSources/BubbleMod
@@ -85,9 +85,6 @@ Official gitlab repository - https://gitlab.com/Sockman/hltopdown
## Half-Life: Update ## Half-Life: Update
Official github repository - https://github.com/Fograin/hl-subsmod-ex Official github repository - https://github.com/Fograin/hl-subsmod-ex
## Half-Life: Rally
Official gitlab repository - https://gitlab.com/hlrally/src
## Half-Life: Weapon Edition ## Half-Life: Weapon Edition
Available on ModDB - https://www.moddb.com/mods/half-life-weapon-edition/downloads/half-life-weapon-edition-1508-alpha-open-src Available on ModDB - https://www.moddb.com/mods/half-life-weapon-edition/downloads/half-life-weapon-edition-1508-alpha-open-src
@@ -133,8 +130,22 @@ Available in mod archive on ModDB - https://www.moddb.com/mods/overturn
## Oz Deathmatch ## Oz Deathmatch
Mirrored on github - https://github.com/nekonomicon/OZDM Mirrored on github - https://github.com/nekonomicon/OZDM
## Spirit of Half-Life
[Logic&Trick's](https://github.com/LogicAndTrick) mirror - https://files.logic-and-trick.com/#/Half-Life/Mods/Spirit%20of%20Half-Life
## Threewave CTF
*Unfinished mod by Valve Software*
Available in Valve's Half-Life repository with Deathmatch Classic sources - https://github.com/ValveSoftware/halflife/tree/master/dmc
## Trinity Render
Available on ModDB: https://www.moddb.com/mods/half-life-episode-two/downloads/trinity-rendering-engine-v308f
## Tyrian: Ground Assault
Available on ModDB: https://www.moddb.com/mods/tyriangroundassault/downloads/tyrianga-v1-0-src
## Paranoia ## Paranoia
Available on ModDB - https://www.moddb.com/mods/paranoia/downloads/paranoia-toolkit Available on ModDB: https://www.moddb.com/mods/paranoia/downloads/paranoia-toolkit
## Paranoia 2: The Savior ## Paranoia 2: The Savior
Prealpha, mirrored on github - https://github.com/a1batross/Paranoia2_ancient Prealpha, mirrored on github - https://github.com/a1batross/Paranoia2_ancient
@@ -149,37 +160,12 @@ Was found on HLFX - http://hlfx.ru/forum/showthread.php?s=2c892dfc52f72be52a89c3
## Ricochet ## Ricochet
Available in Valve's Half-Life repository - https://github.com/ValveSoftware/halflife/tree/master/ricochet Available in Valve's Half-Life repository - https://github.com/ValveSoftware/halflife/tree/master/ricochet
## Spirit of Half-Life
[Logic&Trick's](https://github.com/LogicAndTrick) mirror - https://files.logic-and-trick.com/#/Half-Life/Mods/Spirit%20of%20Half-Life
## The Wastes
Version 1.5: mirrored on code.idtech.space - https://code.idtech.space/vera/halflife-thewastes-sdk
## Threewave CTF
*Unfinished mod by Valve Software*
Available in Valve's Half-Life repository with Deathmatch Classic sources - https://github.com/ValveSoftware/halflife/tree/master/dmc
## Trinity Render
Available on ModDB - https://www.moddb.com/mods/half-life-episode-two/downloads/trinity-rendering-engine-v308f
## Tyrian: Ground Assault
Available on ModDB - https://www.moddb.com/mods/tyriangroundassault/downloads/tyrianga-v1-0-src
## Wasteland
Mirrored on code.idtech.space - https://code.idtech.space/vera/halflife-wasteland-sdk
## Wizard Wars ## Wizard Wars
Download page on official site - http://www.thothie.com/ww/ Download page on official site - http://www.thothie.com/ww/
## XashXT ## XashXT
Mirrored on github - https://github.com/a1batross/XashXT_original Mirrored on github - https://github.com/a1batross/XashXT_original
## Xen-Warrior
*Source code is a part of Spirit of Half-Life 1.0-1.2 under XENWARRIOR macro*
[Logic&Trick's](https://github.com/LogicAndTrick) mirror - https://files.logic-and-trick.com/#/Half-Life/Mods/Spirit%20of%20Half-Life
## Zombie-X ## Zombie-X
Available in mod archive on ModDB - https://www.moddb.com/mods/zombie-x-10-final/downloads/zombie-x-10-dle-beta6-last-version Available in mod archive on ModDB - https://www.moddb.com/mods/zombie-x-10-final/downloads/zombie-x-10-dle-beta6-last-version
@@ -201,12 +187,12 @@ malortie's recreation - https://github.com/malortie/hl-aom
Branch **aom** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aom Branch **aom** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aom
## Afraid of Monsters: Director's cut ## Afraid of Monsters: Director's cut
Reverse-engineered code: branch **aomdc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aomdc Reverse-engineered code, branch **aomdc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/aomdc
## Azure Sheep ## Azure Sheep
malortie's recreation - https://github.com/malortie/hl-asheep malortie's recreation - https://github.com/malortie/hl-asheep
Reverse-engineered code: branch **asheep** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/asheep Reverse-engineered code, branch **asheep** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/asheep
## Big Lolly ## Big Lolly
malortie's recreation - https://github.com/malortie/hl-biglolly malortie's recreation - https://github.com/malortie/hl-biglolly
@@ -228,7 +214,7 @@ Branch **caseclosed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable
Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd
## Counter Strike ## Counter Strike
Reverse-engineered code of client part by a1batross - https://github.com/Velaron/cs16-client Reverse-engineered code of client part by a1batross - https://github.com/FWGS/cs16-client/tree/v1.32
Reverse-engineered code of server part by nagist - https://github.com/nagist/cs16nd Reverse-engineered code of server part by nagist - https://github.com/nagist/cs16nd
@@ -240,22 +226,15 @@ CSO-like Xash3D-based mod, CSMoE - https://github.com/MoeMod/CSMoE
## Crack-Life: Campaign Mode ## Crack-Life: Campaign Mode
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_life 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 ## Escape from the Darkness
malortie's recreation - https://github.com/malortie/hl-eftd malortie's recreation - https://github.com/malortie/hl-eftd
Reverse-engineered code: branch **eftd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/eftd Reverse-engineered code, branch **eftd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/eftd
## Half-Life: Black Guard
*This mod uses dlls from Cleaner's Adventures*
Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd
## Half-Life: Blue Shift ## Half-Life: Blue Shift
Unkle Mike's recreation - https://hlfx.ru/forum/showthread.php?s=&threadid=5253 Unkle Mike's recreation - https://hlfx.ru/forum/showthread.php?s=&threadid=5253
Reverse-engineered code: branch **bshift** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/bshift Reverse-engineered code, branch **bshift** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/bshift
## Half-Life: Induction ## Half-Life: Induction
Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/induction Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/induction
@@ -263,12 +242,12 @@ Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/
## Half-Life: Opposing Force ## Half-Life: Opposing Force
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/hlsdk-xash3d Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/hlsdk-xash3d
Reverse-engineered code: clean branch **opfor** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/opfor Reverse-engineered code, clean branch **opfor** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/opfor
Spirit of Half Life: Opposing-Force Edition - https://github.com/Hammermaps-DEV/SOHL-V1.9-Opposing-Force-Edition Spirit of Half Life: Opposing-Force Edition - https://github.com/Hammermaps-DEV/SOHL-V1.9-Opposing-Force-Edition
## Half-Life: Rebellion ## Half-Life: Rebellion
Reverse-engineered code: branch **rebellion** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/rebellion Reverse-engineered code, branch **rebellion** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/rebellion
## Half-Life: Urbicide ## Half-Life: Urbicide
Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hl_urbicide Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hl_urbicide
@@ -276,7 +255,7 @@ Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portabl
## Half-Life: Visitors ## Half-Life: Visitors
malortie's recreation - https://github.com/malortie/hl-visitors malortie's recreation - https://github.com/malortie/hl-visitors
Reverse-engineered code: branch **visitors** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/visitors Reverse-engineered code, branch **visitors** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/visitors
## Half-Secret ## Half-Secret
Branch **half-secret** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-secret Branch **half-secret** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-secret
@@ -289,18 +268,18 @@ Branch **noffice** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tr
## Poke 646 ## Poke 646
malortie's recreation - https://github.com/malortie/hl-poke646 malortie's recreation - https://github.com/malortie/hl-poke646
Reverse-engineered code: branch **poke646** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646 Reverse-engineered code, branch **poke646** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646
## Poke 646: Vendetta ## Poke 646: Vendetta
malortie's recreation - https://github.com/malortie/hl-poke646-vendetta malortie's recreation - https://github.com/malortie/hl-poke646-vendetta
Reverse-engineered code: branch **poke646_vendetta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646_vendetta Reverse-engineered code, branch **poke646_vendetta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/poke646_vendetta
## Residual Life ## Residual Life
Reverse-engineered code: branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point Reverse-engineered code, branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point
## Residual Point ## Residual Point
Reverse-engineered code: branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point Reverse-engineered code, branch **residual_point** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/residual_point
## Sewer Beta ## Sewer Beta
Branch **sewer_beta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sewer_beta Branch **sewer_beta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sewer_beta
@@ -311,12 +290,12 @@ Reverse-engineered code by Velaron - https://github.com/Velaron/tf15-client
## The Gate ## The Gate
malortie's recreation - https://github.com/malortie/hl-thegate malortie's recreation - https://github.com/malortie/hl-thegate
Reverse-engineered code: branch **thegate** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/thegate Reverse-engineered code, branch **thegate** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/thegate
## They Hunger ## They Hunger
malortie's recreation - https://github.com/malortie/hl-theyhunger malortie's recreation - https://github.com/malortie/hl-theyhunger
Reverse-engineered code: branch **theyhunger** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/theyhunger Reverse-engineered code, branch **theyhunger** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/theyhunger
They Hunger: Tactical - https://www.moddb.com/mods/they-hunger-tactical/downloads/tht-source-code-documentation They Hunger: Tactical - https://www.moddb.com/mods/they-hunger-tactical/downloads/tht-source-code-documentation
@@ -359,22 +338,16 @@ Branch **half-screwed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portab
Port to Linux - https://github.com/fmoraw/NS Port to Linux - https://github.com/fmoraw/NS
## Spirit of Half-Life ## Spirit of Half-Life
Version 1.2: branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2 Version 1.2, branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2
## Swiss Cheese Halloween 2002 ## Swiss Cheese Halloween 2002
Just more playable version by malortie - https://github.com/malortie/hl-shall Just more playable version by malortie - https://github.com/malortie/hl-shall
Branch **halloween** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/halloween Branch **halloween** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/halloween
## The Wastes
Version 1.5: Port to Linux - https://git.mentality.rip/a1batross/halflife-thewastes-sdk
## Threewave CTF ## Threewave CTF
Branch **dmc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/dmc Branch **dmc** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/dmc
## Xen-Warrior
Branch **sohl1.2** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sohl1.2
## Zombie-X ## Zombie-X
Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x

View File

@@ -2,32 +2,38 @@ Xash3D FWGS is intended to be easily ported to specific platform, however main i
This page is about merged ports to main source tree and responsible for it developers. This page is about merged ports to main source tree and responsible for it developers.
For porting guidelines, look engine-porting-guide.md. For porting guidelines, look here(TODO!)
Status: Status:
* **Supported**: active, was confirmed to be fully functional. * **Supported**: active, confirmed to be fully functional.
* **In progress**: active, under development. * **In progress**: active, under development.
* **Incomplete**: not active, but some work was accepted to main repository before
* **Old Engine**: port was for old engine fork * **Old Engine**: port was for old engine fork
* **Not maintained**: lack of human resources * **Not maintained**: lack of human resources
* **Not merged**: was done in third-party fork, real status unknown
* **Deprecated**: not supported anymore * **Deprecated**: not supported anymore
Table is sorted by status and platform. Table is sorted by status.
| Platform | Status | Maintainer | Note | Platform | Status | Maintainer | Note
| -------- | ------ | ---------- | ---- | -------- | ------ | ---------- | ----
| Android | Supported | @Velaron | | Windows | Supported | @a1batross, @SNMetamorph |
| *BSD | Supported | @nekonomicon | | *BSD | Supported | @nekonomicon |
| DOS4GW | Supported | @mittorn | | GNU/Linux(x86, amd64, arm) | Supported | @a1batross, @mittorn |
| GNU/Linux | Supported | @a1batross, @mittorn | | Android | Supported | @a1batross, @mittorn |
| Haiku | Supported | not maintained | Was added by #478 and #483
| macOS | Supported | @sofakng |
| MotoMAGX | Supported | @a1batross | | MotoMAGX | Supported | @a1batross |
| GNU/Linux(elbrus) | Supported | @a1batross, @mittorn | Rare and eventual access to e2k machine
| Haiku | Supported | not maintained | Was added by #478 and #483
| DOS4GW | Supported | @mittorn |
| GNU/Linux(mipsel) | Supported | @mittorn |
| PSVita | Supported | @fgsfdsfgs | | PSVita | Supported | @fgsfdsfgs |
| Switch | Supported | @fgsfdsfgs | | Switch | Supported | @fgsfdsfgs |
| Windows | Supported | @a1batross, @SNMetamorph |
| PSP | In progress | @Crow_bar, @Velaron | [GitHub Repository](https://github.com/Crow-bar/xash3d-fwgs)
| Wii | In progress | Collaborative effort | [GitHub Repository](https://github.com/saucesaft/xash3d-wii) | Wii | In progress | Collaborative effort | [GitHub Repository](https://github.com/saucesaft/xash3d-wii)
| PSP | In progress | @Crow_bar, @Velaron | [GitHub Repository](https://github.com/Crow-bar/xash3d-fwgs)
| Emscripten | Old Engine | not maintained | | Emscripten | Old Engine | not maintained |
| 3DS | Old Engine fork | not maintained | [GitHub Repository](https://github.com/masterfeizz/Xash3DS)
| Oculus Quest | Old Engine fork | @DrBeef | [GitHub Repository](https://github.com/DrBeef/Lambda1VR) | Oculus Quest | Old Engine fork | @DrBeef | [GitHub Repository](https://github.com/DrBeef/Lambda1VR)
| PSVita | Old Engine fork | not maintained | [GitHub Repository](https://github.com/fgsfdsfgs/vitaXash3D)
| Switch | Old Engine fork | not maintained | [GitHub Repository](https://github.com/switchports/xash3d-switch)
| 3DS | Old Engine fork | not maintained | [GitHub Repository](https://github.com/masterfeizz/Xash3DS)
| macOS | Deprecated | not maintained | See GitHub issue #61
| iOS | Deprecated | not maintained | See GitHub issue #61 | iOS | Deprecated | not maintained | See GitHub issue #61

View File

@@ -0,0 +1,41 @@
# Experimental VGUI2 Support
Thanks to @kungfulon contributions, Xash3D FWGS now supports VGUI2.
VGUI2 is undocumented UI system from Source Engine that GoldSrc used in some games and it's main menu.
## Support status
Doesn't draw anything, doesn't take any input.
## List of games that require VGUI2 support
- Counter-Strike 1.6
- Counter-Strike: Condition Zero
- Counter-Strike: Condition Zero Deleted Scenes
- Day of Defeat
- Half-Life: Blue Shift
## How to enable VGUI2 support
By default, engine doesn't initialize VGUI2 to not confuse existing games and mods that use or do not use VGUI1. This support also relies on a number of proprietary libraries, that we better not redistribute, so you have to supply them yourself. Keep in mind, that these libraries are compiled only for 32-bit Windows, Linux and OSX, you shouldn't expect them running anywhere else.
1. Download latest Half-Life from Steam.
2. Open local files.
3. Copy libraries in the list below according to your platform, to folder where Xash3D searches it's libraries (usually in same folder where executable is located)
| Linux | Windows
| -------- | --------
| `chromehtml.so` | `chromehtml.dll`
| `vgui2.so` | `vgui2.dll`
| `libcef.so` | `libcef.dll`
| `libtier0.so` | `tier0.dll`
| `libvstdlib.so` | `vstdlib.dll`
| `libsteam_api.so` | `steam_api.dll`
Some files must also be copied:
- `cef_gtk.pak`
Additionally, on Linux other libraries must be provided. Use `ldd` tool to figure out which libraries you miss. Many of them can be pulled from Steam Runtime.
Do not recommend using RoDir with VGUI2 games. Many of them are broken. Steam API will crash without `steam_appid.txt` in Xash root directory.

View File

@@ -1,27 +1,33 @@
# 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" /> # Xash3D FWGS Engine
[![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) [![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. Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike with extended features and crossplatform.
Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike. ```
Xash3D is a game engine, aimed to provide compatibility with Half-Life Engine,
## Donate as well as to give game developers well known workflow and extend it.
[![Donate to FWGS button](https://img.shields.io/badge/Donate_to_FWGS-%3C3-magenta)](Documentation/donate.md) \ Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine
If you like Xash3D FWGS, consider supporting individual engine maintainers. By supporting us, you help to continue developing this game engine further. The sponsorship links are available in [documentation](Documentation/donate.md). ```
## Fork features ## Fork features
* Steam Half-Life (HLSDK 2.4) support. * HLSDK 2.4 support.
* Crossplatform and modern compilers support: supports Windows, Linux, BSD & Android on x86 & ARM and [many more](Documentation/ports.md). * Crossplatform: supported x86 and ARM on Windows/Linux/BSD/Android. ([see docs for more info](Documentation/ports.md))
* Better multiplayer support: multiple master servers, headless dedicated server, voice chat and IPv6 support. * Modern compilers support: say no more to MSVC6.
* Multiple renderers support: OpenGL, GLESv1, GLESv2 and Software. * Better multiplayer support: multiple master servers, headless dedicated server.
* Advanced virtual filesystem: `.pk3` and `.pk3dir` support, compatibility with GoldSrc FS module, fast case-insensitivity emulation for crossplatform. * Mobility API: allows better game integration on mobile devices(vibration, touch controls)
* Mobility API: better game integration on mobile devices (vibration, touch controls) * Different input methods: touch, gamepad and classic mouse & keyboard.
* Different input methods: touch and gamepad in addition to mouse & keyboard.
* TrueType font rendering, as a part of mainui_cpp. * TrueType font rendering, as a part of mainui_cpp.
* External VGUI support module. * Multiple renderers support: OpenGL, GLESv1, GLESv2, Software.
* PNG & KTX2 image format support. * Voice support.
* [A set of small improvements](Documentation/), without broken compatibility. * External filesystem module like in GoldSrc engine.
* External vgui support module.
* PNG image format support.
* A set of small improvements, without broken compatibility.
## Planned fork features
* Virtual Reality support and game API.
* Vulkan renderer.
## Installation & Running ## Installation & Running
0) Get Xash3D FWGS binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code. 0) Get Xash3D FWGS binaries: you can use [testing](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) build or you can compile engine from source code.

View File

@@ -18,17 +18,21 @@ GNU General Public License for more details.
// video backends (XASH_VIDEO) // video backends (XASH_VIDEO)
#define VIDEO_NULL 0 #define VIDEO_NULL 0
#define VIDEO_SDL 1 #define VIDEO_SDL 1
#define VIDEO_ANDROID 2
#define VIDEO_FBDEV 3 #define VIDEO_FBDEV 3
#define VIDEO_DOS 4 #define VIDEO_DOS 4
// audio backends (XASH_SOUND) // audio backends (XASH_SOUND)
#define SOUND_NULL 0 #define SOUND_NULL 0
#define SOUND_SDL 1 #define SOUND_SDL 1
#define SOUND_OPENSLES 2
#define SOUND_ALSA 3 #define SOUND_ALSA 3
// input (XASH_INPUT) // input (XASH_INPUT)
#define INPUT_NULL 0 #define INPUT_NULL 0
#define INPUT_SDL 1 #define INPUT_SDL 1
#define INPUT_ANDROID 2
#define INPUT_EVDEV 3 #define INPUT_EVDEV 3
// timer (XASH_TIMER) // timer (XASH_TIMER)
@@ -41,13 +45,16 @@ GNU General Public License for more details.
// messageboxes (XASH_MESSAGEBOX) // messageboxes (XASH_MESSAGEBOX)
#define MSGBOX_STDERR 0 #define MSGBOX_STDERR 0
#define MSGBOX_SDL 1 #define MSGBOX_SDL 1
#define MSGBOX_ANDROID 2
#define MSGBOX_WIN32 3 #define MSGBOX_WIN32 3
#define MSGBOX_NSWITCH 4 #define MSGBOX_NSWITCH 4
// library loading (XASH_LIB) // library loading (XASH_LIB)
#define LIB_NULL 0 #define LIB_NULL 0
#define LIB_POSIX 1 #define LIB_POSIX 1
#define LIB_WIN32 2 #define LIB_WIN32 2
#define LIB_STATIC 3 #define LIB_STATIC 3
#endif /* BACKENDS_H */ #endif /* BACKENDS_H */

View File

@@ -9,20 +9,7 @@ NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 ==
======================================================================== ========================================================================
*/ */
#define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24 || type == PF_LUMINANCE) #define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24 || type == PF_LUMINANCE)
#define ImageCompressed( type ) \ #define ImageDXT( type ) (type == PF_DXT1 || type == PF_DXT3 || type == PF_DXT5 || type == PF_ATI2 || type == PF_BC6H_SIGNED || type == PF_BC6H_UNSIGNED || type == PF_BC7)
( type == PF_DXT1 \
|| type == PF_DXT3 \
|| type == PF_DXT5 \
|| type == PF_ATI2 \
|| type == PF_BC4_SIGNED \
|| type == PF_BC4_UNSIGNED \
|| type == PF_BC5_SIGNED \
|| type == PF_BC5_UNSIGNED \
|| type == PF_BC6H_SIGNED \
|| type == PF_BC6H_UNSIGNED \
|| type == PF_BC7_UNORM \
|| type == PF_BC7_SRGB \
|| type == PF_KTX2_RAW )
typedef enum typedef enum
{ {
@@ -38,15 +25,9 @@ typedef enum
PF_DXT3, // s3tc DXT3/BC2 format PF_DXT3, // s3tc DXT3/BC2 format
PF_DXT5, // s3tc DXT5/BC3 format PF_DXT5, // s3tc DXT5/BC3 format
PF_ATI2, // latc ATI2N/BC5 format PF_ATI2, // latc ATI2N/BC5 format
PF_BC4_SIGNED,
PF_BC4_UNSIGNED,
PF_BC5_SIGNED,
PF_BC5_UNSIGNED,
PF_BC6H_SIGNED, // bptc BC6H signed FP16 format PF_BC6H_SIGNED, // bptc BC6H signed FP16 format
PF_BC6H_UNSIGNED, // bptc BC6H unsigned FP16 format PF_BC6H_UNSIGNED, // bptc BC6H unsigned FP16 format
PF_BC7_UNORM, // bptc BC7 format PF_BC7, // bptc BC7 format
PF_BC7_SRGB,
PF_KTX2_RAW, // Raw KTX2 data, used for yet unsupported KTX2 subformats
PF_TOTALCOUNT, // must be last PF_TOTALCOUNT, // must be last
} pixformat_t; } pixformat_t;
@@ -69,7 +50,6 @@ typedef enum
IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals
IL_OVERVIEW = BIT(6), // overview required some unque operations IL_OVERVIEW = BIT(6), // overview required some unque operations
IL_LOAD_PLAYER_DECAL = BIT(7), // special mode for player decals IL_LOAD_PLAYER_DECAL = BIT(7), // special mode for player decals
IL_KTX2_RAW = BIT(8), // renderer can consume raw KTX2 files (e.g. ref_vk)
} ilFlags_t; } ilFlags_t;
// goes into rgbdata_t->encode // goes into rgbdata_t->encode

View File

@@ -717,7 +717,6 @@ enum
kRenderFxExplode, // Scale up really big! kRenderFxExplode, // Scale up really big!
kRenderFxGlowShell, // Glowing Shell kRenderFxGlowShell, // Glowing Shell
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
kRenderFxLightMultiplier,
}; };
typedef int func_t; typedef int func_t;

View File

@@ -52,6 +52,26 @@ SETUP BACKENDS DEFINITIONS
#endif #endif
#endif // XASH_MESSAGEBOX #endif // XASH_MESSAGEBOX
#endif #endif
#elif XASH_ANDROID
// we are building for Android platform, use Android APIs
#ifndef XASH_VIDEO
#define XASH_VIDEO VIDEO_ANDROID
#endif // XASH_VIDEO
#ifndef XASH_INPUT
#define XASH_INPUT INPUT_ANDROID
#endif // XASH_INPUT
#ifndef XASH_SOUND
#define XASH_SOUND SOUND_OPENSLES
#endif // XASH_SOUND
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_ANDROID
#endif // XASH_MESSAGEBOX
#define XASH_USE_EVDEV 1
#define XASH_DYNAMIC_DLADDR
#elif XASH_LINUX #elif XASH_LINUX
// we are building for Linux without SDL2, can draw only to framebuffer yet // we are building for Linux without SDL2, can draw only to framebuffer yet
#ifndef XASH_VIDEO #ifndef XASH_VIDEO
@@ -151,8 +171,6 @@ Default build-depended cvar and constant values
#define DEFAULT_MODE_WIDTH 960 #define DEFAULT_MODE_WIDTH 960
#define DEFAULT_MODE_HEIGHT 544 #define DEFAULT_MODE_HEIGHT 544
#define DEFAULT_ALLOWCONSOLE 1 #define DEFAULT_ALLOWCONSOLE 1
#elif XASH_ANDROID
#define DEFAULT_TOUCH_ENABLE "1"
#elif XASH_MOBILE_PLATFORM #elif XASH_MOBILE_PLATFORM
#define DEFAULT_TOUCH_ENABLE "1" #define DEFAULT_TOUCH_ENABLE "1"
#define DEFAULT_M_IGNORE "1" #define DEFAULT_M_IGNORE "1"
@@ -186,11 +204,7 @@ Default build-depended cvar and constant values
#endif // DEFAULT_ALLOWCONSOLE #endif // DEFAULT_ALLOWCONSOLE
#ifndef DEFAULT_FULLSCREEN #ifndef DEFAULT_FULLSCREEN
#define DEFAULT_FULLSCREEN "1" // must be a string #define DEFAULT_FULLSCREEN 1
#endif // DEFAULT_FULLSCREEN #endif // DEFAULT_FULLSCREEN
#ifndef DEFAULT_MAX_EDICTS
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
#endif // DEFAULT_MAX_EDICTS
#endif // DEFAULTS_H #endif // DEFAULTS_H

View File

@@ -27,19 +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_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_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
#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 #endif//FEATURES_H

View File

@@ -19,8 +19,6 @@ GNU General Public License for more details.
#define GFL_NOMODELS (1<<0) #define GFL_NOMODELS (1<<0)
#define GFL_NOSKILLS (1<<1) #define GFL_NOSKILLS (1<<1)
#define GFL_RENDER_PICBUTTON_TEXT (1<<2) #define GFL_RENDER_PICBUTTON_TEXT (1<<2)
#define GFL_HD_BACKGROUND (1<<3)
#define GFL_ANIMATED_TITLE (1<<4)
/* /*
======================================================================== ========================================================================

View File

@@ -1,35 +1,18 @@
/* //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
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
// //
// 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 down[2]; // key nums holding it down
int state; // low bit is down state int state; // low bit is down state
} kbutton_t; } kbutton_t;
STATIC_ASSERT( sizeof( kbutton_t ) == 12, "kbutton_t isn't 12 bytes!" ); #endif // !KBUTTONH
#endif // KBUTTON_H

View File

@@ -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 #ifndef NETADR_H
modify it under the terms of the GNU General Public License #define NETADR_H
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
#include "build.h"
#include STDINT_H #include STDINT_H
// net.h -- quake's interface to the networking layer typedef enum
// 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
{ {
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]; // Original structure:
byte ipx[10]; // typedef struct netadr_s
// {
unsigned short port; // netadrtype_t type;
} netadr_t; // unsigned char ip[4];
*/ // unsigned char ipx[10];
// unsigned short port;
// } netadr_t;
#pragma pack( push, 1 ) #pragma pack( push, 1 )
typedef struct netadr_s typedef struct netadr_s
{ {
union union
{ {
// IPv6 struct
struct struct
{ {
uint16_t type6; uint32_t type;
uint8_t ip6[16];
};
struct
{
uint32_t type; // must be netadrtype_t but will break with short enums
union union
{ {
uint8_t ip[4]; uint8_t ip[4];
uint32_t ip4; // for easier conversions 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; } netadr_t;
#pragma pack( pop ) #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

View File

@@ -35,6 +35,7 @@ GNU General Public License for more details.
#define __cdecl #define __cdecl
#define __stdcall #define __stdcall
#define _inline static inline #define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#if XASH_POSIX #if XASH_POSIX
#include <unistd.h> #include <unistd.h>
@@ -62,6 +63,13 @@ GNU General Public License for more details.
int x, y; int x, y;
} POINT; } POINT;
#else // WIN32 #else // WIN32
#ifdef __MINGW32__
#define _inline static inline
#define FORCEINLINE inline __attribute__((always_inline))
#else
#define FORCEINLINE __forceinline
#endif
#define open _open #define open _open
#define read _read #define read _read
#define alloca _alloca #define alloca _alloca

View File

@@ -107,8 +107,7 @@ typedef enum
TF_ARB_FLOAT = (1<<26), // float textures TF_ARB_FLOAT = (1<<26), // float textures
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
TF_ARB_16BIT = (1<<28), // keep image as 16-bit (not 24) TF_ARB_16BIT = (1<<28), // keep image as 16-bit (not 24)
TF_MULTISAMPLE = (1<<29), // multisampling texture TF_MULTISAMPLE = (1<<29) // multisampling texture
TF_ALLOW_NEAREST = (1<<30), // allows toggling nearest filtering for TF_NOMIPMAP textures
} texFlags_t; } texFlags_t;
typedef enum typedef enum
@@ -230,7 +229,7 @@ typedef struct render_api_s
void (*R_Reserved0)( void ); void (*R_Reserved0)( void );
// static allocations // 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 ); void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// engine utils (not related with render API but placed here) // engine utils (not related with render API but placed here)

View File

@@ -57,7 +57,9 @@ typedef uint64_t longtime_t;
#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions #define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions
#define BIT( n ) ( 1U << ( n )) #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 SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits)) #define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit)) #define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))
@@ -84,28 +86,16 @@ typedef uint64_t longtime_t;
#endif #endif
#define _format(x) __attribute__((format(printf, x, x+1))) #define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull))
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
#define FORCEINLINE inline __attribute__((always_inline))
#define NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport ) #define EXPORT __declspec( dllexport )
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#define FORCEINLINE __forceinline
#define NOINLINE __declspec( noinline )
#else #else
#define EXPORT #define EXPORT
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#define FORCEINLINE
#define NOINLINE
#endif #endif
#if ( __GNUC__ >= 3 ) #if ( __GNUC__ >= 3 )
@@ -124,18 +114,10 @@ typedef uint64_t longtime_t;
#define likely(x) (x) #define likely(x) (x)
#endif #endif
#if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword #if defined( static_assert ) // C11 static_assert
#define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y )
#define STATIC_ASSERT static_assert #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 #else
#define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1] #define STATIC_ASSERT( x, y ) extern int _static_assert_##__LINE__[( 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 )
#endif #endif
#ifdef XASH_BIG_ENDIAN #ifdef XASH_BIG_ENDIAN
@@ -195,7 +177,6 @@ typedef struct dll_info_s
} dll_info_t; } dll_info_t;
typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs ); typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs );
typedef void *(*pfnCreateInterface_t)( const char *, int * );
// config strings are a general means of communication from // config strings are a general means of communication from
// the server to all connected clients. // the server to all connected clients.

View File

@@ -0,0 +1,206 @@
#############################################
# Makefile.linux - linux makefile
# Copyright (C) 2017 mittorn
# 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.
##############################################
# Default options - optimized to debug on local machine
CC ?= gcc
CXX ?= g++
CFLAGS ?= -g -O1 -fsigned-char -Wall -Wextra -Wsign-compare -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable
LDFLAGS =
LBITS := $(shell getconf LONG_BIT)
DEPS :=
XASH_COMMIT := $(firstword $(shell git rev-parse --short=6 HEAD) unknown)
ifeq ($(XASH_COMMIT),unknown)
$(warning You seems to build xash3d without git)
$(warning Please use git if you are going to publish your build)
endif
# Pass 64BIT=1 to make arguments to allow amd64 builds
ifneq ($(64BIT),1)
ifeq ($(LBITS),64)
LDFLAGS += -m32
CFLAGS += -m32
endif
endif
TOPDIR = $(PWD)/..
INCLUDES :=
XASH_SINGLE_BINARY ?= 1
INSTALL_DIR ?= ./install/
ifeq ($(NANOGL),1)
INCLUDES += -Inanogl -Inanogl/GL
endif
INCLUDES += -I/usr/include/SDL2 -Icommon -I../common -I. -I../pm_shared -Iclient -Iserver -Iclient/vgui -Icommon/sdl
#############################
# Preprocessor defines:
#############################
DEFINES =
# Specify commit hash in version string
DEFINES += -DXASH_BUILD_COMMIT=\"$(XASH_COMMIT)\"
# Only SDL backend exists on linux
ifeq ($(XASH_DEDICATED),1)
DEFINES += -DXASH_DEDICATED
else
DEFINES += -DXASH_SDL
LIBS += -lSDL2
endif
#############################################
# GL/GLES translators.
# You need clone it to engine folder to use
# Only one translator should be enabled
#############################################
ifeq ($(NANOGL),1)
DEFINES += -DXASH_NANOGL -D__MULTITEXTURE_SUPPORT__ -DEGL_LIB=\"libEGL.so\"
endif
ifeq ($(WES),1)
DEFINES += -DXASH_WES -D__MULTITEXTURE_SUPPORT__ -DEGL_LIB=\"libEGL.so\"
endif
ifeq ($(REGAL),1)
DEFINES += -DXASH_REGAL -D__MULTITEXTURE_SUPPORT__ -DEGL_LIB=\"regal/lib/linux-32/libRegal.so\"
LIBS += regal/lib/linux-32/libRegal.so
endif
# Some libc implementations cannot use libdl in static builds, so disable it by default
ifeq ($(XASH_STATIC),1)
ifneq ($(XASH_STATIC_LIBDL),1)
DEFINES += -DNO_LIBDL
endif
XASH_SINGLE_BINARY := 1
endif
ifneq ($(XASH_STATIC),1)
LIBS += -ldl
endif
ifeq ($(XASH_STATIC_LIBDL),1)
LIBS += -ldl
endif
LIBS += -lm -pthread
ifeq ($(XASH_SINGLE_BINARY),1)
DEFINES += -DSINGLE_BINARY
endif
# Collect files
SRCS_CPP =
SRCS = $(wildcard server/*.c) $(wildcard client/vgui/*.c) $(wildcard client/avi/*.c) $(wildcard common/*.c) $(wildcard common/imagelib/*.c) $(wildcard common/soundlib/*.c) $(wildcard common/soundlib/libmpg/*.c)
ifneq ($(XASH_DEDICATED),1)
SRCS += $(wildcard client/*.c)
SRCS += $(wildcard platform/sdl/*.c)
ifeq ($(WES),1)
SRCS += $(wildcard gl-wes-v2/src/*.c)
endif
ifeq ($(NANOGL),1)
SRCS_CPP += $(wildcard nanogl/*.cpp)
endif
endif
OBJS = $(patsubst %.c,obj/%.o,$(SRCS))
OBJS_CPP = $(patsubst %.cpp,obj/%.o,$(SRCS_CPP))
#################################
# Windows DLL loader
# Should be enabled only on i386 builds
#################################
LOADER :=
ifeq ($(XASH_DLL_LOADER),1)
DEFINES += -DDLL_LOADER
ifeq ($(XASH_SINGLE_BINARY),1)
LOADER = libloader.a
else
LOADER = libloader.so
endif
DEPS += $(LOADER)
LIBS += $(LOADER)
endif
# Rules for binaries
ifeq ($(XASH_SINGLE_BINARY),0)
BINARIES = libxash.so
libxash.so : $(OBJS) $(OBJS_CPP) $(DEPS)
$(CC) -fvisibility=hidden -o libxash.so $(LDFLAGS) -shared $(OBJS) $(OBJS_CPP) $(LIBS)
else
BINARIES = xash
xash: $(OBJS) $(OBJS_CPP) $(DEPS)
ifeq ($(XASH_STATIC),1)
$(CC) -o xash -static $(LDFLAGS) $(OBJS) $(OBJS_CPP) $(LIBS)
else
$(CC) -o xash -fvisibility=hidden $(LDFLAGS) $(OBJS) $(OBJS_CPP) $(LIBS)
endif
endif
ifeq ($(XASH_DLL_LOADER),1)
$(LOADER):
$(MAKE) -f ../loader/Makefile.linux -C ../loader $(LOADER)
cp ../loader/$(LOADER) .
endif
# Create dirs for object files
DIRS := obj obj/server obj/client/avi obj/client/vgui obj/common/sdl obj/common/imagelib obj/common/soundlib/libmpg obj/platform/sdl obj/nanogl
$(OBJS): | $(DIRS)
$(DIRS) :
mkdir -p $(DIRS)
# Object rules
obj/%.o : %.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c "$<" -o "$@" -Wno-unused-result -fvisibility=hidden
obj/%.o : %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -c "$<" -o "$@"
default: $(BINARIES)
.PHONY: depend clean list install
clean:
$(RM) $(OBJS) $(OBJS_CPP) $(BINARIES) ../loader/*.o ../loader/*.a ../loader/*.so $(LOADER)
list:
@echo Sources:
@echo $(SRCS)
@echo C++ Sources:
@echo $(SRCS_CPP)
@echo Objects:
@echo $(OBJS) $(OBJS_CPP)
@echo Dirs:
@echo $(DIRS)
@echo Dependencies:
@echo $(DEPS)
# Simple install rule
install: $(BINARIES)
mkdir -p $(INSTALL_DIR)
ifeq ($(XASH_SINGLE_BINARY),1)
cp xash $(INSTALL_DIR)/xash_bin
else
cp libxash.so $(INSTALL_DIR)/
cp libloader.so $(INSTALL_DIR)/
endif

269
contrib/mittorn/README.md Normal file
View File

@@ -0,0 +1,269 @@
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
- [Building](#building)
- [Manual build (without CMake)](#manual-build-without-cmake)
- [Building Engine](#building-engine)
- [Building launch binary](#building-launch-binary)
- [Building on Windows](#building-on-windows)
- [Visual Studio 2013 (recommended for Windows)](#visual-studio-2013-recommended-for-windows)
- [Visual Studio 6](#visual-studio-6)
- [MinGW](#mingw)
- [Building Game mods](#building-game-mods)
- [Linux](#linux)
- [microndk](#microndk)
- [Makefile.linux](#makefile-linux)
- [Windows](#windows)
- [Running](#running)
- [Manual running](#manual-running)
- [Running with GDB](#running-with-gdb)
- [Using DLL Loader](#using-dll-loader)
- [Running MinGW builds](#running-mingw-builds)
- [Running MinGW builds under GDB](#running-mingw-builds-under-gdb)
# Building
## Manual build (without CMake)
### Building engine
Clone Xash3D repository using git:
git clone https://github.com/FWGS/xash3d
Move to the Xash3D folder:
cd xash3d/engine
make -f Makefile.linux XASH_VGUI=1
or same for dedicated
make -f Makefile.linux XASH_DEDICATED=1
To enable dll support on linux, build loader library:
cd ../loader
make -f Makefile.linux libloader.so libloader.a
cp libloader.so libloader.a ../engine/
And built engine with XASH_DLL_LOADER=1:
cd ../engine
make -f Makefile.linux XASH_VGUI=1 XASH_SDL=1 XASH_DLL_LOADER=1
or same for dedicated server
cd ../engine
make -f Makefile.linux XASH_DEDICATED=1 XASH_DLL_LOADER=1
### Building engine in separate library
Some old distros does not support hidden symbol visibility
This results in crash when loading server library
Building launch binary
cd (xash3d)/game_launch
gcc xash.c -o xash -ldl -lrt -lm
Building engine library:
make -f Makefile.linux XASH_SINGLE_BINARY=0
## Building on Windows
### Visual Studio 2013 (recommended for Windows)
Download latest prebuilt SDL2 from
https://www.libsdl.org/release/SDL2-devel-2.0.4-VC.zip
Unzip and rename `SDL2-2.0.4` folder to `SDL2` and put it next to xash3d project folder.
..\xash3d\
..\SDL2\
Open `xash.sln` with Visual Studio 2013 and make a build. After building, copy contents of `Debug` or
`Release` folder to directory you choose. Copy `valve` folder and `vgui.dll` from your Half Life game
installation folder and `SDL2.dll` form `\SDL2\lib\x86\` to it.
Move `vgui_support.dll` into `valve` folder.
..\valve\
..\valve\vgui_support.dll
..\menu.dll
..\SDL2.dll
..\vgui.dll
..\xash.dll
..\xash.exe
Now you good to go, just run `xash.exe`.
### Visual Studio 6
This is legacy configuration, but msvc6 seems to generate more stable and more effective code
Setup your msvc6 enviroment, unpack SDL2-2.0.4 to xash3d folder and do:
cd (xash3d)\engine
..\msvc6\build.bat
cd (xash3d)\game_launch
..\msvc6\build_launch.bat
### MinGW
The most effective configuration, but maybe unstable.
Setup your MinGW environment and run:
cd (xash3d)\engine\
CC=gcc mingw32-make -f Makefile.mingw
engine will be built to single exe binary
## Building game mods
### Linux
#### microndk
All mods that ported to android may be build to linux using Android.mk with microndk:
[https://github.com/SDLash3D/microndk]
Clone microndk repo somewhere, change xash3d_config to preffered configuration (change arch to x86
for example)
Go to dlls folder if you are building server or cl_dlls if you are building client and do:
make -f /path/to/microndk/microndk.mk -j4
Do:
make -f /path/to/microndk/microndk.mk -j4 clean
every time when you build client after building server
#### Makefile.linux
### Windows
On windows common way is using Visual Studio as many mods does not correctly work with mingw.
Just open project and build it.
Other is using mingw and microndk, but it was not tested yet.
hlsdk-xash3d based mods may work fine with mingw.
You may use microndk to build it. Build process is very similar to linux one.
After setting up MinGW enviroment, do:<br>
`mingw32-make -f \path\to\microndk\Microndk.mk`
to build 64-bit library, use:<br>
`mingw32-make -f \path\to\microndk\Microndk.mk 64BIT=1`
Edit xash3d_config.mk to set optimal CFLAGS if you are running server
# Running
Copy **valve** folder from Half-Life:
cp -r $HOME/.steam/steam/steamapps/common/Half-Life/valve $HOME/Games/Xash3D
**NOTE**: If you build with CMake, you can now use `make install`. It will install binaries where
they must be located. So just run `xash3d` from command line in directory where is gamedata is located.
For additional info look to the CMakeLists.txt in repo root and xash3d.sh script.
After a successful build, copy the next files to some other directory where you want to run Xash3D:
cp engine/libxash.so game_launch/xash3d mainui/libxashmenu.so $HOME/Games/Xash3D
If you built it with XASH_VGUI, also copy vgui.so:
cp ../hlsdk/linux/vgui.so vgui_support/libvgui_support.so $HOME/Games/Xash3D
Copy script:
cp ../xash3d.sh $HOME/Games/Xash3D
Run:
cd $HOME/Games/Xash3D
./xash3d.sh
## Manual running
Put xash3d binaries and vgui(optionally) to you game data directory and run:
LD_LIBRARY_PATH=. ./xash -dev 5
## Running under GDB
LD_LIBRARY_PATH=. gdb --args ./xash -dev 5
## Using DLL Loader
Put vgui_support.dll from windows build to your game data folder and run:
LD_LIBRARY_PATH=. ./xash -dev 5 -vguilib vgui.dll -clientlib valve/cl_dlls/client.dll -dll dlls/hl.dll
## Running MinGW builds
Put exe file to your game data directory
cd (game)\
xash_bin -dev 5
### Running MinGW builds under GDB
gdb --args ./xash_bin.exe -dev 5
# Useful GDB commands
Start or restart process:
(gdb) r
Show backtrace:
(gdb) bt
Full backtrace:
(gdb) bt full
Continue execution:
(gdb) c
Recover from segmentation fault:
Skipping function:
(gdb) handle SIGSEGV nopass
(gdb) ret
(gdb) c
Restart frame for beginning:
(gdb) handle SIGSEGV nopass
(gdb) jump *Host_AbortCurrentFrame
Anti-Crash script (useful for scripting servers):
```
cd /path/to/rootdir
file xash
set args xash -dev 5 -nowcon
handle SIGSEGV nopass
catch signal SIGSEGV
set $crashes=0
commands
print $crashes++
if $crashes > 500
set $crashes=0
run
else
jump *Host_AbortCurrentFrame
end
end
run
```

7
contrib/mittorn/setup.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
SCRIPTDIR=$(dirname "$0")
TOPDIR=$SCRIPTDIR/../../
cp $SCRIPTDIR/Makefile.dllloader $TOPDIR/loader/
cp $SCRIPTDIR/Makefile.emscripten $TOPDIR/engine/
cp $SCRIPTDIR/Makefile.linux $TOPDIR/engine/
cp $SCRIPTDIR/wscript $TOPDIR/engine/

73
contrib/mittorn/wscript Normal file
View File

@@ -0,0 +1,73 @@
#! /usr/bin/env python
# encoding: utf-8
# mittorn, 2018
VERSION='0.99'
APPNAME='xash3d-fwgs'
top = '.'
def options(opt):
opt.load('compiler_c')
# opt.load('msvs')
opt.add_option('--dedicated', action = 'store_true', help = 'build dedicated server only' )
opt.add_option('--64bits', dest = 'amd64', action = 'store_true', help = 'build 64-bit engine on x86_64' )
def configure(conf):
conf.load('compiler_c')
conf.env.append_unique('CFLAGS', '-O2')
conf.env.append_unique('DEFINES', 'SINGLE_BINARY')
conf.env.append_value('LINKFLAGS', '-ldl')
conf.env.append_value('LINKFLAGS', '-lm')
conf.env.append_value('LINKFLAGS', '-pthread')
# check for 64-bit builds
# TODO: check 32-bit toolchain and dependencies
if conf.env.DEST_CPU == 'x86_64' and not conf.options.amd64:
conf.env.append_value('LINKFLAGS', '-m32')
conf.env.append_value('CFLAGS', '-m32')
print('NOTE: will build engine with 64-bit toolchain using -m32')
else:
print('Warning: 64bit engine may be unstable')
# check for dedicated server build
if conf.options.dedicated:
conf.env.append_unique('DEFINES', 'XASH_DEDICATED')
conf.env.dedicated = True
else:
# TODO: add way to specify SDL2 path, move to separate function
try:
conf.check_cfg(path='sdl2-config', args='--cflags --libs', package='', msg='Checking for SDL2', uselib_store='SDL2')
except conf.errors.ConfigurationError:
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
conf.env.append_unique('DEFINES', 'XASH_SDL')
def build(bld):
# basic build: dedicated only, no dependencies
use = [];
source = bld.path.ant_glob([
'common/*.c',
'common/imagelib/*.c',
'common/soundlib/*.c',
'common/soundlib/libmpg/*.c',
'server/*.c'])
# add client files and sdl2 library
if not bld.env.dedicated:
use += ['SDL2']
source += bld.path.ant_glob([
'client/*.c',
'client/vgui/*.c',
'client/avi/*.c',
'platform/sdl/*.c'])
bld(
target = 'xash',
features = 'c cprogram',
includes = ['../common', '../pm_shared', 'common', 'server', 'client', 'client/vgui', '.' ],
source = source,
use = use
)

View File

@@ -1,22 +1,18 @@
/* /***
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.525731, 0.000000, 0.850651},
{-0.442863, 0.238856, 0.864188}, {-0.442863, 0.238856, 0.864188},
{-0.295242, 0.000000, 0.955423}, {-0.295242, 0.000000, 0.955423},

View File

@@ -85,12 +85,6 @@ void CL_PlayCDTrack_f( void )
paused = false; paused = false;
looped = false; looped = false;
} }
else if( !Q_stricmp( command, "playfile" ))
{
S_StartBackgroundTrack( pszTrack, NULL, 0, true );
paused = false;
looped = false;
}
else if( !Q_stricmp( command, "loop" )) else if( !Q_stricmp( command, "loop" ))
{ {
if( Q_isdigit( pszTrack )) if( Q_isdigit( pszTrack ))
@@ -102,12 +96,6 @@ void CL_PlayCDTrack_f( void )
paused = false; paused = false;
looped = true; looped = true;
} }
else if( !Q_stricmp( command, "loopfile" ))
{
S_StartBackgroundTrack( pszTrack, pszTrack, 0, true );
paused = false;
looped = true;
}
else if( !Q_stricmp( command, "pause" )) else if( !Q_stricmp( command, "pause" ))
{ {
S_StreamSetPause( true ); S_StreamSetPause( true );
@@ -157,12 +145,32 @@ void CL_PlayCDTrack_f( void )
CL_ScreenshotGetName 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 ) if( lastnum < 0 || lastnum > 9999 )
{
Con_Printf( S_ERROR "unable to write screenshot\n" );
return false; 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 +180,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, false ))
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, false ))
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 CL_LevelShot_f
@@ -214,100 +343,23 @@ void CL_LevelShot_f( void )
else cls.scrshot_action = scrshot_inactive; // disable - not needs else cls.scrshot_action = scrshot_inactive; // disable - not needs
} }
static scrshot_t CL_GetScreenshotTypeFromString( const char *string ) /*
{ ==================
if( !Q_stricmp( string, "snapshot" )) CL_SaveShot_f
return scrshot_snapshot;
if( !Q_stricmp( string, "screenshot" )) mini-pic in loadgame menu
return scrshot_normal; ==================
*/
if( !Q_stricmp( string, "saveshot" )) void CL_SaveShot_f( void )
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( CL_IsDevOverviewMode() == 1 )
type = scrshot_mapshot;
}
else
{ {
if( Cmd_Argc() < 2 ) if( Cmd_Argc() < 2 )
{ {
Con_Printf( S_USAGE "%s <shotname>\n", argv0 ); Con_Printf( S_USAGE "saveshot <savename>\n" );
return; 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 )); Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
break; cls.scrshot_action = scrshot_savegame; // build new frame for saveshot
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;
} }
/* /*

View File

@@ -127,7 +127,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
CL_AddToResourceList( pResource, &cl.resourcesonhand ); CL_AddToResourceList( pResource, &cl.resourcesonhand );
} }
static void CL_ClearResourceList( resource_t *pList ) void CL_ClearResourceList( resource_t *pList )
{ {
resource_t *p, *n; resource_t *p, *n;

View File

@@ -107,8 +107,6 @@ struct
int angle_position; int angle_position;
} demo; } demo;
static qboolean CL_NextDemo( void );
/* /*
==================== ====================
CL_StartupDemoHeader CL_StartupDemoHeader
@@ -158,7 +156,7 @@ CL_GetDemoRecordClock
write time while demo is recording write time while demo is recording
==================== ====================
*/ */
static float CL_GetDemoRecordClock( void ) float CL_GetDemoRecordClock( void )
{ {
return cl.mtime[0]; return cl.mtime[0];
} }
@@ -170,7 +168,7 @@ CL_GetDemoPlaybackClock
overwrite host.realtime overwrite host.realtime
==================== ====================
*/ */
static float CL_GetDemoPlaybackClock( void ) float CL_GetDemoPlaybackClock( void )
{ {
return host.realtime + host.frametime; return host.realtime + host.frametime;
} }
@@ -196,7 +194,7 @@ CL_WriteDemoCmdHeader
Writes the demo command header and time-delta 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; float dt;
@@ -269,7 +267,7 @@ Save state of cls.netchan sequences
so that we can play the demo correctly. so that we can play the demo correctly.
==================== ====================
*/ */
static void CL_WriteDemoSequence( file_t *file ) void CL_WriteDemoSequence( file_t *file )
{ {
Assert( file != NULL ); Assert( file != NULL );
@@ -350,7 +348,7 @@ CL_WriteDemoHeader
Write demo header Write demo header
==================== ====================
*/ */
static void CL_WriteDemoHeader( const char *name ) void CL_WriteDemoHeader( const char *name )
{ {
int copysize; int copysize;
int savepos; int savepos;
@@ -374,7 +372,7 @@ static void CL_WriteDemoHeader( const char *name )
demo.header.id = IDEMOHEADER; demo.header.id = IDEMOHEADER;
demo.header.dem_protocol = DEMO_PROTOCOL; demo.header.dem_protocol = DEMO_PROTOCOL;
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION; demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
demo.header.host_fps = host_maxfps.value ? bound( MIN_FPS, host_maxfps.value, MAX_FPS ) : MAX_FPS; 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.mapname, clgame.mapname, sizeof( demo.header.mapname ));
Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment )); Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment ));
Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir )); Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir ));
@@ -438,7 +436,7 @@ CL_StopRecord
finish recording demo finish recording demo
================= =================
*/ */
static void CL_StopRecord( void ) void CL_StopRecord( void )
{ {
int i, curpos; int i, curpos;
float stoptime; float stoptime;
@@ -520,7 +518,7 @@ CL_ReadDemoCmdHeader
read the demo command read the demo command
================= =================
*/ */
static qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt ) qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt )
{ {
// read the command // read the command
// HACKHACK: skip NOPs // HACKHACK: skip NOPs
@@ -550,7 +548,7 @@ read the demo usercmd for predicting
and smooth movement during playback the demo and smooth movement during playback the demo
================= =================
*/ */
static void CL_ReadDemoUserCmd( qboolean discard ) void CL_ReadDemoUserCmd( qboolean discard )
{ {
byte data[1024]; byte data[1024];
int cmdnumber; int cmdnumber;
@@ -572,9 +570,6 @@ static void CL_ReadDemoUserCmd( qboolean discard )
memset( &nullcmd, 0, sizeof( nullcmd )); memset( &nullcmd, 0, sizeof( nullcmd ));
MSG_Init( &buf, "UserCmd", data, sizeof( data )); MSG_Init( &buf, "UserCmd", data, sizeof( data ));
// a1ba: I have no proper explanation why
cmdnumber++;
pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK]; pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK];
pcmd->processedfuncs = false; pcmd->processedfuncs = false;
pcmd->senttime = 0.0f; pcmd->senttime = 0.0f;
@@ -615,7 +610,7 @@ CL_ReadDemoSequence
read netchan sequences read netchan sequences
================= =================
*/ */
static void CL_ReadDemoSequence( qboolean discard ) void CL_ReadDemoSequence( qboolean discard )
{ {
int incoming_sequence; int incoming_sequence;
int incoming_acknowledged; int incoming_acknowledged;
@@ -649,17 +644,15 @@ static void CL_ReadDemoSequence( qboolean discard )
CL_DemoStartPlayback CL_DemoStartPlayback
================= =================
*/ */
static void CL_DemoStartPlayback( int mode ) void CL_DemoStartPlayback( int mode )
{ {
if( cls.changedemo ) if( cls.changedemo )
{ {
int maxclients = cl.maxclients;
S_StopAllSounds( true ); S_StopAllSounds( true );
SCR_BeginLoadingPlaque( false ); SCR_BeginLoadingPlaque( false );
CL_ClearState (); CL_ClearState ();
CL_InitEdicts( maxclients ); // re-arrange edicts CL_InitEdicts (); // re-arrange edicts
} }
else else
{ {
@@ -694,7 +687,7 @@ static void CL_DemoStartPlayback( int mode )
CL_DemoAborted CL_DemoAborted
================= =================
*/ */
static void CL_DemoAborted( void ) void CL_DemoAborted( void )
{ {
if( cls.demofile ) if( cls.demofile )
FS_Close( cls.demofile ); FS_Close( cls.demofile );
@@ -705,7 +698,7 @@ static void CL_DemoAborted( void )
cls.demofile = NULL; cls.demofile = NULL;
cls.demonum = -1; cls.demonum = -1;
Cvar_DirectSet( &v_dark, "0" ); Cvar_SetValue( "v_dark", 0.0f );
} }
/* /*
@@ -723,7 +716,7 @@ void CL_DemoCompleted( void )
if( !CL_NextDemo() && !cls.changedemo ) if( !CL_NextDemo() && !cls.changedemo )
UI_SetActiveMenu( true ); UI_SetActiveMenu( true );
Cvar_DirectSet( &v_dark, "0" ); Cvar_SetValue( "v_dark", 0.0f );
} }
/* /*
@@ -734,7 +727,7 @@ returns true on success, false on failure
g-cont. probably captain obvious mode is ON g-cont. probably captain obvious mode is ON
================= =================
*/ */
static qboolean CL_DemoMoveToNextSection( void ) qboolean CL_DemoMoveToNextSection( void )
{ {
if( ++demo.entryIndex >= demo.directory.numentries ) if( ++demo.entryIndex >= demo.directory.numentries )
{ {
@@ -756,7 +749,7 @@ static qboolean CL_DemoMoveToNextSection( void )
return true; return true;
} }
static qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length ) qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
{ {
int msglen = 0; int msglen = 0;
@@ -807,7 +800,7 @@ CL_DemoReadMessageQuake
reads demo data and write it to client 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; vec3_t viewangles;
int msglen = 0; int msglen = 0;
@@ -1022,7 +1015,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
return CL_ReadRawNetworkData( buffer, 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; int i, i0, i1, imod;
float at; float at;
@@ -1117,7 +1110,7 @@ CL_FinishTimeDemo
show stats show stats
============== ==============
*/ */
static void CL_FinishTimeDemo( void ) void CL_FinishTimeDemo( void )
{ {
int frames; int frames;
double time; double time;
@@ -1129,10 +1122,7 @@ static void CL_FinishTimeDemo( void )
time = host.realtime - cls.td_starttime; time = host.realtime - cls.td_starttime;
if( !time ) time = 1.0; if( !time ) time = 1.0;
Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time ); Con_Printf( "%i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time );
if( Sys_CheckParm( "-timedemo" ))
CL_Quit_f();
} }
/* /*
@@ -1266,7 +1256,7 @@ CL_NextDemo
Called when a demo finishes Called when a demo finishes
================== ==================
*/ */
static qboolean CL_NextDemo( void ) qboolean CL_NextDemo( void )
{ {
char str[MAX_QPATH]; char str[MAX_QPATH];
@@ -1316,7 +1306,7 @@ void CL_CheckStartupDemos( void )
} }
// run demos loop in background mode // run demos loop in background mode
Cvar_DirectSet( &v_dark, "1" ); Cvar_SetValue( "v_dark", 1.0f );
cls.demos_pending = false; cls.demos_pending = false;
cls.demonum = 0; cls.demonum = 0;
CL_NextDemo (); CL_NextDemo ();
@@ -1332,11 +1322,11 @@ static void CL_DemoGetName( int lastnum, char *filename, size_t size )
if( lastnum < 0 || lastnum > 9999 ) if( lastnum < 0 || lastnum > 9999 )
{ {
// bound // bound
Q_strncpy( filename, "demo9999", size ); Q_strncpy( filename, "demo9999.dem", size );
return; return;
} }
Q_snprintf( filename, size, "demo%04d", lastnum ); Q_snprintf( filename, size, "demo%04d.dem", lastnum );
} }
/* /*
@@ -1391,9 +1381,7 @@ void CL_Record_f( void )
for( n = 0; n < 10000; n++ ) for( n = 0; n < 10000; n++ )
{ {
CL_DemoGetName( n, demoname, sizeof( demoname )); CL_DemoGetName( n, demoname, sizeof( demoname ));
Q_snprintf( demopath, sizeof( demopath ), "%s.dem", demoname ); if( !FS_FileExists( demoname, true ))
if( !FS_FileExists( demopath, true ))
break; break;
} }
@@ -1480,7 +1468,7 @@ void CL_PlayDemo_f( void )
{ {
int c, neg = false; int c, neg = false;
demo.header.host_fps = host_maxfps.value; demo.header.host_fps = host_maxfps->value;
while(( c = FS_Getc( cls.demofile )) != '\n' ) while(( c = FS_Getc( cls.demofile )) != '\n' )
{ {

View File

@@ -6,7 +6,7 @@
#include "r_efx.h" #include "r_efx.h"
#include "cl_tent.h" #include "cl_tent.h"
#include "pm_local.h" #include "pm_local.h"
#define PART_SIZE Q_max( 0.5f, cl_draw_particles.value ) #define PART_SIZE Q_max( 0.5f, cl_draw_particles->value )
/* /*
============================================================== ==============================================================
@@ -21,9 +21,9 @@ static int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
static int ramp3[6] = { 0x6d, 0x6b, 6, 5, 4, 3 }; static int ramp3[6] = { 0x6d, 0x6b, 6, 5, 4, 3 };
static int gSparkRamp[9] = { 0xfe, 0xfd, 0xfc, 0x6f, 0x6e, 0x6d, 0x6c, 0x67, 0x60 }; static int gSparkRamp[9] = { 0xfe, 0xfd, 0xfc, 0x6f, 0x6e, 0x6d, 0x6c, 0x67, 0x60 };
static CVAR_DEFINE_AUTO( tracerspeed, "6000", 0, "tracer speed" ); convar_t *tracerspeed;
static CVAR_DEFINE_AUTO( tracerlength, "0.8", 0, "tracer length factor" ); convar_t *tracerlength;
static CVAR_DEFINE_AUTO( traceroffset, "30", 0, "tracer starting offset" ); convar_t *traceroffset;
particle_t *cl_active_particles; particle_t *cl_active_particles;
particle_t *cl_active_tracers; particle_t *cl_active_tracers;
@@ -100,9 +100,9 @@ void CL_InitParticles( void )
cl_avelocities[i][2] = COM_RandomFloat( 0.0f, 2.55f ); cl_avelocities[i][2] = COM_RandomFloat( 0.0f, 2.55f );
} }
Cvar_RegisterVariable( &tracerspeed ); tracerspeed = Cvar_Get( "tracerspeed", "6000", 0, "tracer speed" );
Cvar_RegisterVariable( &tracerlength ); tracerlength = Cvar_Get( "tracerlength", "0.8", 0, "tracer length factor" );
Cvar_RegisterVariable( &traceroffset ); traceroffset = Cvar_Get( "traceroffset", "30", 0, "tracer starting offset" );
} }
/* /*
@@ -171,11 +171,11 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float )
{ {
particle_t *p; particle_t *p;
if( !cl_draw_particles.value ) if( !cl_draw_particles->value )
return NULL; return NULL;
// never alloc particles when we not in game // 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 ) if( !cl_free_particles )
{ {
@@ -218,15 +218,15 @@ R_AllocTracer
can return NULL if particles is out 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; particle_t *p;
if( !cl_draw_tracers.value ) if( !cl_draw_tracers->value )
return NULL; return NULL;
// never alloc particles when we not in game // 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 ) if( !cl_free_particles )
{ {
@@ -249,7 +249,7 @@ static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life
VectorCopy( org, p->org ); VectorCopy( org, p->org );
VectorCopy( vel, p->vel ); VectorCopy( vel, p->vel );
p->die = cl.time + life; p->die = cl.time + life;
p->ramp = tracerlength.value; p->ramp = tracerlength->value;
p->color = 4; // select custom color p->color = 4; // select custom color
p->packedColor = 255; // alpha p->packedColor = 255; // alpha
@@ -300,7 +300,7 @@ R_BeamAlloc
============== ==============
*/ */
static BEAM *R_BeamAlloc( void ) BEAM *R_BeamAlloc( void )
{ {
BEAM *pBeam; 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. // free particles that have died off.
R_FreeDeadParticles( &pBeam->particles ); R_FreeDeadParticles( &pBeam->particles );
@@ -605,7 +605,7 @@ CL_BeamAttemptToDie
Check for expired beams Check for expired beams
============== ==============
*/ */
static qboolean CL_BeamAttemptToDie( BEAM *pBeam ) qboolean CL_BeamAttemptToDie( BEAM *pBeam )
{ {
Assert( pBeam != NULL ); Assert( pBeam != NULL );
@@ -1236,15 +1236,12 @@ R_BloodStream
particle spray 2 particle spray 2
=============== ===============
*/ */
void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor, int speed ) void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
{ {
particle_t *p; particle_t *p;
int i, j; int i, j;
float arc; float arc;
int accel = speed; // must be integer due to bug in GoldSrc int accel = speed; // must be integer due to bug in GoldSrc
vec3_t dir;
VectorNormalize2( ndir, dir );
for( arc = 0.05f, i = 0; i < 100; i++ ) for( arc = 0.05f, i = 0; i < 100; i++ )
{ {
@@ -1807,14 +1804,14 @@ void GAME_EXPORT R_TracerEffect( const vec3_t start, const vec3_t end )
float len, speed; float len, speed;
float offset; float offset;
speed = Q_max( tracerspeed.value, 3.0f ); speed = Q_max( tracerspeed->value, 3.0f );
VectorSubtract( end, start, dir ); VectorSubtract( end, start, dir );
len = VectorLength( dir ); len = VectorLength( dir );
if( len == 0.0f ) return; if( len == 0.0f ) return;
VectorScale( dir, 1.0f / len, dir ); // normalize VectorScale( dir, 1.0f / len, dir ); // normalize
offset = COM_RandomFloat( -10.0f, 9.0f ) + traceroffset.value; offset = COM_RandomFloat( -10.0f, 9.0f ) + traceroffset->value;
VectorScale( dir, offset, vel ); VectorScale( dir, offset, vel );
VectorAdd( start, vel, pos ); VectorAdd( start, vel, pos );
VectorScale( dir, speed, vel ); VectorScale( dir, speed, vel );
@@ -2040,7 +2037,7 @@ void CL_ReadPointFile_f( void )
else Con_Printf( "map %s has no leaks!\n", clgame.mapname ); 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; BEAM *pBeam, *pNext, *pPrev = NULL;
// draw temporary entity beams // draw temporary entity beams
@@ -2070,16 +2067,16 @@ static void CL_FreeDeadBeams( void )
void CL_DrawEFX( float time, qboolean fTrans ) void CL_DrawEFX( float time, qboolean fTrans )
{ {
CL_FreeDeadBeams(); CL_FreeDeadBeams();
if( cl_draw_beams.value ) if( CVAR_TO_BOOL( cl_draw_beams ))
ref.dllFuncs.CL_DrawBeams( fTrans, cl_active_beams ); ref.dllFuncs.CL_DrawBeams( fTrans, cl_active_beams );
if( fTrans ) if( fTrans )
{ {
R_FreeDeadParticles( &cl_active_particles ); R_FreeDeadParticles( &cl_active_particles );
if( cl_draw_particles.value ) if( CVAR_TO_BOOL( cl_draw_particles ))
ref.dllFuncs.CL_DrawParticles( time, cl_active_particles, PART_SIZE ); ref.dllFuncs.CL_DrawParticles( time, cl_active_particles, PART_SIZE );
R_FreeDeadParticles( &cl_active_tracers ); R_FreeDeadParticles( &cl_active_tracers );
if( cl_draw_tracers.value ) if( CVAR_TO_BOOL( cl_draw_tracers ))
ref.dllFuncs.CL_DrawTracers( time, cl_active_tracers ); ref.dllFuncs.CL_DrawTracers( time, cl_active_tracers );
} }
} }

View File

@@ -40,7 +40,7 @@ CL_CalcPlayerVelocity
compute velocity for a given client 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; clientdata_t *pcd;
vec3_t delta; vec3_t delta;
@@ -78,13 +78,13 @@ 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; int idx = (slot & 63) * 2;
con_nprint_t info; con_nprint_t info;
string origin_str = { 0 }; //, angles_str = { 0 }; string origin_str = { 0 }; //, angles_str = { 0 };
if( !cl_showevents.value ) if( !cl_showevents->value )
return; return;
info.time_to_live = 1.0f; info.time_to_live = 1.0f;
@@ -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; cl_user_event_t *ev;
const char *name; const char *name;
@@ -225,18 +225,6 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
if( ev->index == ei->index ) if( ev->index == ei->index )
{ {
name = cl.event_precache[ei->index];
if( cl_trace_events.value )
{
Con_Printf( "^3EVENT %s AT %.2f %.2f %.2f\n" // event name
"\t%.2f %.2f %i %i %s %s\n", // bool params
name, ei->args.origin[0], ei->args.origin[1], ei->args.origin[2],
ei->args.fparam1, ei->args.fparam2,
ei->args.iparam1, ei->args.iparam2,
ei->args.bparam1 ? "TRUE" : "FALSE", ei->args.bparam2 ? "TRUE" : "FALSE" );
}
if( ev->func ) if( ev->func )
{ {
CL_DescribeEvent( ei, slot ); CL_DescribeEvent( ei, slot );
@@ -244,6 +232,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
return true; return true;
} }
name = cl.event_precache[ei->index];
Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name ); Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name );
break; break;
} }
@@ -292,7 +281,7 @@ CL_FindEvent
find first empty event find first empty event
============= =============
*/ */
static event_info_t *CL_FindEmptyEvent( void ) event_info_t *CL_FindEmptyEvent( void )
{ {
int i; int i;
event_state_t *es; event_state_t *es;
@@ -320,7 +309,7 @@ CL_FindEvent
replace only unreliable events replace only unreliable events
============= =============
*/ */
static event_info_t *CL_FindUnreliableEvent( void ) event_info_t *CL_FindUnreliableEvent( void )
{ {
event_state_t *es; event_state_t *es;
event_info_t *ei; event_info_t *ei;
@@ -350,7 +339,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; event_info_t *ei;

View File

@@ -46,35 +46,10 @@ static int CL_LoadFontTexture( const char *fontname, uint texFlags, int *width )
return tex; return tex;
} }
static int CL_FontRenderMode( convar_t *fontrender ) qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags )
{
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 )
{ {
int font_width, i; int font_width, i;
if( !rendermode )
return false;
if( font->valid ) if( font->valid )
return true; // already loaded 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->type = FONT_FIXED;
font->valid = true; font->valid = true;
font->scale = scale; font->scale = scale;
font->nearest = FBitSet( texFlags, TF_NEAREST );
font->rendermode = rendermode; font->rendermode = rendermode;
font->charHeight = Q_rint( font_width / 16 * scale ); 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; 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; fs_offset_t length;
qfont_t src; qfont_t src;
byte *pfile; byte *pfile;
int font_width, i; int font_width, i;
if( !rendermode )
return false;
if( font->valid ) if( font->valid )
return true; return true;
@@ -133,7 +106,8 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
font->type = FONT_VARIABLE; font->type = FONT_VARIABLE;
font->valid = true; font->valid = true;
font->scale = scale ? scale : 1.0f; font->scale = scale;
font->nearest = FBitSet( texFlags, TF_NEAREST );
font->rendermode = rendermode; font->rendermode = rendermode;
font->charHeight = Q_rint( src.rowheight * scale ); 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]; return font->charWidths[number];
rc = &font->fontRc[number]; rc = &font->fontRc[number];
if( font->nearest || font->scale <= 1.0f )
if( font->scale <= 1.f || !REF_GET_PARM( PARM_TEX_FILTERING, font->hFontTexture ))
half = 0; half = 0;
s1 = ((float)rc->left + half ) / texw; 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 ); SPR_AdjustSize( &x, &y, &w, &h );
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE )) 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 // 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 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 Con_UtfProcessChar( 0 ); // clear utf state
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE )) if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
CL_SetFontRendermode( font ); ref.dllFuncs.GL_SetRenderMode( font->rendermode );
Vector4Copy( color, current_color ); Vector4Copy( color, current_color );

View File

@@ -24,7 +24,7 @@ GNU General Public License for more details.
#include "sound.h" #include "sound.h"
#include "input.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 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; position_history_t *ph;
prev = &ent->ph[ent->current_position];
ent->current_position = (ent->current_position + 1) & HISTORY_MASK; ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
ph = &ent->ph[ent->current_position]; ph = &ent->ph[ent->current_position];
VectorCopy( ent->curstate.origin, ph->origin ); VectorCopy( ent->curstate.origin, ph->origin );
VectorCopy( ent->curstate.angles, ph->angles ); VectorCopy( ent->curstate.angles, ph->angles );
if( ent->model && ent->model->type == mod_brush )
ph->animtime = ent->curstate.animtime; ph->animtime = ent->curstate.animtime;
else
// a1ba: for some reason, this sometimes still may happen ph->animtime = cl.time;
// 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;
}
} }
/* /*
@@ -85,7 +74,7 @@ CL_ResetPositions
Interpolation init or reset after teleporting 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; position_history_t store;
@@ -107,7 +96,7 @@ check for instant movement in case
we don't want interpolate this we don't want interpolate this
================== ==================
*/ */
static qboolean CL_EntityTeleported( cl_entity_t *ent ) qboolean CL_EntityTeleported( cl_entity_t *ent )
{ {
float len, maxlen; float len, maxlen;
vec3_t delta; vec3_t delta;
@@ -128,7 +117,7 @@ CL_CompareTimestamps
round-off floating errors round-off floating errors
================== ==================
*/ */
static qboolean CL_CompareTimestamps( float t1, float t2 ) qboolean CL_CompareTimestamps( float t1, float t2 )
{ {
int iTime1 = t1 * 1000; int iTime1 = t1 * 1000;
int iTime2 = t2 * 1000; int iTime2 = t2 * 1000;
@@ -143,9 +132,9 @@ CL_EntityIgnoreLerp
some ents will be ignore lerping 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 ) if( cl_nointerp->value > 0.f )
return true; return true;
if( e->model && e->model->type == mod_alias ) if( e->model && e->model->type == mod_alias )
@@ -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 ) switch( e->curstate.movetype )
{ {
@@ -170,13 +159,6 @@ static qboolean CL_EntityCustomLerp( cl_entity_t *e )
case MOVETYPE_FLY: case MOVETYPE_FLY:
case MOVETYPE_COMPOUND: case MOVETYPE_COMPOUND:
return false; 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; return true;
@@ -189,7 +171,7 @@ CL_ParametricMove
check for parametrical moved entities check for parametrical moved entities
================== ==================
*/ */
static qboolean CL_ParametricMove( cl_entity_t *ent ) qboolean CL_ParametricMove( cl_entity_t *ent )
{ {
float frac, dt, t; float frac, dt, t;
vec3_t delta; 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 )) if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio ))
return; // below fields used only for alias and studio interpolation return; // below fields used only for alias and studio interpolation
@@ -321,7 +303,7 @@ CL_ProcessEntityUpdate
apply changes since new frame received apply changes since new frame received
================== ==================
*/ */
static void CL_ProcessEntityUpdate( cl_entity_t *ent ) void CL_ProcessEntityUpdate( cl_entity_t *ent )
{ {
qboolean parametric; qboolean parametric;
@@ -367,10 +349,11 @@ CL_FindInterpolationUpdates
find two timestamps 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; qboolean extrapolate = true;
uint i, i0, i1, imod; uint i, i0, i1, imod;
float at;
imod = ent->current_position; imod = ent->current_position;
i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end) 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++ ) for( i = 1; i < HISTORY_MAX - 1; i++ )
{ {
double at = ent->ph[( imod - i ) & HISTORY_MASK].animtime; at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
if( at == 0.0f ) break;
if( at == 0.0f )
break;
if( targettime > at ) if( targettime > at )
{ {
@@ -406,14 +387,15 @@ CL_PureOrigin
non-local players interpolation 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; position_history_t *ph0, *ph1;
vec3_t delta; vec3_t delta;
// NOTE: ph0 is next, ph1 is a prev // NOTE: ph0 is next, ph1 is a prev
CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 ); extrapolate = CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
if ( !ph0 || !ph1 ) if ( !ph0 || !ph1 )
return; return;
@@ -421,7 +403,7 @@ static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t
t0 = ph0->animtime; t0 = ph0->animtime;
t1 = ph1->animtime; t1 = ph1->animtime;
if( t0 != 0.0 ) if( t0 != 0.0f )
{ {
vec4_t q, q1, q2; 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 )) if( !Q_equal( t0, t1 ))
frac = ( t - t1 ) / ( 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 ); VectorMA( ph1->origin, frac, delta, outorigin );
@@ -455,11 +437,11 @@ CL_InterpolateModel
non-players interpolation 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; position_history_t *ph0 = NULL, *ph1 = NULL;
vec3_t origin, angles, delta; vec3_t origin, angles, delta;
double t, t1, t2, frac; float t, t1, t2, frac;
vec4_t q, q1, q2; vec4_t q, q1, q2;
VectorCopy( e->curstate.origin, e->origin ); VectorCopy( e->curstate.origin, e->origin );
@@ -482,13 +464,13 @@ static int CL_InterpolateModel( cl_entity_t *e )
if( cl.maxclients <= 1 ) if( cl.maxclients <= 1 )
return 1; return 1;
if( e->model->type == mod_brush && !cl_bmodelinterp.value ) if( e->model->type == mod_brush && !cl_bmodelinterp->value )
return 1; return 1;
if( cl.local.moving && cl.local.onground == e->index ) if( cl.local.moving && cl.local.onground == e->index )
return 1; return 1;
t = cl.time - cl_interp.value; t = cl.time - cl_interp->value;
CL_FindInterpolationUpdates( e, t, &ph0, &ph1 ); CL_FindInterpolationUpdates( e, t, &ph0, &ph1 );
if( ph0 == NULL || ph1 == NULL ) if( ph0 == NULL || ph1 == NULL )
@@ -507,7 +489,9 @@ static int CL_InterpolateModel( cl_entity_t *e )
return 0; 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->origin, e->origin );
VectorCopy( ph0->angles, e->angles ); VectorCopy( ph0->angles, e->angles );
@@ -545,7 +529,7 @@ interpolate non-local clients
*/ */
void CL_ComputePlayerOrigin( cl_entity_t *ent ) void CL_ComputePlayerOrigin( cl_entity_t *ent )
{ {
double targettime; float targettime;
vec4_t q, q1, q2; vec4_t q, q1, q2;
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
@@ -553,7 +537,7 @@ void CL_ComputePlayerOrigin( cl_entity_t *ent )
if( !ent->player ) if( !ent->player )
return; return;
if( cl_nointerp.value > 0.f ) if( cl_nointerp->value > 0.f )
{ {
VectorCopy( ent->curstate.angles, ent->angles ); VectorCopy( ent->curstate.angles, ent->angles );
VectorCopy( ent->curstate.origin, ent->origin ); VectorCopy( ent->curstate.origin, ent->origin );
@@ -571,7 +555,7 @@ void CL_ComputePlayerOrigin( cl_entity_t *ent )
return; return;
} }
targettime = cl.time - cl_interp.value; targettime = cl.time - cl_interp->value;
CL_PureOrigin( ent, targettime, origin, angles ); CL_PureOrigin( ent, targettime, origin, angles );
VectorCopy( angles, ent->angles ); VectorCopy( angles, ent->angles );
@@ -585,7 +569,7 @@ CL_ProcessPlayerState
process player states after the new packet has received 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; entity_state_t *ps;
@@ -605,7 +589,7 @@ reset latched state if this frame entity was teleported
or just EF_NOINTERP was set 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 )) if( CHECKVISBIT( frame->flags, pnum ))
{ {
@@ -695,7 +679,7 @@ CL_FlushEntityPacket
Read and ignore whole entity packet. Read and ignore whole entity packet.
================= =================
*/ */
static void CL_FlushEntityPacket( sizebuf_t *msg ) void CL_FlushEntityPacket( sizebuf_t *msg )
{ {
int newnum; int newnum;
entity_state_t from, to; entity_state_t from, to;
@@ -725,7 +709,7 @@ CL_DeltaEntity
processing delta update 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; cl_entity_t *ent;
entity_state_t *state; entity_state_t *state;
@@ -1057,7 +1041,7 @@ CL_LinkCustomEntity
Add server beam to draw list 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; // !!! ent->curstate.movetype = state->modelindex; // !!!
@@ -1080,7 +1064,7 @@ Create visible entities in the correct position
for all current players for all current players
============= =============
*/ */
static void CL_LinkPlayers( frame_t *frame ) void CL_LinkPlayers( frame_t *frame )
{ {
entity_state_t *state; entity_state_t *state;
cl_entity_t *ent; 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; cl_entity_t *ent;
entity_state_t *state; entity_state_t *state;
@@ -1228,34 +1212,18 @@ static void CL_LinkPacketEntities( frame_t *frame )
#else #else
if( ent->lastmove >= cl.time ) if( ent->lastmove >= cl.time )
{ {
float at = ent->curstate.animtime;
CL_ResetLatchedVars( ent, true ); 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.origin, ent->latched.prevorigin );
VectorCopy( ent->curstate.angles, ent->latched.prevangles ); VectorCopy( ent->curstate.angles, ent->latched.prevangles );
if( !FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
{
// disable step interpolation in client.dll // disable step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_NONE; ent->curstate.movetype = MOVETYPE_NONE;
} }
}
else
{
if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
{
interpolate = true;
}
else else
{ {
// restore step interpolation in client.dll // restore step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_STEP; ent->curstate.movetype = MOVETYPE_STEP;
} }
}
#endif #endif
} }
} }
@@ -1279,24 +1247,11 @@ static void CL_LinkPacketEntities( frame_t *frame )
if ( !CL_InterpolateModel( ent )) if ( !CL_InterpolateModel( ent ))
continue; continue;
} }
// a1ba: in GoldSrc this is done for cstrike and czero else if( ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address ))
// 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 ))
{ {
if( !CL_InterpolateModel( ent )) if( !CL_InterpolateModel( ent ))
continue; 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 else
{ {
// no interpolation right now // no interpolation right now
@@ -1492,3 +1447,9 @@ qboolean CL_GetMovieSpatialization( rawchan_t *ch )
return true; return true;
} }
void CL_ExtraUpdate( void )
{
clgame.dllFuncs.IN_Accumulate();
S_ExtraUpdate();
}

View File

@@ -154,7 +154,7 @@ CL_CreatePlaylist
Create a default valve playlist Create a default valve playlist
==================== ====================
*/ */
static void CL_CreatePlaylist( const char *filename ) void CL_CreatePlaylist( const char *filename )
{ {
file_t *f; file_t *f;
@@ -357,9 +357,7 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h )
*h *= yscale; *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 )
{ {
@@ -374,7 +372,6 @@ static void SPR_AdjustTexCoords( int texnum, float width, float height, float *s
*t1 += 0.5f; *t1 += 0.5f;
*t2 -= 0.5f; *t2 -= 0.5f;
} }
}
*s1 /= width; *s1 /= width;
*t1 /= height; *t1 /= height;
@@ -405,8 +402,6 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
height = h; height = h;
} }
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
if( prc ) if( prc )
{ {
wrect_t rc = *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; t2 = rc.bottom;
// calc user-defined rectangle // 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; width = rc.right - rc.left;
height = rc.bottom - rc.top; 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 // scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height ); 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.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 ); ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum );
} }
@@ -462,7 +458,7 @@ void CL_DrawCenterPrint( void )
if( !clgame.centerPrint.time ) if( !clgame.centerPrint.time )
return; return;
if(( cl.time - clgame.centerPrint.time ) >= scr_centertime.value ) if(( cl.time - clgame.centerPrint.time ) >= scr_centertime->value )
{ {
// time expired // time expired
clgame.centerPrint.time = 0.0f; clgame.centerPrint.time = 0.0f;
@@ -474,7 +470,8 @@ void CL_DrawCenterPrint( void )
pText = clgame.centerPrint.message; pText = clgame.centerPrint.message;
CL_DrawCharacterLen( font, 0, NULL, &charHeight ); CL_DrawCharacterLen( font, 0, NULL, &charHeight );
CL_SetFontRendermode( font );
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
for( i = 0; i < clgame.centerPrint.lines; i++ ) for( i = 0; i < clgame.centerPrint.lines; i++ )
{ {
lineLength = 0; lineLength = 0;
@@ -550,7 +547,7 @@ fill screen with specfied color
can be modulated can be modulated
============= =============
*/ */
static void CL_DrawScreenFade( void ) void CL_DrawScreenFade( void )
{ {
screenfade_t *sf = &clgame.fade; screenfade_t *sf = &clgame.fade;
int alpha; int alpha;
@@ -668,12 +665,12 @@ void CL_ParseTextMessage( sizebuf_t *msg )
text->g2 = MSG_ReadByte( msg ); text->g2 = MSG_ReadByte( msg );
text->b2 = MSG_ReadByte( msg ); text->b2 = MSG_ReadByte( msg );
text->a2 = MSG_ReadByte( msg ); text->a2 = MSG_ReadByte( msg );
text->fadein = (float)(MSG_ReadWord( msg ) / 256.0f ); text->fadein = (float)(MSG_ReadShort( msg ) / 256.0f );
text->fadeout = (float)(MSG_ReadWord( msg ) / 256.0f ); text->fadeout = (float)(MSG_ReadShort( msg ) / 256.0f );
text->holdtime = (float)(MSG_ReadWord( msg ) / 256.0f ); text->holdtime = (float)(MSG_ReadShort( msg ) / 256.0f );
if( text->effect == 2 ) if( text->effect == 2 )
text->fxtime = (float)(MSG_ReadWord( msg ) / 256.0f ); text->fxtime = (float)(MSG_ReadShort( msg ) / 256.0f );
else text->fxtime = 0.0f; else text->fxtime = 0.0f;
// to prevent grab too long messages // to prevent grab too long messages
@@ -766,7 +763,7 @@ CL_SoundFromIndex
return soundname from index return soundname from index
==================== ====================
*/ */
static const char *CL_SoundFromIndex( int index ) const char *CL_SoundFromIndex( int index )
{ {
sfx_t *sfx = NULL; sfx_t *sfx = NULL;
int hSound; int hSound;
@@ -912,12 +909,12 @@ CL_DrawCrosshair
Render crosshair Render crosshair
==================== ====================
*/ */
static void CL_DrawCrosshair( void ) void CL_DrawCrosshair( void )
{ {
int x, y, width, height; int x, y, width, height;
float xscale, yscale; float xscale, yscale;
if( !clgame.ds.pCrosshair || !cl_crosshair.value ) if( !clgame.ds.pCrosshair || !cl_crosshair->value )
return; return;
// any camera on or client is died // any camera on or client is died
@@ -1091,13 +1088,13 @@ void CL_ClearWorld( void )
clgame.numStatics = 0; clgame.numStatics = 0;
} }
void CL_InitEdicts( int maxclients ) void CL_InitEdicts( void )
{ {
Assert( clgame.entities == NULL ); Assert( clgame.entities == NULL );
if( !clgame.mempool ) return; // Host_Error without client if( !clgame.mempool ) return; // Host_Error without client
#if XASH_LOW_MEMORY != 2 #if XASH_LOW_MEMORY != 2
CL_UPDATE_BACKUP = ( maxclients <= 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP; CL_UPDATE_BACKUP = ( cl.maxclients <= 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP;
#endif #endif
cls.num_client_entities = CL_UPDATE_BACKUP * NUM_PACKET_ENTITIES; cls.num_client_entities = CL_UPDATE_BACKUP * NUM_PACKET_ENTITIES;
cls.packet_entities = Mem_Realloc( clgame.mempool, cls.packet_entities, sizeof( entity_state_t ) * cls.num_client_entities ); cls.packet_entities = Mem_Realloc( clgame.mempool, cls.packet_entities, sizeof( entity_state_t ) * cls.num_client_entities );
@@ -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 ); 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 ) void CL_FreeEdicts( void )
{ {
ref.dllFuncs.R_ProcessEntData( false, NULL, 0 ); ref.dllFuncs.R_ProcessEntData( false );
if( clgame.entities ) if( clgame.entities )
Mem_Free( clgame.entities ); Mem_Free( clgame.entities );
@@ -1143,7 +1140,7 @@ void CL_ClearEdicts( void )
// in case we stopped with error // in case we stopped with error
clgame.maxEntities = 2; clgame.maxEntities = 2;
CL_InitEdicts( cl.maxclients ); CL_InitEdicts();
} }
/* /*
@@ -1238,7 +1235,11 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
{ {
char name[MAX_QPATH]; char name[MAX_QPATH];
model_t *mod; 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 )) if( !COM_CheckString( filename ))
{ {
@@ -1249,7 +1250,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
Q_strncpy( name, filename, sizeof( name )); Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( 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 )) 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 // find a free model slot spot
// use low indices only for HUD sprites for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
// for GoldSrc bug compatibility if( !mod->name[0] ) break; // this is a valid spot
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
}
if( i == MAX_CLIENT_SPRITES / 2 ) if( i == MAX_CLIENT_SPRITES / 2 )
{ {
@@ -1326,10 +1320,8 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
========= =========
pfnSPR_Load pfnSPR_Load
function exported for support GoldSrc Monitor utility
========= =========
*/ */
HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
HSPRITE EXPORT pfnSPR_Load( const char *szPicName ) HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
{ {
model_t *spr; model_t *spr;
@@ -1346,7 +1338,7 @@ CL_GetSpritePointer
============= =============
*/ */
static const model_t *CL_GetSpritePointer( HSPRITE hSprite ) const model_t *CL_GetSpritePointer( HSPRITE hSprite )
{ {
model_t *mod; model_t *mod;
int index = hSprite - 1; int index = hSprite - 1;
@@ -1376,10 +1368,8 @@ static const model_t *CL_GetSpritePointer( HSPRITE hSprite )
========= =========
pfnSPR_Frames pfnSPR_Frames
function exported for support GoldSrc Monitor utility
========= =========
*/ */
int EXPORT pfnSPR_Frames( HSPRITE hPic );
int EXPORT pfnSPR_Frames( HSPRITE hPic ) int EXPORT pfnSPR_Frames( HSPRITE hPic )
{ {
int numFrames = 0; int numFrames = 0;
@@ -1598,7 +1588,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; float _x = x, _y = y, _w = w, _h = h;
@@ -1640,15 +1630,14 @@ get actual screen info
*/ */
int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo ) int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
{ {
qboolean apply_scale_factor = false; float scale_factor = hud_scale->value;
float scale_factor = hud_scale.value;
if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED )) if( FBitSet( hud_fontscale->flags, FCVAR_CHANGED ))
{ {
CL_FreeFont( &cls.creditsFont ); CL_FreeFont( &cls.creditsFont );
SCR_LoadCreditsFont(); SCR_LoadCreditsFont();
ClearBits( hud_fontscale.flags, FCVAR_CHANGED ); ClearBits( hud_fontscale->flags, FCVAR_CHANGED );
} }
// setup screen info // setup screen info
@@ -1656,23 +1645,16 @@ int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH; clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH;
if( scale_factor && scale_factor != 1.0f) 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 )
{ {
clgame.scrInfo.iWidth = (float)refState.width / scale_factor; clgame.scrInfo.iWidth = (float)refState.width / scale_factor;
clgame.scrInfo.iHeight = (float)refState.height / scale_factor; clgame.scrInfo.iHeight = (float)refState.height / scale_factor;
SetBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED ); clgame.scrInfo.iFlags |= SCRINFO_STRETCHED;
} }
else else
{ {
clgame.scrInfo.iWidth = refState.width; clgame.scrInfo.iWidth = refState.width;
clgame.scrInfo.iHeight = refState.height; clgame.scrInfo.iHeight = refState.height;
ClearBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED ); clgame.scrInfo.iFlags &= ~SCRINFO_STRETCHED;
} }
if( !pscrinfo ) return 0; if( !pscrinfo ) return 0;
@@ -1703,22 +1685,6 @@ static void GAME_EXPORT pfnSetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g,
clgame.ds.rcCrosshair = rc; clgame.ds.rcCrosshair = rc;
} }
/*
=============
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" ))
flags |= FCVAR_PRIVILEGED;
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
}
/* /*
============= =============
pfnHookUserMsg pfnHookUserMsg
@@ -1923,7 +1889,7 @@ static int GAME_EXPORT pfnDrawCharacter( int x, int y, int number, int r, int g,
rgba_t color = { r, g, b, 255 }; rgba_t color = { r, g, b, 255 };
int flags = FONT_DRAW_HUD; int flags = FONT_DRAW_HUD;
if( hud_utf8.value ) if( hud_utf8->value )
flags |= FONT_DRAW_UTF8; flags |= FONT_DRAW_UTF8;
return CL_DrawCharacter( x, y, number, color, &cls.creditsFont, flags ); return CL_DrawCharacter( x, y, number, color, &cls.creditsFont, flags );
@@ -1938,7 +1904,7 @@ drawing string like a console string
*/ */
int GAME_EXPORT pfnDrawConsoleString( int x, int y, char *string ) int GAME_EXPORT pfnDrawConsoleString( int x, int y, char *string )
{ {
cl_font_t *font = Con_GetFont( con_fontsize.value ); cl_font_t *font = Con_GetFont( con_fontsize->value );
rgba_t color; rgba_t color;
Vector4Copy( clgame.ds.textColor, color ); Vector4Copy( clgame.ds.textColor, color );
Vector4Set( clgame.ds.textColor, 255, 255, 255, 255 ); Vector4Set( clgame.ds.textColor, 255, 255, 255, 255 );
@@ -1971,7 +1937,7 @@ compute string length in screen pixels
*/ */
void GAME_EXPORT pfnDrawConsoleStringLen( const char *pText, int *length, int *height ) void GAME_EXPORT pfnDrawConsoleStringLen( const char *pText, int *length, int *height )
{ {
cl_font_t *font = Con_GetFont( con_fontsize.value ); cl_font_t *font = Con_GetFont( con_fontsize->value );
if( height ) *height = font->charHeight; if( height ) *height = font->charHeight;
CL_DrawStringLen( font, pText, length, NULL, FONT_DRAW_UTF8 | FONT_DRAW_HUD ); CL_DrawStringLen( font, pText, length, NULL, FONT_DRAW_UTF8 | FONT_DRAW_HUD );
@@ -2019,7 +1985,7 @@ static int GAME_EXPORT pfnGetWindowCenterX( void )
{ {
int x = 0; int x = 0;
#if XASH_WIN32 #if XASH_WIN32
if( m_ignore.value ) if( m_ignore->value )
{ {
POINT pos; POINT pos;
GetCursorPos( &pos ); GetCursorPos( &pos );
@@ -2044,7 +2010,7 @@ static int GAME_EXPORT pfnGetWindowCenterY( void )
{ {
int y = 0; int y = 0;
#if XASH_WIN32 #if XASH_WIN32
if( m_ignore.value ) if( m_ignore->value )
{ {
POINT pos; POINT pos;
GetCursorPos( &pos ); GetCursorPos( &pos );
@@ -2134,7 +2100,7 @@ pfnGetViewModel
============= =============
*/ */
static cl_entity_t* GAME_EXPORT CL_GetViewModel( void ) cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
{ {
return &clgame.viewent; return &clgame.viewent;
} }
@@ -2156,7 +2122,7 @@ pfnCalcShake
============= =============
*/ */
static void GAME_EXPORT pfnCalcShake( void ) void GAME_EXPORT pfnCalcShake( void )
{ {
screen_shake_t *const shake = &clgame.shake; screen_shake_t *const shake = &clgame.shake;
float frametime, fraction, freq; float frametime, fraction, freq;
@@ -2212,7 +2178,7 @@ pfnApplyShake
============= =============
*/ */
static void GAME_EXPORT pfnApplyShake( float *origin, float *angles, float factor ) void GAME_EXPORT pfnApplyShake( float *origin, float *angles, float factor )
{ {
if( origin ) if( origin )
VectorMA( origin, factor, clgame.shake.applied_offset, origin ); VectorMA( origin, factor, clgame.shake.applied_offset, origin );
@@ -2340,7 +2306,7 @@ pfnPlaySound
============= =============
*/ */
static void GAME_EXPORT pfnPlaySound( int ent, float *org, int chan, const char *samp, float vol, float attn, int flags, int pitch ) void GAME_EXPORT pfnPlaySound( int ent, float *org, int chan, const char *samp, float vol, float attn, int flags, int pitch )
{ {
S_StartSound( org, ent, chan, S_RegisterSound( samp ), vol, attn, pitch, flags ); S_StartSound( org, ent, chan, S_RegisterSound( samp ), vol, attn, pitch, flags );
} }
@@ -2351,7 +2317,7 @@ CL_FindModelIndex
============= =============
*/ */
static int GAME_EXPORT CL_FindModelIndex( const char *m ) int GAME_EXPORT CL_FindModelIndex( const char *m )
{ {
char filepath[MAX_QPATH]; char filepath[MAX_QPATH];
static float lasttimewarn; static float lasttimewarn;
@@ -2388,7 +2354,7 @@ pfnIsLocal
============= =============
*/ */
static int GAME_EXPORT pfnIsLocal( int playernum ) int GAME_EXPORT pfnIsLocal( int playernum )
{ {
if( playernum == cl.playernum ) if( playernum == cl.playernum )
return true; return true;
@@ -2401,7 +2367,7 @@ pfnLocalPlayerDucking
============= =============
*/ */
static int GAME_EXPORT pfnLocalPlayerDucking( void ) int GAME_EXPORT pfnLocalPlayerDucking( void )
{ {
return (cl.local.usehull == 1) ? true : false; return (cl.local.usehull == 1) ? true : false;
} }
@@ -2412,7 +2378,7 @@ pfnLocalPlayerViewheight
============= =============
*/ */
static void GAME_EXPORT pfnLocalPlayerViewheight( float *view_ofs ) void GAME_EXPORT pfnLocalPlayerViewheight( float *view_ofs )
{ {
if( view_ofs ) VectorCopy( cl.viewheight, view_ofs ); if( view_ofs ) VectorCopy( cl.viewheight, view_ofs );
} }
@@ -2423,7 +2389,7 @@ pfnLocalPlayerBounds
============= =============
*/ */
static void GAME_EXPORT pfnLocalPlayerBounds( int hull, float *mins, float *maxs ) void GAME_EXPORT pfnLocalPlayerBounds( int hull, float *mins, float *maxs )
{ {
if( hull >= 0 && hull < 4 ) if( hull >= 0 && hull < 4 )
{ {
@@ -2438,7 +2404,7 @@ pfnIndexFromTrace
============= =============
*/ */
static int GAME_EXPORT pfnIndexFromTrace( struct pmtrace_s *pTrace ) int GAME_EXPORT pfnIndexFromTrace( struct pmtrace_s *pTrace )
{ {
#if 0 // Velaron: breaks compatibility with mods that call the function after CL_PopPMStates #if 0 // Velaron: breaks compatibility with mods that call the function after CL_PopPMStates
if( pTrace->ent >= 0 && pTrace->ent < clgame.pmove->numphysent ) if( pTrace->ent >= 0 && pTrace->ent < clgame.pmove->numphysent )
@@ -2473,7 +2439,7 @@ pfnGetVisent
============= =============
*/ */
static physent_t *pfnGetVisent( int idx ) physent_t *pfnGetVisent( int idx )
{ {
if( idx >= 0 && idx < clgame.pmove->numvisent ) if( idx >= 0 && idx < clgame.pmove->numvisent )
{ {
@@ -2483,43 +2449,13 @@ static physent_t *pfnGetVisent( int idx )
return NULL; 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 pfnSetTraceHull
============= =============
*/ */
static void GAME_EXPORT CL_SetTraceHull( int hull ) void GAME_EXPORT CL_SetTraceHull( int hull )
{ {
clgame.pmove->usehull = bound( 0, hull, 3 ); clgame.pmove->usehull = bound( 0, hull, 3 );
} }
@@ -2530,7 +2466,7 @@ pfnPlayerTrace
============= =============
*/ */
static void GAME_EXPORT CL_PlayerTrace( float *start, float *end, int traceFlags, int ignore_pe, pmtrace_t *tr ) void GAME_EXPORT CL_PlayerTrace( float *start, float *end, int traceFlags, int ignore_pe, pmtrace_t *tr )
{ {
if( !tr ) return; if( !tr ) return;
*tr = PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, ignore_pe, NULL ); *tr = PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, ignore_pe, NULL );
@@ -2542,7 +2478,7 @@ pfnPlayerTraceExt
============= =============
*/ */
static void GAME_EXPORT CL_PlayerTraceExt( float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ), pmtrace_t *tr ) void GAME_EXPORT CL_PlayerTraceExt( float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ), pmtrace_t *tr )
{ {
if( !tr ) return; if( !tr ) return;
*tr = PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, -1, pfnIgnore ); *tr = PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, -1, pfnIgnore );
@@ -2587,7 +2523,7 @@ pfnStopAllSounds
============= =============
*/ */
static void GAME_EXPORT pfnStopAllSounds( int ent, int entchannel ) void GAME_EXPORT pfnStopAllSounds( int ent, int entchannel )
{ {
S_StopSound( ent, entchannel, NULL ); S_StopSound( ent, entchannel, NULL );
} }
@@ -2612,7 +2548,7 @@ model_t *CL_LoadModel( const char *modelname, int *index )
return CL_ModelHandle( i ); return CL_ModelHandle( i );
} }
static int GAME_EXPORT CL_AddEntity( int entityType, cl_entity_t *pEnt ) int GAME_EXPORT CL_AddEntity( int entityType, cl_entity_t *pEnt )
{ {
if( !pEnt ) return false; if( !pEnt ) return false;
@@ -2629,7 +2565,7 @@ pfnGetGameDirectory
============= =============
*/ */
static const char *pfnGetGameDirectory( void ) const char *pfnGetGameDirectory( void )
{ {
static char szGetGameDir[MAX_SYSPATH]; static char szGetGameDir[MAX_SYSPATH];
@@ -2643,7 +2579,7 @@ Key_LookupBinding
============= =============
*/ */
static const char *Key_LookupBinding( const char *pBinding ) const char *Key_LookupBinding( const char *pBinding )
{ {
return Key_KeynumToString( Key_GetKey( pBinding )); return Key_KeynumToString( Key_GetKey( pBinding ));
} }
@@ -2674,7 +2610,7 @@ pfnGetScreenFade
============= =============
*/ */
static void GAME_EXPORT pfnGetScreenFade( struct screenfade_s *fade ) void GAME_EXPORT pfnGetScreenFade( struct screenfade_s *fade )
{ {
if( fade ) *fade = clgame.fade; if( fade ) *fade = clgame.fade;
} }
@@ -2696,7 +2632,7 @@ pfnLoadMapSprite
============= =============
*/ */
static model_t *pfnLoadMapSprite( const char *filename ) model_t *pfnLoadMapSprite( const char *filename )
{ {
model_t *mod; model_t *mod;
@@ -2708,55 +2644,13 @@ static model_t *pfnLoadMapSprite( const char *filename )
return NULL; 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 PlayerInfo_ValueForKey
============= =============
*/ */
static const char *PlayerInfo_ValueForKey( int playerNum, const char *key ) const char *PlayerInfo_ValueForKey( int playerNum, const char *key )
{ {
// find the player // find the player
if(( playerNum > cl.maxclients ) || ( playerNum < 1 )) if(( playerNum > cl.maxclients ) || ( playerNum < 1 ))
@@ -2774,7 +2668,7 @@ PlayerInfo_SetValueForKey
============= =============
*/ */
static void GAME_EXPORT PlayerInfo_SetValueForKey( const char *key, const char *value ) void GAME_EXPORT PlayerInfo_SetValueForKey( const char *key, const char *value )
{ {
convar_t *var; convar_t *var;
@@ -2800,7 +2694,7 @@ pfnGetPlayerUniqueID
============= =============
*/ */
static qboolean GAME_EXPORT pfnGetPlayerUniqueID( int iPlayer, char playerID[16] ) qboolean GAME_EXPORT pfnGetPlayerUniqueID( int iPlayer, char playerID[16] )
{ {
if( iPlayer < 1 || iPlayer > cl.maxclients ) if( iPlayer < 1 || iPlayer > cl.maxclients )
return false; return false;
@@ -2820,7 +2714,7 @@ pfnGetTrackerIDForPlayer
obsolete, unused obsolete, unused
============= =============
*/ */
static int GAME_EXPORT pfnGetTrackerIDForPlayer( int playerSlot ) int GAME_EXPORT pfnGetTrackerIDForPlayer( int playerSlot )
{ {
return 0; return 0;
} }
@@ -2832,7 +2726,7 @@ pfnGetPlayerForTrackerID
obsolete, unused obsolete, unused
============= =============
*/ */
static int GAME_EXPORT pfnGetPlayerForTrackerID( int trackerID ) int GAME_EXPORT pfnGetPlayerForTrackerID( int trackerID )
{ {
return 0; return 0;
} }
@@ -2843,7 +2737,7 @@ pfnServerCmdUnreliable
============= =============
*/ */
static int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString ) int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString )
{ {
if( !COM_CheckString( szCmdString )) if( !COM_CheckString( szCmdString ))
return 0; return 0;
@@ -2860,7 +2754,7 @@ pfnGetMousePos
============= =============
*/ */
static void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt ) void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt )
{ {
if( !ppt ) if( !ppt )
return; return;
@@ -2875,7 +2769,7 @@ pfnSetMouseEnable
legacy of dinput code legacy of dinput code
============= =============
*/ */
static void GAME_EXPORT pfnSetMouseEnable( qboolean fEnable ) void GAME_EXPORT pfnSetMouseEnable( qboolean fEnable )
{ {
} }
@@ -2994,7 +2888,7 @@ static int GAME_EXPORT pfnDrawString( int x, int y, const char *str, int r, int
rgba_t color = { r, g, b, 255 }; rgba_t color = { r, g, b, 255 };
int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF; int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF;
if( hud_utf8.value ) if( hud_utf8->value )
SetBits( flags, FONT_DRAW_UTF8 ); SetBits( flags, FONT_DRAW_UTF8 );
return CL_DrawString( x, y, str, color, &cls.creditsFont, flags ); return CL_DrawString( x, y, str, color, &cls.creditsFont, flags );
@@ -3012,7 +2906,7 @@ static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int
int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF; int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF;
int width; int width;
if( hud_utf8.value ) if( hud_utf8->value )
SetBits( flags, FONT_DRAW_UTF8 ); SetBits( flags, FONT_DRAW_UTF8 );
CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags ); CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags );
@@ -3089,7 +2983,7 @@ pfnFillRGBABlend
============= =============
*/ */
static void GAME_EXPORT CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int b, int a ) void GAME_EXPORT CL_FillRGBABlend( 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; float _x = x, _y = y, _w = w, _h = h;
@@ -3151,7 +3045,7 @@ pfnParseFile
handle colon separately handle colon separately
============= =============
*/ */
static char *pfnParseFile( char *data, char *token ) char *pfnParseFile( char *data, char *token )
{ {
return COM_ParseFileSafe( data, token, PFILE_TOKEN_MAX_LENGTH, PFILE_HANDLECOLON, NULL, NULL ); return COM_ParseFileSafe( data, token, PFILE_TOKEN_MAX_LENGTH, PFILE_HANDLECOLON, NULL, NULL );
} }
@@ -3372,7 +3266,7 @@ NetAPI_InitNetworking
================= =================
*/ */
static void GAME_EXPORT NetAPI_InitNetworking( void ) void GAME_EXPORT NetAPI_InitNetworking( void )
{ {
NET_Config( true, false ); // allow remote NET_Config( true, false ); // allow remote
} }
@@ -3383,7 +3277,7 @@ NetAPI_InitNetworking
================= =================
*/ */
static void GAME_EXPORT NetAPI_Status( net_status_t *status ) void GAME_EXPORT NetAPI_Status( net_status_t *status )
{ {
qboolean connected = false; qboolean connected = false;
int packet_loss = 0; int packet_loss = 0;
@@ -3402,7 +3296,7 @@ static void GAME_EXPORT NetAPI_Status( net_status_t *status )
status->remote_address = cls.netchan.remote_address; status->remote_address = cls.netchan.remote_address;
status->packet_loss = packet_loss; status->packet_loss = packet_loss;
status->local_address = net_local; status->local_address = net_local;
status->rate = rate.value; status->rate = rate->value;
} }
/* /*
@@ -3411,7 +3305,7 @@ NetAPI_SendRequest
================= =================
*/ */
static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, double timeout, netadr_t *remote_address, net_api_response_func_t response ) void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, double timeout, netadr_t *remote_address, net_api_response_func_t response )
{ {
net_request_t *nr = NULL; net_request_t *nr = NULL;
string req; string req;
@@ -3426,9 +3320,6 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX ) if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX )
return; // IPX no longer support return; // IPX no longer support
if( request == NETAPI_REQUEST_SERVERLIST )
return; // no support for server list requests
// find a free request // find a free request
for( i = 0; i < MAX_REQUESTS; i++ ) for( i = 0; i < MAX_REQUESTS; i++ )
{ {
@@ -3465,10 +3356,29 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
nr->resp.remote_address = *remote_address; nr->resp.remote_address = *remote_address;
nr->flags = flags; nr->flags = flags;
if( request == NETAPI_REQUEST_SERVERLIST )
{
char fullquery[512];
size_t len;
len = CL_BuildMasterServerScanRequest( fullquery, sizeof( fullquery ), false );
// make sure that port is specified
if( !nr->resp.remote_address.port )
nr->resp.remote_address.port = MSG_BigShort( PORT_MASTER );
// grab the list from the master server
NET_SendPacket( NS_CLIENT, len, fullquery, nr->resp.remote_address );
clgame.request_type = NET_REQUEST_CLIENT;
clgame.master_request = nr; // holds the master request unitl the master acking
}
else
{
// local servers request // local servers request
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request ); Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req ); Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req );
} }
}
/* /*
================= =================
@@ -3476,7 +3386,7 @@ NetAPI_CancelRequest
================= =================
*/ */
static void GAME_EXPORT NetAPI_CancelRequest( int context ) void GAME_EXPORT NetAPI_CancelRequest( int context )
{ {
net_request_t *nr; net_request_t *nr;
int i; int i;
@@ -3495,6 +3405,13 @@ static void GAME_EXPORT NetAPI_CancelRequest( int context )
nr->pfnFunc( &nr->resp ); nr->pfnFunc( &nr->resp );
} }
if( clgame.net_requests[i].resp.type == NETAPI_REQUEST_SERVERLIST && &clgame.net_requests[i] == clgame.master_request )
{
if( clgame.request_type == NET_REQUEST_CLIENT )
clgame.request_type = NET_REQUEST_CANCEL;
clgame.master_request = NULL;
}
memset( &clgame.net_requests[i], 0, sizeof( net_request_t )); memset( &clgame.net_requests[i], 0, sizeof( net_request_t ));
break; break;
} }
@@ -3523,6 +3440,8 @@ void GAME_EXPORT NetAPI_CancelAllRequests( void )
} }
memset( clgame.net_requests, 0, sizeof( clgame.net_requests )); memset( clgame.net_requests, 0, sizeof( clgame.net_requests ));
clgame.request_type = NET_REQUEST_CANCEL;
clgame.master_request = NULL;
} }
/* /*
@@ -3531,7 +3450,7 @@ NetAPI_AdrToString
================= =================
*/ */
static const char *NetAPI_AdrToString( netadr_t *a ) const char *NetAPI_AdrToString( netadr_t *a )
{ {
return NET_AdrToString( *a ); return NET_AdrToString( *a );
} }
@@ -3542,7 +3461,7 @@ NetAPI_CompareAdr
================= =================
*/ */
static int GAME_EXPORT NetAPI_CompareAdr( netadr_t *a, netadr_t *b ) int GAME_EXPORT NetAPI_CompareAdr( netadr_t *a, netadr_t *b )
{ {
return NET_CompareAdr( *a, *b ); return NET_CompareAdr( *a, *b );
} }
@@ -3553,7 +3472,7 @@ NetAPI_StringToAdr
================= =================
*/ */
static int GAME_EXPORT NetAPI_StringToAdr( char *s, netadr_t *a ) int GAME_EXPORT NetAPI_StringToAdr( char *s, netadr_t *a )
{ {
return NET_StringToAdr( s, a ); return NET_StringToAdr( s, a );
} }
@@ -3564,7 +3483,7 @@ NetAPI_ValueForKey
================= =================
*/ */
static const char * GAME_EXPORT NetAPI_ValueForKey( const char *s, const char *key ) const char *NetAPI_ValueForKey( const char *s, const char *key )
{ {
return Info_ValueForKey( s, key ); return Info_ValueForKey( s, key );
} }
@@ -3575,7 +3494,7 @@ NetAPI_RemoveKey
================= =================
*/ */
static void GAME_EXPORT NetAPI_RemoveKey( char *s, const char *key ) void GAME_EXPORT NetAPI_RemoveKey( char *s, const char *key )
{ {
Info_RemoveKey( s, key ); Info_RemoveKey( s, key );
} }
@@ -3586,7 +3505,7 @@ NetAPI_SetValueForKey
================= =================
*/ */
static void GAME_EXPORT NetAPI_SetValueForKey( char *s, const char *key, const char *value, int maxsize ) void GAME_EXPORT NetAPI_SetValueForKey( char *s, const char *key, const char *value, int maxsize )
{ {
if( key[0] == '*' ) return; if( key[0] == '*' ) return;
Info_SetValueForStarKey( s, key, value, maxsize ); Info_SetValueForStarKey( s, key, value, maxsize );
@@ -3606,7 +3525,7 @@ Voice_StartVoiceTweakMode
================= =================
*/ */
static int GAME_EXPORT Voice_StartVoiceTweakMode( void ) int GAME_EXPORT Voice_StartVoiceTweakMode( void )
{ {
return 0; return 0;
} }
@@ -3617,7 +3536,7 @@ Voice_EndVoiceTweakMode
================= =================
*/ */
static void GAME_EXPORT Voice_EndVoiceTweakMode( void ) void GAME_EXPORT Voice_EndVoiceTweakMode( void )
{ {
} }
@@ -3627,7 +3546,7 @@ Voice_SetControlFloat
================= =================
*/ */
static void GAME_EXPORT Voice_SetControlFloat( VoiceTweakControl iControl, float value ) void GAME_EXPORT Voice_SetControlFloat( VoiceTweakControl iControl, float value )
{ {
} }
@@ -3637,7 +3556,7 @@ Voice_GetControlFloat
================= =================
*/ */
static float GAME_EXPORT Voice_GetControlFloat( VoiceTweakControl iControl ) float GAME_EXPORT Voice_GetControlFloat( VoiceTweakControl iControl )
{ {
return 1.0f; return 1.0f;
} }
@@ -3955,13 +3874,13 @@ void CL_UnloadProgs( void )
Cvar_FullSet( "cl_background", "0", FCVAR_READ_ONLY ); Cvar_FullSet( "cl_background", "0", FCVAR_READ_ONLY );
Cvar_FullSet( "host_clientloaded", "0", FCVAR_READ_ONLY ); Cvar_FullSet( "host_clientloaded", "0", FCVAR_READ_ONLY );
Cvar_Unlink( FCVAR_CLIENTDLL );
Cmd_Unlink( CMD_CLIENTDLL );
COM_FreeLibrary( clgame.hInstance ); COM_FreeLibrary( clgame.hInstance );
Mem_FreePool( &cls.mempool ); Mem_FreePool( &cls.mempool );
Mem_FreePool( &clgame.mempool ); Mem_FreePool( &clgame.mempool );
memset( &clgame, 0, sizeof( clgame )); memset( &clgame, 0, sizeof( clgame ));
Cvar_Unlink( FCVAR_CLIENTDLL );
Cmd_Unlink( CMD_CLIENTDLL );
} }
qboolean CL_LoadProgs( const char *name ) qboolean CL_LoadProgs( const char *name )
@@ -4003,7 +3922,7 @@ qboolean CL_LoadProgs( const char *name )
// during LoadLibrary // during LoadLibrary
if( !GI->internal_vgui_support && VGui_LoadProgs( NULL )) if( !GI->internal_vgui_support && VGui_LoadProgs( NULL ))
{ {
VGui_Startup( refState.width, refState.height ); VGui_Startup( NULL, refState.width, refState.height );
} }
else else
{ {
@@ -4019,7 +3938,8 @@ qboolean CL_LoadProgs( const char *name )
// delayed vgui initialization for internal support // delayed vgui initialization for internal support
if( GI->internal_vgui_support && VGui_LoadProgs( clgame.hInstance )) if( GI->internal_vgui_support && VGui_LoadProgs( clgame.hInstance ))
{ {
VGui_Startup( refState.width, refState.height ); // do not pass client pointer yet
VGui_Startup( NULL, refState.width, refState.height );
} }
// clear exports // clear exports
@@ -4102,6 +4022,9 @@ qboolean CL_LoadProgs( const char *name )
return false; return false;
} }
// try to load VGUI2
VGui_Startup( clgame.hInstance, refState.width, refState.height );
Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY ); Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY );
clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts(); clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts();
@@ -4119,7 +4042,7 @@ qboolean CL_LoadProgs( const char *name )
if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" ); Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" );
CL_InitEdicts( cl.maxclients ); // initailize local player and world CL_InitEdicts (); // initailize local player and world
CL_InitClientMove(); // initialize pm_shared CL_InitClientMove(); // initialize pm_shared
// initialize game // initialize game

View File

@@ -414,15 +414,11 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
out->gamemode = in->gamemode; out->gamemode = in->gamemode;
if( in->nomodels ) if( in->nomodels )
SetBits( out->flags, GFL_NOMODELS ); out->flags |= GFL_NOMODELS;
if( in->noskills ) if( in->noskills )
SetBits( out->flags, GFL_NOSKILLS ); out->flags |= GFL_NOSKILLS;
if( in->render_picbutton_text ) if( in->render_picbutton_text )
SetBits( out->flags, GFL_RENDER_PICBUTTON_TEXT ); out->flags |= GFL_RENDER_PICBUTTON_TEXT;
if( in->hd_background )
SetBits( out->flags, GFL_HD_BACKGROUND );
if( in->animated_title )
SetBits( out->flags, GFL_ANIMATED_TITLE );
} }
/* /*
@@ -542,7 +538,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; gameui.ds.gl_texturenum = hPic;
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
@@ -558,7 +554,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 ); ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -570,7 +566,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 ); ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -582,7 +578,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 ); ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -594,7 +590,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 ); ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -646,17 +642,6 @@ static void GAME_EXPORT pfnFillRGBA( int x, int y, int width, int height, int r,
ref.dllFuncs.Color4ub( 255, 255, 255, 255 ); ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
} }
/*
=============
pfnCvar_RegisterVariable
=============
*/
static cvar_t *GAME_EXPORT pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags )
{
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_GAMEUIDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_GAMEUIDLL ));
}
/* /*
============= =============
pfnClientCmd pfnClientCmd
@@ -984,23 +969,30 @@ pfnCheckGameDll
========= =========
*/ */
static int GAME_EXPORT pfnCheckGameDll( void ) int GAME_EXPORT pfnCheckGameDll( void )
{ {
#ifdef XASH_INTERNAL_GAMELIBS
return true;
#else
string dllpath; string dllpath;
void *hInst;
#if TARGET_OS_IPHONE
// loading server library drains too many ram
// so 512MB iPod Touch cannot even connect to
// to servers in cstrike
return true;
#endif
if( svgame.hInstance ) if( svgame.hInstance )
return true; return true;
COM_GetCommonLibraryPath( LIBRARY_SERVER, dllpath, sizeof( dllpath )); COM_GetCommonLibraryPath( LIBRARY_SERVER, dllpath, sizeof( dllpath ));
if( FS_FileExists( dllpath, false )) if(( hInst = COM_LoadLibrary( dllpath, true, false )) != NULL )
{
COM_FreeLibrary( hInst ); // don't increase linker's reference counter
return true; return true;
}
Con_Reportf( S_WARN "Could not load server library: %s\n", COM_GetLibraryError() );
return false; return false;
#endif
} }
/* /*
@@ -1092,11 +1084,6 @@ static int pfnDelete( const char *path )
return FS_Delete( path ); return FS_Delete( path );
} }
static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
{
Con_DefaultColor( r, g, b, true );
}
// engine callbacks // engine callbacks
static ui_enginefuncs_t gEngfuncs = static ui_enginefuncs_t gEngfuncs =
{ {
@@ -1136,7 +1123,7 @@ static ui_enginefuncs_t gEngfuncs =
UI_DrawConsoleString, UI_DrawConsoleString,
UI_DrawSetTextColor, UI_DrawSetTextColor,
Con_DrawStringLen, Con_DrawStringLen,
pfnCon_DefaultColor, Con_DefaultColor,
pfnGetPlayerModel, pfnGetPlayerModel,
pfnSetPlayerModel, pfnSetPlayerModel,
pfnClearScene, pfnClearScene,
@@ -1231,12 +1218,12 @@ void UI_UnloadProgs( void )
Cvar_FullSet( "host_gameuiloaded", "0", FCVAR_READ_ONLY ); Cvar_FullSet( "host_gameuiloaded", "0", FCVAR_READ_ONLY );
Cvar_Unlink( FCVAR_GAMEUIDLL );
Cmd_Unlink( CMD_GAMEUIDLL );
COM_FreeLibrary( gameui.hInstance ); COM_FreeLibrary( gameui.hInstance );
Mem_FreePool( &gameui.mempool ); Mem_FreePool( &gameui.mempool );
memset( &gameui, 0, sizeof( gameui )); memset( &gameui, 0, sizeof( gameui ));
Cvar_Unlink( FCVAR_GAMEUIDLL );
Cmd_Unlink( CMD_GAMEUIDLL );
} }
qboolean UI_LoadProgs( void ) qboolean UI_LoadProgs( void )

File diff suppressed because it is too large Load Diff

View File

@@ -20,17 +20,17 @@ GNU General Public License for more details.
#include "input.h" #include "input.h"
#include "platform/platform.h" #include "platform/platform.h"
static mobile_engfuncs_t *gMobileEngfuncs; mobile_engfuncs_t *gMobileEngfuncs;
static CVAR_DEFINE_AUTO( vibration_length, "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "vibration length" ); convar_t *vibration_length;
static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" ); convar_t *vibration_enable;
static cl_font_t g_scaled_font; static cl_font_t g_scaled_font;
static float g_font_scale; static float g_font_scale;
static void pfnVibrate( float life, char flags ) static void pfnVibrate( float life, char flags )
{ {
if( !vibration_enable.value ) if( !vibration_enable->value )
return; return;
if( life < 0.0f ) if( life < 0.0f )
@@ -42,7 +42,7 @@ static void pfnVibrate( float life, char flags )
//Con_Reportf( "Vibrate: %f %d\n", life, flags ); //Con_Reportf( "Vibrate: %f %d\n", life, flags );
// here goes platform-specific backends // here goes platform-specific backends
Platform_Vibrate( life * vibration_length.value, flags ); Platform_Vibrate( life * vibration_length->value, flags );
} }
static void Vibrate_f( void ) static void Vibrate_f( void )
@@ -67,7 +67,7 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
rgba_t color = { r, g, b, 255 }; rgba_t color = { r, g, b, 255 };
int flags = FONT_DRAW_HUD; int flags = FONT_DRAW_HUD;
if( hud_utf8.value ) if( hud_utf8->value )
SetBits( flags, FONT_DRAW_UTF8 ); SetBits( flags, FONT_DRAW_UTF8 );
if( fabs( g_font_scale - scale ) > 0.1f || if( fabs( g_font_scale - scale ) > 0.1f ||
@@ -87,6 +87,15 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
return CL_DrawCharacter( x, y, number, color, &g_scaled_font, flags ); return CL_DrawCharacter( x, y, number, color, &g_scaled_font, flags );
} }
static void *pfnGetNativeObject( const char *obj )
{
if( !obj )
return NULL;
// Backend should consider that obj is case-sensitive
return Platform_GetNativeObject( obj );
}
static void pfnTouch_HideButtons( const char *name, byte state ) static void pfnTouch_HideButtons( const char *name, byte state )
{ {
Touch_HideButtons( name, state, true ); Touch_HideButtons( name, state, true );
@@ -115,7 +124,7 @@ static mobile_engfuncs_t gpMobileEngfuncs =
Touch_ResetDefaultButtons, Touch_ResetDefaultButtons,
pfnDrawScaledCharacter, pfnDrawScaledCharacter,
Sys_Warn, Sys_Warn,
Sys_GetNativeObject, pfnGetNativeObject,
ID_SetCustomClientID, ID_SetCustomClientID,
pfnParseFileSafe pfnParseFileSafe
}; };
@@ -133,8 +142,8 @@ qboolean Mobile_Init( void )
success = true; success = true;
Cmd_AddCommand( "vibrate", (xcommand_t)Vibrate_f, "Vibrate for specified time"); Cmd_AddCommand( "vibrate", (xcommand_t)Vibrate_f, "Vibrate for specified time");
Cvar_RegisterVariable( &vibration_length ); vibration_length = Cvar_Get( "vibration_length", "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "Vibration length");
Cvar_RegisterVariable( &vibration_enable ); vibration_enable = Cvar_Get( "vibration_enable", "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "Enable vibration");
return success; return success;
} }

View File

@@ -33,12 +33,12 @@ GNU General Public License for more details.
#define NETGRAPH_NET_COLORS 5 #define NETGRAPH_NET_COLORS 5
#define NUM_LATENCY_SAMPLES 8 #define NUM_LATENCY_SAMPLES 8
CVAR_DEFINE_AUTO( net_graph, "0", FCVAR_ARCHIVE, "draw network usage graph" ); convar_t *net_graph;
static CVAR_DEFINE_AUTO( net_graphpos, "1", FCVAR_ARCHIVE, "network usage graph position" ); static convar_t *net_graphpos;
static CVAR_DEFINE_AUTO( net_scale, "5", FCVAR_ARCHIVE, "network usage graph scale level" ); static convar_t *net_graphwidth;
static CVAR_DEFINE_AUTO( net_graphwidth, "192", FCVAR_ARCHIVE, "network usage graph width" ); static convar_t *net_graphheight;
static CVAR_DEFINE_AUTO( net_graphheight, "64", FCVAR_ARCHIVE, "network usage graph height" ); static convar_t *net_graphsolid;
static CVAR_DEFINE_AUTO( net_graphsolid, "1", FCVAR_ARCHIVE, "fill segments in network usage graph" ); static convar_t *net_scale;
static struct packet_latency_t static struct packet_latency_t
{ {
@@ -211,7 +211,7 @@ static void NetGraph_GetFrameData( float *latency, int *latency_count )
else else
{ {
int frame_latency = Q_min( 1.0f, f->latency ); int frame_latency = Q_min( 1.0f, f->latency );
p->latency = (( frame_latency + 0.1f ) / 1.1f ) * ( net_graphheight.value - NETGRAPH_LERP_HEIGHT - 2 ); p->latency = (( frame_latency + 0.1f ) / 1.1f ) * ( net_graphheight->value - NETGRAPH_LERP_HEIGHT - 2 );
if( i > cls.netchan.incoming_sequence - NUM_LATENCY_SAMPLES ) if( i > cls.netchan.incoming_sequence - NUM_LATENCY_SAMPLES )
{ {
@@ -260,7 +260,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
for( a = 0; a < w; a++ ) for( a = 0; a < w; a++ )
{ {
i = ( cls.netchan.outgoing_sequence - a ) & NET_TIMINGS_MASK; i = ( cls.netchan.outgoing_sequence - a ) & NET_TIMINGS_MASK;
h = Q_min(( netstat_cmdinfo[i].cmd_lerp / 3.0f ) * NETGRAPH_LERP_HEIGHT, net_graphheight.value * 0.7f); h = Q_min(( netstat_cmdinfo[i].cmd_lerp / 3.0f ) * NETGRAPH_LERP_HEIGHT, net_graphheight->value * 0.7f);
fill.left = x + w - a - 1; fill.left = x + w - a - 1;
fill.right = fill.bottom = 1; fill.right = fill.bottom = 1;
@@ -273,7 +273,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
h -= extrap_point; h -= extrap_point;
fill.top -= extrap_point; fill.top -= extrap_point;
if( !net_graphsolid.value ) if( !net_graphsolid->value )
{ {
fill.top -= (h - 1); fill.top -= (h - 1);
start = (h - 1); start = (h - 1);
@@ -295,7 +295,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
fill.top -= h; fill.top -= h;
h = extrap_point - h; h = extrap_point - h;
if( !net_graphsolid.value ) if( !net_graphsolid->value )
h = 1; h = 1;
for( j = 0; j < h; j++ ) for( j = 0; j < h; j++ )
@@ -334,7 +334,7 @@ NetGraph_DrawHatches
*/ */
static void NetGraph_DrawHatches( int x, int y ) static void NetGraph_DrawHatches( int x, int y )
{ {
int ystep = (int)( 10.0f / net_scale.value ); int ystep = (int)( 10.0f / net_scale->value );
byte colorminor[4] = { 0, 63, 63, 200 }; byte colorminor[4] = { 0, 63, 63, 200 };
byte color[4] = { 0, 200, 0, 255 }; byte color[4] = { 0, 200, 0, 255 };
wrect_t hatch = { x, 4, y, 1 }; wrect_t hatch = { x, 4, y, 1 };
@@ -342,9 +342,9 @@ static void NetGraph_DrawHatches( int x, int y )
ystep = Q_max( ystep, 1 ); ystep = Q_max( ystep, 1 );
for( starty = hatch.top; hatch.top > 0 && ((starty - hatch.top) * net_scale.value < (maxmsgbytes + 50)); hatch.top -= ystep ) for( starty = hatch.top; hatch.top > 0 && ((starty - hatch.top) * net_scale->value < (maxmsgbytes + 50)); hatch.top -= ystep )
{ {
if(!((int)((starty - hatch.top) * net_scale.value ) % 50 )) if(!((int)((starty - hatch.top) * net_scale->value ) % 50 ))
{ {
NetGraph_DrawRect( &hatch, color ); NetGraph_DrawRect( &hatch, color );
} }
@@ -370,14 +370,14 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
int pty = Q_max( rect.top + rect.bottom - NETGRAPH_LERP_HEIGHT - 3, 1 ); int pty = Q_max( rect.top + rect.bottom - NETGRAPH_LERP_HEIGHT - 3, 1 );
int out, i = ( cls.netchan.outgoing_sequence - 1 ) & NET_TIMINGS_MASK; int out, i = ( cls.netchan.outgoing_sequence - 1 ) & NET_TIMINGS_MASK;
int j = cls.netchan.incoming_sequence & NET_TIMINGS_MASK; int j = cls.netchan.incoming_sequence & NET_TIMINGS_MASK;
int last_y = y - net_graphheight.value; int last_y = y - net_graphheight->value;
if( count > 0 ) if( count > 0 )
{ {
avg = avg / (float)( count - ( host.frametime * FRAMERATE_AVG_FRAC )); avg = avg / (float)( count - ( host.frametime * FRAMERATE_AVG_FRAC ));
if( cl_updaterate.value > 0.0f ) if( cl_updaterate->value > 0.0f )
avg -= 1000.0f / cl_updaterate.value; avg -= 1000.0f / cl_updaterate->value;
// can't be below zero // can't be below zero
avg = Q_max( 0.0f, avg ); avg = Q_max( 0.0f, avg );
@@ -387,11 +387,11 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
// move rolling average // move rolling average
framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0f - FRAMERATE_AVG_FRAC ) * framerate; 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 ) if( framerate > 0.0f )
{ {
y -= net_graphheight.value; y -= net_graphheight->value;
CL_DrawStringf( font, x, y, colors, FONT_DRAW_NORENDERMODE, "%.1f fps" , 1.0f / framerate); CL_DrawStringf( font, x, y, colors, FONT_DRAW_NORENDERMODE, "%.1f fps" , 1.0f / framerate);
@@ -422,9 +422,9 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
} }
if( graphtype < 3 ) if( graphtype < 3 )
CL_DrawStringf( font, ptx, pty, colors, FONT_DRAW_NORENDERMODE, "%i/s", (int)cl_cmdrate.value ); CL_DrawStringf( font, ptx, pty, colors, FONT_DRAW_NORENDERMODE, "%i/s", (int)cl_cmdrate->value );
CL_DrawStringf( font, ptx, last_y, colors, FONT_DRAW_NORENDERMODE, "%i/s" , (int)cl_updaterate.value ); CL_DrawStringf( font, ptx, last_y, colors, FONT_DRAW_NORENDERMODE, "%i/s" , (int)cl_updaterate->value );
} }
/* /*
@@ -435,12 +435,12 @@ NetGraph_DrawDataSegment
*/ */
static int NetGraph_DrawDataSegment( wrect_t *fill, int bytes, byte r, byte g, byte b, byte a ) static int NetGraph_DrawDataSegment( wrect_t *fill, int bytes, byte r, byte g, byte b, byte a )
{ {
float h = bytes / net_scale.value; float h = bytes / net_scale->value;
byte colors[4] = { r, g, b, a }; byte colors[4] = { r, g, b, a };
fill->top -= (int)h; fill->top -= (int)h;
if( net_graphsolid.value ) if( net_graphsolid->value )
fill->bottom = (int)h; fill->bottom = (int)h;
else fill->bottom = 1; else fill->bottom = 1;
@@ -498,7 +498,7 @@ NetGraph_DrawDataUsage
static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype ) static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
{ {
int a, i, h, lastvalidh = 0, ping; int a, i, h, lastvalidh = 0, ping;
int pingheight = net_graphheight.value - NETGRAPH_LERP_HEIGHT - 2; int pingheight = net_graphheight->value - NETGRAPH_LERP_HEIGHT - 2;
wrect_t fill = { 0 }; wrect_t fill = { 0 };
byte color[4]; byte color[4];
@@ -554,7 +554,7 @@ static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
continue; continue;
color[0] = color[1] = color[2] = color[3] = 255; color[0] = color[1] = color[2] = color[3] = 255;
fill.top = y - net_graphheight.value - 1; fill.top = y - net_graphheight->value - 1;
fill.bottom = 1; fill.bottom = 1;
if( NetGraph_AtEdge( a, w )) if( NetGraph_AtEdge( a, w ))
@@ -589,7 +589,7 @@ static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
if( !NetGraph_DrawDataSegment( &fill, netstat_graph[i].voicebytes, 255, 255, 255, 255 )) if( !NetGraph_DrawDataSegment( &fill, netstat_graph[i].voicebytes, 255, 255, 255, 255 ))
continue; continue;
fill.top = y - net_graphheight.value - 1; fill.top = y - net_graphheight->value - 1;
fill.bottom = 1; fill.bottom = 1;
fill.top -= 2; fill.top -= 2;
@@ -598,7 +598,7 @@ static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
} }
if( graphtype >= 2 ) if( graphtype >= 2 )
NetGraph_DrawHatches( x, y - net_graphheight.value - 1 ); NetGraph_DrawHatches( x, y - net_graphheight->value - 1 );
} }
/* /*
@@ -613,12 +613,12 @@ static void NetGraph_GetScreenPos( wrect_t *rect, int *w, int *x, int *y )
rect->right = refState.width; rect->right = refState.width;
rect->bottom = refState.height; rect->bottom = refState.height;
*w = Q_min( NET_TIMINGS, net_graphwidth.value ); *w = Q_min( NET_TIMINGS, net_graphwidth->value );
if( rect->right < *w + 10 ) if( rect->right < *w + 10 )
*w = rect->right - 10; *w = rect->right - 10;
// detect x and y position // detect x and y position
switch( (int)net_graphpos.value ) switch( (int)net_graphpos->value )
{ {
case 1: // right sided case 1: // right sided
*x = rect->left + rect->right - 5 - *w; *x = rect->left + rect->right - 5 - *w;
@@ -661,16 +661,16 @@ void SCR_DrawNetGraph( void )
{ {
graphtype = 2; graphtype = 2;
} }
else if( net_graph.value != 0.0f ) else if( net_graph->value != 0.0f )
{ {
graphtype = (int)net_graph.value; graphtype = (int)net_graph->value;
} }
else else
{ {
return; return;
} }
if( net_scale.value <= 0 ) if( net_scale->value <= 0 )
Cvar_SetValue( "net_scale", 0.1f ); Cvar_SetValue( "net_scale", 0.1f );
NetGraph_GetScreenPos( &rect, &w, &x, &y ); NetGraph_GetScreenPos( &rect, &w, &x, &y );
@@ -697,12 +697,12 @@ void SCR_DrawNetGraph( void )
void CL_InitNetgraph( void ) void CL_InitNetgraph( void )
{ {
Cvar_RegisterVariable( &net_graph ); net_graph = Cvar_Get( "net_graph", "0", FCVAR_ARCHIVE, "draw network usage graph" );
Cvar_RegisterVariable( &net_graphpos ); net_graphpos = Cvar_Get( "net_graphpos", "1", FCVAR_ARCHIVE, "network usage graph position" );
Cvar_RegisterVariable( &net_scale ); net_scale = Cvar_Get( "net_scale", "5", FCVAR_ARCHIVE, "network usage graph scale level" );
Cvar_RegisterVariable( &net_graphwidth ); net_graphwidth = Cvar_Get( "net_graphwidth", "192", FCVAR_ARCHIVE, "network usage graph width" );
Cvar_RegisterVariable( &net_graphheight ); net_graphheight = Cvar_Get( "net_graphheight", "64", FCVAR_ARCHIVE, "network usage graph height" );
Cvar_RegisterVariable( &net_graphsolid ); net_graphsolid = Cvar_Get( "net_graphsolid", "1", FCVAR_ARCHIVE, "fill segments in network usage graph" );
packet_loss = packet_choke = 0.0; packet_loss = packet_choke = 0.0;
NetGraph_InitColors(); NetGraph_InitColors();

View File

@@ -31,7 +31,7 @@ CL_UserMsgStub
Default stub for missed callbacks 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; return 1;
} }
@@ -57,7 +57,7 @@ CL_ParseSoundPacket
================== ==================
*/ */
static void CL_ParseSoundPacket( sizebuf_t *msg ) void CL_ParseSoundPacket( sizebuf_t *msg )
{ {
vec3_t pos; vec3_t pos;
int chan, sound; int chan, sound;
@@ -196,7 +196,7 @@ void CL_ParseServerTime( sizebuf_t *msg )
dt = cl.time - cl.mtime[0]; dt = cl.time - cl.mtime[0];
if( fabs( dt ) > cl_clockreset.value ) // 0.1 by default if( fabs( dt ) > cl_clockreset->value ) // 0.1 by default
{ {
cl.time = cl.mtime[0]; cl.time = cl.mtime[0];
cl.timedelta = 0.0f; cl.timedelta = 0.0f;
@@ -304,7 +304,7 @@ CL_ParseStaticEntity
static client entity static client entity
================== ==================
*/ */
static void CL_ParseStaticEntity( sizebuf_t *msg ) void CL_ParseStaticEntity( sizebuf_t *msg )
{ {
int i, newnum; int i, newnum;
entity_state_t from, to; entity_state_t from, to;
@@ -618,7 +618,7 @@ static void CL_StartResourceDownloading( const char *pszMessage, qboolean bCusto
CL_BatchResourceRequest( !bCustom ); 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; customization_t *pList;
@@ -630,7 +630,7 @@ static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_
return NULL; return NULL;
} }
static void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove ) void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
{ {
customization_t *pList; customization_t *pList;
customization_t *pNext; customization_t *pNext;
@@ -801,7 +801,7 @@ CL_CreateCustomizationList
loading custom decal for self loading custom decal for self
================== ==================
*/ */
static void CL_CreateCustomizationList( void ) void CL_CreateCustomizationList( void )
{ {
resource_t *pResource; resource_t *pResource;
player_info_t *pPlayer; player_info_t *pPlayer;
@@ -848,10 +848,8 @@ CL_ParseServerData
void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ) void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
{ {
char gamefolder[MAX_QPATH]; char gamefolder[MAX_QPATH];
string mapfile;
qboolean background; qboolean background;
int i; int i;
uint32_t mapCRC;
HPAK_CheckSize( CUSTOM_RES_PATH ); HPAK_CheckSize( CUSTOM_RES_PATH );
@@ -902,7 +900,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle )); Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
background = MSG_ReadOneBit( msg ); background = MSG_ReadOneBit( msg );
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder )); Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
Host_ValidateEngineFeatures( MSG_ReadDword( msg )); host.features = (uint)MSG_ReadLong( msg );
if( !legacy ) if( !legacy )
{ {
@@ -914,18 +912,6 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
} }
} }
Q_snprintf( mapfile, sizeof( mapfile ), "maps/%s.bsp", clgame.mapname );
if( CRC32_MapFile( &mapCRC, mapfile, cl.maxclients > 1 ))
{
// validate map checksum
if( mapCRC != cl.checksum )
{
Con_Printf( S_ERROR "Your map [%s] differs from the server's.\n", clgame.mapname );
CL_Disconnect_f(); // for local game, call EndGame
Host_AbortCurrentFrame(); // to avoid svc_bad
}
}
if( clgame.maxModels > MAX_MODELS ) if( clgame.maxModels > MAX_MODELS )
Con_Printf( S_WARN "server model limit is above client model limit %i > %i\n", clgame.maxModels, MAX_MODELS ); Con_Printf( S_WARN "server model limit is above client model limit %i > %i\n", clgame.maxModels, MAX_MODELS );
@@ -945,10 +931,10 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
// loading user settings // loading user settings
CSCR_LoadDefaultCVars( "user.scr" ); CSCR_LoadDefaultCVars( "user.scr" );
if( r_decals.value > mp_decals.value ) if( r_decals->value > mp_decals.value )
Cvar_DirectSet( &r_decals, mp_decals.string ); Cvar_SetValue( "r_decals", mp_decals.value );
} }
else Cvar_DirectSet( &r_decals, NULL ); else Cvar_Reset( "r_decals" );
// set the background state // set the background state
if( cls.demoplayback && ( cls.demonum != -1 )) if( cls.demoplayback && ( cls.demonum != -1 ))
@@ -980,7 +966,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle )); Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle ));
if( !cls.changelevel && !cls.changedemo ) if( !cls.changelevel && !cls.changedemo )
CL_InitEdicts( cl.maxclients ); // re-arrange edicts CL_InitEdicts (); // re-arrange edicts
// get splash name // get splash name
if( cls.demoplayback && ( cls.demonum != -1 )) if( cls.demoplayback && ( cls.demonum != -1 ))
@@ -988,9 +974,9 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" )); else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" ));
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
{ {
if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name.string ), true )) if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name->string ), true ))
Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen
cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime)
} }
@@ -1254,7 +1240,7 @@ CL_ParseSetAngle
set the view angle to this absolute value set the view angle to this absolute value
================ ================
*/ */
void CL_ParseSetAngle( sizebuf_t *msg ) static void CL_ParseSetAngle( sizebuf_t *msg )
{ {
MSG_ReadVec3Angles( msg, cl.viewangles ); MSG_ReadVec3Angles( msg, cl.viewangles );
} }
@@ -1382,13 +1368,9 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
if( slot >= MAX_CLIENTS ) if( slot >= MAX_CLIENTS )
Host_Error( "CL_ParseServerMessage: svc_updateuserinfo >= MAX_CLIENTS\n" ); Host_Error( "CL_ParseServerMessage: svc_updateuserinfo >= MAX_CLIENTS\n" );
player = &cl.players[slot];
if( !legacy ) if( !legacy )
id = MSG_ReadLong( msg ); // unique user ID id = MSG_ReadLong( msg ); // unique user ID
else player = &cl.players[slot];
id = 0; // bogus
active = MSG_ReadOneBit( msg ) ? true : false; active = MSG_ReadOneBit( msg ) ? true : false;
if( active ) if( active )
@@ -1410,10 +1392,6 @@ void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy )
memset( player, 0, sizeof( *player )); 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;
} }
/* /*
@@ -1501,7 +1479,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
} }
} }
static void CL_SendConsistencyInfo( sizebuf_t *msg ) void CL_SendConsistencyInfo( sizebuf_t *msg )
{ {
qboolean user_changed_diskfile; qboolean user_changed_diskfile;
vec3_t mins, maxs; vec3_t mins, maxs;
@@ -1541,8 +1519,7 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg )
{ {
case force_exactfile: case force_exactfile:
MD5_HashFile( md5, filename, NULL ); MD5_HashFile( md5, filename, NULL );
memcpy( &pc->value, md5, sizeof( pc->value )); pc->value = *(int *)md5;
LittleLongSW( pc->value );
if( user_changed_diskfile ) if( user_changed_diskfile )
MSG_WriteUBitLong( msg, 0, 32 ); MSG_WriteUBitLong( msg, 0, 32 );
@@ -1573,7 +1550,7 @@ CL_StartDark
*/ */
static void CL_StartDark( void ) static void CL_StartDark( void )
{ {
if( v_dark.value ) if( Cvar_VariableValue( "v_dark" ))
{ {
screenfade_t *sf = &clgame.fade; screenfade_t *sf = &clgame.fade;
float fadetime = 5.0f; float fadetime = 5.0f;
@@ -1598,7 +1575,7 @@ static void CL_StartDark( void )
sf->fadeReset += cl.time; sf->fadeReset += cl.time;
sf->fadeEnd += sf->fadeReset; sf->fadeEnd += sf->fadeReset;
Cvar_DirectSet( &v_dark, "0" ); Cvar_SetValue( "v_dark", 0.0f );
} }
} }
@@ -1645,6 +1622,9 @@ void CL_RegisterResources( sizebuf_t *msg )
CL_ClearWorld (); CL_ClearWorld ();
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models. // tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap (); ref.dllFuncs.R_NewMap ();
@@ -1678,7 +1658,7 @@ void CL_RegisterResources( sizebuf_t *msg )
} }
} }
static void CL_ParseConsistencyInfo( sizebuf_t *msg ) void CL_ParseConsistencyInfo( sizebuf_t *msg )
{ {
int lastcheck; int lastcheck;
int delta; int delta;
@@ -1743,7 +1723,7 @@ CL_ParseResourceList
============== ==============
*/ */
static void CL_ParseResourceList( sizebuf_t *msg ) void CL_ParseResourceList( sizebuf_t *msg )
{ {
resource_t *pResource; resource_t *pResource;
int i, total; int i, total;
@@ -1780,12 +1760,12 @@ CL_ParseVoiceInit
================== ==================
*/ */
static void CL_ParseVoiceInit( sizebuf_t *msg ) void CL_ParseVoiceInit( sizebuf_t *msg )
{ {
char *pszCodec = MSG_ReadString( msg ); char *pszCodec = MSG_ReadString( msg );
int quality = MSG_ReadByte( msg ); int quality = MSG_ReadByte( msg );
Voice_Init( pszCodec, quality, false ); // init requested codec and the device Voice_Init( pszCodec, quality );
} }
/* /*
@@ -1794,7 +1774,7 @@ CL_ParseVoiceData
================== ==================
*/ */
static void CL_ParseVoiceData( sizebuf_t *msg ) void CL_ParseVoiceData( sizebuf_t *msg )
{ {
int size, idx, frames; int size, idx, frames;
byte received[8192]; byte received[8192];
@@ -1911,7 +1891,7 @@ CL_ParseScreenShake
Set screen shake 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 amplitude = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 ));
float duration = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 )); float duration = (float)(word)MSG_ReadShort( msg ) * ( 1.0f / (float)( 1 << 12 ));
@@ -1934,7 +1914,7 @@ CL_ParseScreenFade
Set screen fade Set screen fade
============== ==============
*/ */
static void CL_ParseScreenFade( sizebuf_t *msg ) void CL_ParseScreenFade( sizebuf_t *msg )
{ {
float duration, holdTime; float duration, holdTime;
screenfade_t *sf = &clgame.fade; screenfade_t *sf = &clgame.fade;
@@ -2033,7 +2013,7 @@ CL_ParseExec
Exec map/class specific configs Exec map/class specific configs
============== ==============
*/ */
static void CL_ParseExec( sizebuf_t *msg ) void CL_ParseExec( sizebuf_t *msg )
{ {
qboolean is_class; qboolean is_class;
int class_idx; int class_idx;
@@ -2173,7 +2153,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
// parse user message into buffer // parse user message into buffer
MSG_ReadBytes( msg, pbuf, iSize ); MSG_ReadBytes( msg, pbuf, iSize );
if( cl_trace_messages.value ) if( cl_trace_messages->value )
{ {
Con_Reportf( "^3USERMSG %s SIZE %i SVC_NUM %i\n", Con_Reportf( "^3USERMSG %s SIZE %i SVC_NUM %i\n",
clgame.msg[i].name, iSize, clgame.msg[i].number ); clgame.msg[i].name, iSize, clgame.msg[i].number );
@@ -2280,8 +2260,6 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
old_background = cl.background; old_background = cl.background;
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))
{ {
int maxclients = cl.maxclients;
cls.changelevel = true; cls.changelevel = true;
S_StopAllSounds( true ); S_StopAllSounds( true );
@@ -2294,7 +2272,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
} }
CL_ClearState (); CL_ClearState ();
CL_InitEdicts( maxclients ); // re-arrange edicts CL_InitEdicts (); // re-arrange edicts
} }
else Con_Printf( "Server disconnected, reconnecting\n" ); else Con_Printf( "Server disconnected, reconnecting\n" );
@@ -2329,18 +2307,11 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
break; break;
case svc_stufftext: case svc_stufftext:
s = MSG_ReadString( msg ); 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 #ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection // disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS ) if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early break; // too early
#endif #endif
Cbuf_AddFilteredText( s ); Cbuf_AddFilteredText( s );
break; break;
case svc_setangle: case svc_setangle:
@@ -2520,3 +2491,666 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
} }
} }
} }
/*
==================
CL_ParseStaticEntity
static client entity
==================
*/
void CL_LegacyParseStaticEntity( sizebuf_t *msg )
{
int i;
entity_state_t state;
cl_entity_t *ent;
memset( &state, 0, sizeof( state ));
state.modelindex = MSG_ReadShort( msg );
state.sequence = MSG_ReadByte( msg );
state.frame = MSG_ReadByte( msg );
state.colormap = MSG_ReadWord( msg );
state.skin = MSG_ReadByte( msg );
for( i = 0; i < 3; i++ )
{
state.origin[i] = MSG_ReadCoord( msg );
state.angles[i] = MSG_ReadBitAngle( msg, 16 );
}
state.rendermode = MSG_ReadByte( msg );
if( state.rendermode != kRenderNormal )
{
state.renderamt = MSG_ReadByte( msg );
state.rendercolor.r = MSG_ReadByte( msg );
state.rendercolor.g = MSG_ReadByte( msg );
state.rendercolor.b = MSG_ReadByte( msg );
state.renderfx = MSG_ReadByte( msg );
}
i = clgame.numStatics;
if( i >= MAX_STATIC_ENTITIES )
{
Con_Printf( S_ERROR "MAX_STATIC_ENTITIES limit exceeded!\n" );
return;
}
ent = &clgame.static_entities[i];
clgame.numStatics++;
// all states are same
ent->baseline = ent->curstate = ent->prevstate = state;
ent->index = 0; // static entities doesn't has the numbers
// statics may be respawned in game e.g. for demo recording
if( cls.state == ca_connected || cls.state == ca_validate )
ent->trivial_accept = INVALID_HANDLE;
// setup the new static entity
VectorCopy( ent->curstate.origin, ent->origin );
VectorCopy( ent->curstate.angles, ent->angles );
ent->model = CL_ModelHandle( state.modelindex );
ent->curstate.framerate = 1.0f;
CL_ResetLatchedVars( ent, true );
if( ent->curstate.rendermode == kRenderNormal && ent->model != NULL )
{
// auto 'solid' faces
if( FBitSet( ent->model->flags, MODEL_TRANSPARENT ) && Host_IsQuakeCompatible( ))
{
ent->curstate.rendermode = kRenderTransAlpha;
ent->curstate.renderamt = 255;
}
}
R_AddEfrags( ent ); // add link
}
void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
{
vec3_t pos;
int chan, sound;
float volume, attn;
int flags, pitch, entnum;
sound_t handle = 0;
flags = MSG_ReadWord( msg );
if( flags & SND_LEGACY_LARGE_INDEX )
{
sound = MSG_ReadWord( msg );
flags &= ~SND_LEGACY_LARGE_INDEX;
}
else
sound = MSG_ReadByte( msg );
chan = MSG_ReadByte( msg );
if( FBitSet( flags, SND_VOLUME ))
volume = (float)MSG_ReadByte( msg ) / 255.0f;
else volume = VOL_NORM;
if( FBitSet( flags, SND_ATTENUATION ))
attn = (float)MSG_ReadByte( msg ) / 64.0f;
else attn = ATTN_NONE;
if( FBitSet( flags, SND_PITCH ))
pitch = MSG_ReadByte( msg );
else pitch = PITCH_NORM;
// entity reletive
entnum = MSG_ReadWord( msg );
// positioned in space
MSG_ReadVec3Coord( msg, pos );
if( FBitSet( flags, SND_SENTENCE ))
{
char sentenceName[32];
//if( FBitSet( flags, SND_SEQUENCE ))
//Q_snprintf( sentenceName, sizeof( sentenceName ), "!#%i", sound + MAX_SOUNDS );
//else
Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
handle = S_RegisterSound( sentenceName );
}
else handle = cl.sound_index[sound]; // see precached sound
if( !cl.audio_prepped )
return; // too early
// g-cont. sound and ambient sound have only difference with channel
if( is_ambient )
{
S_AmbientSound( pos, entnum, handle, volume, attn, pitch, flags );
}
else
{
S_StartSound( pos, entnum, chan, handle, volume, attn, pitch, flags );
}
}
/*
================
CL_PrecacheSound
prceache sound from server
================
*/
void CL_LegacyPrecacheSound( sizebuf_t *msg )
{
int soundIndex;
soundIndex = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
if( soundIndex < 0 || soundIndex >= MAX_SOUNDS )
Host_Error( "CL_PrecacheSound: bad soundindex %i\n", soundIndex );
Q_strncpy( cl.sound_precache[soundIndex], MSG_ReadString( msg ), sizeof( cl.sound_precache[0] ));
// when we loading map all resources is precached sequentially
//if( !cl.audio_prepped ) return;
cl.sound_index[soundIndex] = S_RegisterSound( cl.sound_precache[soundIndex] );
}
void CL_LegacyPrecacheModel( sizebuf_t *msg )
{
int modelIndex;
string model;
modelIndex = MSG_ReadUBitLong( msg, MAX_LEGACY_MODEL_BITS );
if( modelIndex < 0 || modelIndex >= MAX_MODELS )
Host_Error( "CL_PrecacheModel: bad modelindex %i\n", modelIndex );
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
//if( !cl.video_prepped ) return;
if( modelIndex == 1 && !cl.worldmodel )
{
CL_ClearWorld ();
cl.models[modelIndex] = cl.worldmodel = Mod_LoadWorld( model, true );
return;
}
//Mod_RegisterModel( cl.model_precache[modelIndex], modelIndex );
cl.models[modelIndex] = Mod_ForName( model, false, false );
cl.nummodels = Q_max( cl.nummodels, modelIndex );
}
void CL_LegacyPrecacheEvent( sizebuf_t *msg )
{
int eventIndex;
eventIndex = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
if( eventIndex < 0 || eventIndex >= MAX_EVENTS )
Host_Error( "CL_PrecacheEvent: bad eventindex %i\n", eventIndex );
Q_strncpy( cl.event_precache[eventIndex], MSG_ReadString( msg ), sizeof( cl.event_precache[0] ));
// can be set now
CL_SetEventIndex( cl.event_precache[eventIndex], eventIndex );
}
#if XASH_LOW_MEMORY == 0
#define MAX_LEGACY_RESOURCES 2048
#elif XASH_LOW_MEMORY == 2
#define MAX_LEGACY_RESOURCES 1
#elif XASH_LOW_MEMORY == 1
#define MAX_LEGACY_RESOURCES 512
#endif
/*
==============
CL_ParseResourceList
==============
*/
void CL_LegacyParseResourceList( sizebuf_t *msg )
{
int i = 0;
static struct
{
int rescount;
int restype[MAX_LEGACY_RESOURCES];
char resnames[MAX_LEGACY_RESOURCES][MAX_QPATH];
} reslist;
memset( &reslist, 0, sizeof( reslist ));
reslist.rescount = MSG_ReadWord( msg ) - 1;
if( reslist.rescount > MAX_LEGACY_RESOURCES )
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 ), MAX_QPATH );
}
if( CL_IsPlaybackDemo() )
{
return;
}
HTTP_ResetProcessState();
host.downloadcount = 0;
for( i = 0; i < reslist.rescount; i++ )
{
char soundpath[MAX_VA_STRING];
const char *path;
if( reslist.restype[i] == t_sound )
{
Q_snprintf( soundpath, sizeof( soundpath ), DEFAULT_SOUNDPATH "%s", reslist.resnames[i] );
path = soundpath;
}
else path = reslist.resnames[i];
if( FS_FileExists( path, false ))
continue; // already exists
host.downloadcount++;
HTTP_AddDownload( path, -1, true );
}
if( !host.downloadcount )
{
MSG_WriteByte( &cls.netchan.message, clc_stringcmd );
MSG_WriteString( &cls.netchan.message, "continueloading" );
}
}
/*
=====================
CL_ParseLegacyServerMessage
dispatch messages
=====================
*/
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( "CL_ParseServerMessage: overflow!\n" );
return;
}
// mark start position
bufStart = MSG_GetNumBytesRead( msg );
// end of message (align bits)
if( MSG_GetNumBitsLeft( msg ) < 8 )
break;
cmd = MSG_ReadServerCmd( msg );
// record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart );
// other commands
switch( cmd )
{
case svc_bad:
Host_Error( "svc_bad\n" );
break;
case svc_nop:
// this does nothing
break;
case svc_disconnect:
CL_Drop ();
Host_AbortCurrentFrame ();
break;
case svc_legacy_event:
CL_ParseEvent( msg );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_legacy_changing:
old_background = cl.background;
if( MSG_ReadOneBit( msg ))
{
cls.changelevel = true;
S_StopAllSounds( true );
Con_Printf( "Server changing, reconnecting\n" );
if( cls.demoplayback )
{
SCR_BeginLoadingPlaque( cl.background );
cls.changedemo = true;
}
CL_ClearState ();
CL_InitEdicts (); // re-arrange edicts
}
else Con_Printf( "Server disconnected, reconnecting\n" );
if( cls.demoplayback )
{
cl.background = (cls.demonum != -1) ? true : false;
cls.state = ca_connected;
}
else
{
// g-cont. local client skip the challenge
if( SV_Active( ))
cls.state = ca_disconnected;
else cls.state = ca_connecting;
cl.background = old_background;
cls.connect_time = MAX_HEARTBEAT;
cls.connect_retry = 0;
}
break;
case svc_setview:
CL_ParseViewEntity( msg );
break;
case svc_sound:
CL_LegacyParseSoundPacket( msg, false );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_legacy_ambientsound:
CL_LegacyParseSoundPacket( msg, true );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_time:
CL_ParseServerTime( msg );
break;
case svc_print:
Con_Printf( "%s", MSG_ReadString( msg ));
break;
case svc_stufftext:
s = MSG_ReadString( msg );
#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:
CL_ParseSetAngle( msg );
break;
case svc_serverdata:
Cbuf_Execute(); // make sure any stuffed commands are done
CL_ParseServerData( msg, true );
break;
case svc_lightstyle:
CL_ParseLightStyle( msg );
break;
case svc_updateuserinfo:
CL_UpdateUserinfo( msg, true );
break;
case svc_deltatable:
Delta_ParseTableField( msg );
break;
case svc_clientdata:
CL_ParseClientData( msg );
cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_resource:
CL_ParseResource( msg );
break;
case svc_pings:
CL_UpdateUserPings( msg );
break;
case svc_particle:
CL_ParseParticles( msg );
break;
case svc_restoresound:
CL_ParseRestoreSoundPacket( msg );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_spawnstatic:
CL_LegacyParseStaticEntity( msg );
break;
case svc_event_reliable:
CL_ParseReliableEvent( msg );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_spawnbaseline:
CL_ParseBaseline( msg, true );
break;
case svc_temp_entity:
CL_ParseTempEntity( msg );
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_setpause:
cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
break;
case svc_signonnum:
CL_ParseSignon( msg );
break;
case svc_centerprint:
CL_CenterPrint( MSG_ReadString( msg ), 0.25f );
break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_legacy_modelindex:
CL_LegacyPrecacheModel( msg );
break;
case svc_legacy_soundindex:
CL_LegacyPrecacheSound( msg );
break;
case svc_cdtrack:
param1 = MSG_ReadByte( msg );
param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum
param2 = MSG_ReadByte( msg );
param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum
S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false );
break;
case svc_restore:
CL_ParseRestore( msg );
break;
case svc_legacy_eventindex:
CL_LegacyPrecacheEvent(msg);
break;
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_bspdecal:
CL_ParseStaticDecal( msg );
break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_addangle:
CL_ParseAddAngle( msg );
break;
case svc_usermessage:
CL_RegisterUserMessage( msg );
break;
case svc_packetentities:
playerbytes = CL_ParsePacketEntities( msg, false );
cl.frames[cl.parsecountmod].graphdata.players += playerbytes;
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
break;
case svc_deltapacketentities:
playerbytes = CL_ParsePacketEntities( msg, true );
cl.frames[cl.parsecountmod].graphdata.players += playerbytes;
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
break;
case svc_legacy_chokecount:
{
int i, j;
i = MSG_ReadByte( msg );
j = cls.netchan.incoming_acknowledged - 1;
for( ; i > 0 && j > cls.netchan.outgoing_sequence - CL_UPDATE_BACKUP; j-- )
{
if( cl.frames[j & CL_UPDATE_MASK].receivedtime != -3.0 )
{
cl.frames[j & CL_UPDATE_MASK].choked = true;
cl.frames[j & CL_UPDATE_MASK].receivedtime = -2.0;
i--;
}
}
break;
}
//cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = true;
//cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].receivedtime = -2.0;
break;
case svc_resourcelist:
CL_LegacyParseResourceList( msg );
break;
case svc_deltamovevars:
CL_ParseMovevars( msg );
break;
case svc_resourcerequest:
CL_ParseResourceRequest( msg );
break;
case svc_customization:
CL_ParseCustomization( msg );
break;
case svc_crosshairangle:
CL_ParseCrosshairAngle( msg );
break;
case svc_soundfade:
CL_ParseSoundFade( msg );
break;
case svc_filetxferfailed:
CL_ParseFileTransferFailed( msg );
break;
case svc_hltv:
CL_ParseHLTV( msg );
break;
case svc_director:
CL_ParseDirector( msg );
break;
case svc_resourcelocation:
CL_ParseResLocation( msg );
break;
case svc_querycvarvalue:
CL_ParseCvarValue( msg, false );
break;
case svc_querycvarvalue2:
CL_ParseCvarValue( msg, true );
break;
default:
CL_ParseUserMessage( msg, cmd );
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
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 )
{
int spawncount, i;
model_t *mod;
if( !cls.legacymode )
return;
spawncount = Q_atoi( Cmd_Argv( 1 ));
Con_Printf( "Setting up renderer...\n" );
// load tempent sprites (glowshell, muzzleflashes etc)
CL_LoadClientSprites ();
// invalidate all decal indexes
memset( cl.decal_index, 0, sizeof( cl.decal_index ));
cl.video_prepped = true;
cl.audio_prepped = true;
if( clgame.entities )
clgame.entities->model = cl.worldmodel;
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();
CL_SetupOverviewParams();
// release unused SpriteTextures
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{
if( mod->needload == NL_UNREFERENCED && COM_CheckString( mod->name ))
Mod_FreeModel( mod );
}
// Mod_FreeUnused ();
if( host_developer.value <= DEV_NONE )
Con_ClearNotify(); // clear any lines of console text
// done with all resources, issue prespawn command.
// Include server count in case server disconnects and changes level during d/l
MSG_BeginClientCmd( &cls.netchan.message, clc_stringcmd );
MSG_WriteStringf( &cls.netchan.message, "begin %i", spawncount );
cls.signon = SIGNONS;
}
void CL_LegacyUpdateInfo( void )
{
if( !cls.legacymode )
return;
if( cls.state != ca_active )
return;
MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
}
qboolean CL_LegacyMode( void )
{
return cls.legacymode;
}

View File

@@ -1,706 +0,0 @@
/*
cl_parse.c - parse a message received from the server
Copyright (C) 2008 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 "net_encode.h"
#include "particledef.h"
#include "cl_tent.h"
#include "shake.h"
#include "hltv.h"
#include "input.h"
/*
==================
CL_ParseStaticEntity
static client entity
==================
*/
static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
{
int i;
entity_state_t state;
cl_entity_t *ent;
memset( &state, 0, sizeof( state ));
state.modelindex = MSG_ReadShort( msg );
state.sequence = MSG_ReadByte( msg );
state.frame = MSG_ReadByte( msg );
state.colormap = MSG_ReadWord( msg );
state.skin = MSG_ReadByte( msg );
for( i = 0; i < 3; i++ )
{
state.origin[i] = MSG_ReadCoord( msg );
state.angles[i] = MSG_ReadBitAngle( msg, 16 );
}
state.rendermode = MSG_ReadByte( msg );
if( state.rendermode != kRenderNormal )
{
state.renderamt = MSG_ReadByte( msg );
state.rendercolor.r = MSG_ReadByte( msg );
state.rendercolor.g = MSG_ReadByte( msg );
state.rendercolor.b = MSG_ReadByte( msg );
state.renderfx = MSG_ReadByte( msg );
}
i = clgame.numStatics;
if( i >= MAX_STATIC_ENTITIES )
{
Con_Printf( S_ERROR "MAX_STATIC_ENTITIES limit exceeded!\n" );
return;
}
ent = &clgame.static_entities[i];
clgame.numStatics++;
// all states are same
ent->baseline = ent->curstate = ent->prevstate = state;
ent->index = 0; // static entities doesn't has the numbers
// statics may be respawned in game e.g. for demo recording
if( cls.state == ca_connected || cls.state == ca_validate )
ent->trivial_accept = INVALID_HANDLE;
// setup the new static entity
VectorCopy( ent->curstate.origin, ent->origin );
VectorCopy( ent->curstate.angles, ent->angles );
ent->model = CL_ModelHandle( state.modelindex );
ent->curstate.framerate = 1.0f;
CL_ResetLatchedVars( ent, true );
if( ent->curstate.rendermode == kRenderNormal && ent->model != NULL )
{
// auto 'solid' faces
if( FBitSet( ent->model->flags, MODEL_TRANSPARENT ) && Host_IsQuakeCompatible( ))
{
ent->curstate.rendermode = kRenderTransAlpha;
ent->curstate.renderamt = 255;
}
}
R_AddEfrags( ent ); // add link
}
static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
{
vec3_t pos;
int chan, sound;
float volume, attn;
int flags, pitch, entnum;
sound_t handle = 0;
flags = MSG_ReadWord( msg );
if( flags & SND_LEGACY_LARGE_INDEX )
{
sound = MSG_ReadWord( msg );
flags &= ~SND_LEGACY_LARGE_INDEX;
}
else
sound = MSG_ReadByte( msg );
chan = MSG_ReadByte( msg );
if( FBitSet( flags, SND_VOLUME ))
volume = (float)MSG_ReadByte( msg ) / 255.0f;
else volume = VOL_NORM;
if( FBitSet( flags, SND_ATTENUATION ))
attn = (float)MSG_ReadByte( msg ) / 64.0f;
else attn = ATTN_NONE;
if( FBitSet( flags, SND_PITCH ))
pitch = MSG_ReadByte( msg );
else pitch = PITCH_NORM;
// entity reletive
entnum = MSG_ReadWord( msg );
// positioned in space
MSG_ReadVec3Coord( msg, pos );
if( FBitSet( flags, SND_SENTENCE ))
{
char sentenceName[32];
//if( FBitSet( flags, SND_SEQUENCE ))
//Q_snprintf( sentenceName, sizeof( sentenceName ), "!#%i", sound + MAX_SOUNDS );
//else
Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
handle = S_RegisterSound( sentenceName );
}
else handle = cl.sound_index[sound]; // see precached sound
if( !cl.audio_prepped )
return; // too early
// g-cont. sound and ambient sound have only difference with channel
if( is_ambient )
{
S_AmbientSound( pos, entnum, handle, volume, attn, pitch, flags );
}
else
{
S_StartSound( pos, entnum, chan, handle, volume, attn, pitch, flags );
}
}
/*
================
CL_PrecacheSound
prceache sound from server
================
*/
static void CL_LegacyPrecacheSound( sizebuf_t *msg )
{
int soundIndex;
soundIndex = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
if( soundIndex < 0 || soundIndex >= MAX_SOUNDS )
Host_Error( "CL_PrecacheSound: bad soundindex %i\n", soundIndex );
Q_strncpy( cl.sound_precache[soundIndex], MSG_ReadString( msg ), sizeof( cl.sound_precache[0] ));
// when we loading map all resources is precached sequentially
//if( !cl.audio_prepped ) return;
cl.sound_index[soundIndex] = S_RegisterSound( cl.sound_precache[soundIndex] );
}
static void CL_LegacyPrecacheModel( sizebuf_t *msg )
{
int modelIndex;
string model;
modelIndex = MSG_ReadUBitLong( msg, MAX_LEGACY_MODEL_BITS );
if( modelIndex < 0 || modelIndex >= MAX_MODELS )
Host_Error( "CL_PrecacheModel: bad modelindex %i\n", modelIndex );
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
//if( !cl.video_prepped ) return;
if( modelIndex == 1 && !cl.worldmodel )
{
CL_ClearWorld ();
cl.models[modelIndex] = cl.worldmodel = Mod_LoadWorld( model, true );
return;
}
//Mod_RegisterModel( cl.model_precache[modelIndex], modelIndex );
cl.models[modelIndex] = Mod_ForName( model, false, false );
cl.nummodels = Q_max( cl.nummodels, modelIndex );
}
static void CL_LegacyPrecacheEvent( sizebuf_t *msg )
{
int eventIndex;
eventIndex = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
if( eventIndex < 0 || eventIndex >= MAX_EVENTS )
Host_Error( "CL_PrecacheEvent: bad eventindex %i\n", eventIndex );
Q_strncpy( cl.event_precache[eventIndex], MSG_ReadString( msg ), sizeof( cl.event_precache[0] ));
// can be set now
CL_SetEventIndex( cl.event_precache[eventIndex], eventIndex );
}
#if XASH_LOW_MEMORY == 0
#define MAX_LEGACY_RESOURCES 2048
#elif XASH_LOW_MEMORY == 2
#define MAX_LEGACY_RESOURCES 1
#elif XASH_LOW_MEMORY == 1
#define MAX_LEGACY_RESOURCES 512
#endif
/*
==============
CL_ParseResourceList
==============
*/
static void CL_LegacyParseResourceList( sizebuf_t *msg )
{
int i = 0;
static struct
{
int rescount;
int restype[MAX_LEGACY_RESOURCES];
char resnames[MAX_LEGACY_RESOURCES][MAX_QPATH];
} reslist;
memset( &reslist, 0, sizeof( reslist ));
reslist.rescount = MSG_ReadWord( msg ) - 1;
if( reslist.rescount > MAX_LEGACY_RESOURCES )
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 ), MAX_QPATH );
}
if( CL_IsPlaybackDemo() )
return;
if( !cl_allow_download.value )
{
Con_DPrintf( "Refusing new resource, cl_allow_download set to 0\n" );
reslist.rescount = 0;
}
if( cls.state == ca_active && !cl_download_ingame.value )
{
Con_DPrintf( "Refusing new resource, cl_download_ingame set to 0\n" );
reslist.rescount = 0;
}
HTTP_ResetProcessState();
host.downloadcount = 0;
for( i = 0; i < reslist.rescount; i++ )
{
char soundpath[MAX_VA_STRING];
const char *path;
if( reslist.restype[i] == t_sound )
{
Q_snprintf( soundpath, sizeof( soundpath ), DEFAULT_SOUNDPATH "%s", reslist.resnames[i] );
path = soundpath;
}
else path = reslist.resnames[i];
if( FS_FileExists( path, false ))
continue; // already exists
host.downloadcount++;
HTTP_AddDownload( path, -1, true );
}
if( !host.downloadcount )
{
MSG_WriteByte( &cls.netchan.message, clc_stringcmd );
MSG_WriteString( &cls.netchan.message, "continueloading" );
}
}
/*
=====================
CL_ParseLegacyServerMessage
dispatch messages
=====================
*/
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( "CL_ParseServerMessage: overflow!\n" );
return;
}
// mark start position
bufStart = MSG_GetNumBytesRead( msg );
// end of message (align bits)
if( MSG_GetNumBitsLeft( msg ) < 8 )
break;
cmd = MSG_ReadServerCmd( msg );
// record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart );
// other commands
switch( cmd )
{
case svc_bad:
Host_Error( "svc_bad\n" );
break;
case svc_nop:
// this does nothing
break;
case svc_disconnect:
CL_Drop ();
Host_AbortCurrentFrame ();
break;
case svc_legacy_event:
CL_ParseEvent( msg );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_legacy_changing:
old_background = cl.background;
if( MSG_ReadOneBit( msg ))
{
int maxclients = cl.maxclients;
cls.changelevel = true;
S_StopAllSounds( true );
Con_Printf( "Server changing, reconnecting\n" );
if( cls.demoplayback )
{
SCR_BeginLoadingPlaque( cl.background );
cls.changedemo = true;
}
CL_ClearState( );
// a1ba: need to restore cl.maxclients because engine chooses
// frame backups count depending on this value
// In general, it's incorrect to call CL_InitEdicts right after
// CL_ClearState because of this bug. Some time later this logic
// should be re-done.
CL_InitEdicts( maxclients ); // re-arrange edicts
}
else Con_Printf( "Server disconnected, reconnecting\n" );
if( cls.demoplayback )
{
cl.background = (cls.demonum != -1) ? true : false;
cls.state = ca_connected;
}
else
{
// g-cont. local client skip the challenge
if( SV_Active( ))
cls.state = ca_disconnected;
else cls.state = ca_connecting;
cl.background = old_background;
cls.connect_time = MAX_HEARTBEAT;
cls.connect_retry = 0;
}
break;
case svc_setview:
CL_ParseViewEntity( msg );
break;
case svc_sound:
CL_LegacyParseSoundPacket( msg, false );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_legacy_ambientsound:
CL_LegacyParseSoundPacket( msg, true );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_time:
CL_ParseServerTime( msg );
break;
case svc_print:
Con_Printf( "%s", MSG_ReadString( 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:
CL_ParseSetAngle( msg );
break;
case svc_serverdata:
Cbuf_Execute(); // make sure any stuffed commands are done
CL_ParseServerData( msg, true );
break;
case svc_lightstyle:
CL_ParseLightStyle( msg );
break;
case svc_updateuserinfo:
CL_UpdateUserinfo( msg, true );
break;
case svc_deltatable:
Delta_ParseTableField( msg );
break;
case svc_clientdata:
CL_ParseClientData( msg );
cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_resource:
CL_ParseResource( msg );
break;
case svc_pings:
CL_UpdateUserPings( msg );
break;
case svc_particle:
CL_ParseParticles( msg );
break;
case svc_restoresound:
CL_ParseRestoreSoundPacket( msg );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_spawnstatic:
CL_LegacyParseStaticEntity( msg );
break;
case svc_event_reliable:
CL_ParseReliableEvent( msg );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_spawnbaseline:
CL_ParseBaseline( msg, true );
break;
case svc_temp_entity:
CL_ParseTempEntity( msg );
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_setpause:
cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
break;
case svc_signonnum:
CL_ParseSignon( msg );
break;
case svc_centerprint:
CL_CenterPrint( MSG_ReadString( msg ), 0.25f );
break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_legacy_modelindex:
CL_LegacyPrecacheModel( msg );
break;
case svc_legacy_soundindex:
CL_LegacyPrecacheSound( msg );
break;
case svc_cdtrack:
param1 = MSG_ReadByte( msg );
param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum
param2 = MSG_ReadByte( msg );
param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum
S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false );
break;
case svc_restore:
CL_ParseRestore( msg );
break;
case svc_legacy_eventindex:
CL_LegacyPrecacheEvent(msg);
break;
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_bspdecal:
CL_ParseStaticDecal( msg );
break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_addangle:
CL_ParseAddAngle( msg );
break;
case svc_usermessage:
CL_RegisterUserMessage( msg );
break;
case svc_packetentities:
playerbytes = CL_ParsePacketEntities( msg, false );
cl.frames[cl.parsecountmod].graphdata.players += playerbytes;
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
break;
case svc_deltapacketentities:
playerbytes = CL_ParsePacketEntities( msg, true );
cl.frames[cl.parsecountmod].graphdata.players += playerbytes;
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
break;
case svc_legacy_chokecount:
{
int i, j;
i = MSG_ReadByte( msg );
j = cls.netchan.incoming_acknowledged - 1;
for( ; i > 0 && j > cls.netchan.outgoing_sequence - CL_UPDATE_BACKUP; j-- )
{
if( cl.frames[j & CL_UPDATE_MASK].receivedtime != -3.0 )
{
cl.frames[j & CL_UPDATE_MASK].choked = true;
cl.frames[j & CL_UPDATE_MASK].receivedtime = -2.0;
i--;
}
}
break;
}
//cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = true;
//cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].receivedtime = -2.0;
break;
case svc_resourcelist:
CL_LegacyParseResourceList( msg );
break;
case svc_deltamovevars:
CL_ParseMovevars( msg );
break;
case svc_resourcerequest:
CL_ParseResourceRequest( msg );
break;
case svc_customization:
CL_ParseCustomization( msg );
break;
case svc_crosshairangle:
CL_ParseCrosshairAngle( msg );
break;
case svc_soundfade:
CL_ParseSoundFade( msg );
break;
case svc_filetxferfailed:
CL_ParseFileTransferFailed( msg );
break;
case svc_hltv:
CL_ParseHLTV( msg );
break;
case svc_director:
CL_ParseDirector( msg );
break;
case svc_resourcelocation:
CL_ParseResLocation( msg );
break;
case svc_querycvarvalue:
CL_ParseCvarValue( msg, false );
break;
case svc_querycvarvalue2:
CL_ParseCvarValue( msg, true );
break;
default:
CL_ParseUserMessage( msg, cmd );
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
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 )
{
int spawncount, i;
model_t *mod;
if( !cls.legacymode )
return;
spawncount = Q_atoi( Cmd_Argv( 1 ));
Con_Printf( "Setting up renderer...\n" );
// load tempent sprites (glowshell, muzzleflashes etc)
CL_LoadClientSprites ();
// invalidate all decal indexes
memset( cl.decal_index, 0, sizeof( cl.decal_index ));
cl.video_prepped = true;
cl.audio_prepped = true;
if( clgame.entities )
clgame.entities->model = cl.worldmodel;
// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();
CL_SetupOverviewParams();
// release unused SpriteTextures
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{
if( mod->needload == NL_UNREFERENCED && COM_CheckString( mod->name ))
Mod_FreeModel( mod );
}
// Mod_FreeUnused ();
if( host_developer.value <= DEV_NONE )
Con_ClearNotify(); // clear any lines of console text
// done with all resources, issue prespawn command.
// Include server count in case server disconnects and changes level during d/l
MSG_BeginClientCmd( &cls.netchan.message, clc_stringcmd );
MSG_WriteStringf( &cls.netchan.message, "begin %i", spawncount );
cls.signon = SIGNONS;
}
void CL_LegacyUpdateInfo( void )
{
if( !cls.legacymode )
return;
if( cls.state != ca_active )
return;
MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
}
qboolean CL_LegacyMode( void )
{
return cls.legacymode;
}

View File

@@ -54,6 +54,31 @@ void GAME_EXPORT CL_PopPMStates( void )
clgame.pushed = false; 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 CL_IsPredicted
@@ -61,7 +86,7 @@ CL_IsPredicted
*/ */
qboolean CL_IsPredicted( void ) qboolean CL_IsPredicted( void )
{ {
if( cl_nopred.value || cl.intermission ) if( cl_nopred->value || cl.intermission )
return false; return false;
// never predict the quake demos // never predict the quake demos
@@ -158,7 +183,7 @@ void CL_SetIdealPitch( void )
} }
if( steps < 2 ) return; if( steps < 2 ) return;
cl.local.idealpitch = -dir * cl_idealpitchscale.value; cl.local.idealpitch = -dir * cl_idealpitchscale->value;
} }
/* /*
@@ -209,7 +234,7 @@ void CL_CheckPredictionError( void )
// save the prediction error for interpolation // save the prediction error for interpolation
if( dist > MAX_PREDICTION_ERROR ) if( dist > MAX_PREDICTION_ERROR )
{ {
if( cl_showerror.value && host_developer.value ) if( cl_showerror->value && host_developer.value )
Con_NPrintf( 10 + ( ++pos & 3 ), "^3player teleported:^7 %.3f units\n", dist ); Con_NPrintf( 10 + ( ++pos & 3 ), "^3player teleported:^7 %.3f units\n", dist );
// a teleport or something or gamepaused // a teleport or something or gamepaused
@@ -217,7 +242,7 @@ void CL_CheckPredictionError( void )
} }
else else
{ {
if( cl_showerror.value && dist > MIN_PREDICTION_EPSILON && host_developer.value ) if( cl_showerror->value && dist > MIN_PREDICTION_EPSILON && host_developer.value )
Con_NPrintf( 10 + ( ++pos & 3 ), "^1prediction error:^7 %.3f units\n", dist ); Con_NPrintf( 10 + ( ++pos & 3 ), "^1prediction error:^7 %.3f units\n", dist );
VectorCopy( cl.frames[cmd].playerstate[cl.playernum].origin, cl.local.predicted_origins[frame] ); VectorCopy( cl.frames[cmd].playerstate[cl.playernum].origin, cl.local.predicted_origins[frame] );
@@ -228,7 +253,7 @@ void CL_CheckPredictionError( void )
// GoldSrc checks for singleplayer // GoldSrc checks for singleplayer
// we would check for local server // we would check for local server
if( dist > MIN_CORRECTION_DISTANCE && !SV_Active() ) if( dist > MIN_CORRECTION_DISTANCE && !SV_Active() )
cls.correction_time = cl_smoothtime.value; cls.correction_time = cl_smoothtime->value;
} }
} }
@@ -392,7 +417,7 @@ CL_AddLinksToPmove
collect solid entities collect solid entities
==================== ====================
*/ */
static void CL_AddLinksToPmove( frame_t *frame ) void CL_AddLinksToPmove( frame_t *frame )
{ {
entity_state_t *state; entity_state_t *state;
model_t *model; model_t *model;
@@ -508,7 +533,7 @@ void GAME_EXPORT CL_SetSolidPlayers( int playernum )
physent_t *pe; physent_t *pe;
int i; int i;
if( !cl_solid_players.value ) if( !cl_solid_players->value )
return; return;
for( i = 0; i < MAX_CLIENTS; i++ ) for( i = 0; i < MAX_CLIENTS; i++ )
@@ -662,6 +687,11 @@ cl_entity_t *CL_GetWaterEntity( const float *rgflPos )
return CL_GetEntityByIndex( entnum ); 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 ) static int GAME_EXPORT pfnTestPlayerPosition( float *pos, pmtrace_t *ptrace )
{ {
return PM_TestPlayerPosition( clgame.pmove, pos, ptrace, NULL ); return PM_TestPlayerPosition( clgame.pmove, pos, ptrace, NULL );
@@ -794,27 +824,6 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
cd = &from->client; cd = &from->client;
pmove->player_index = ps->number - 1; pmove->player_index = ps->number - 1;
// a1ba: workaround bug on old protocol 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
// either debug this, or remove when old protocol will be dropped!!!
if( pmove->player_index < 0 )
{
if( cls.legacymode )
{
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
}
else
{
// if this happens, record a demo and send it to a1ba
Host_Error( "%s: ps->number == %d\n", __func__, ps->number );
}
}
pmove->multiplayer = (cl.maxclients > 1); pmove->multiplayer = (cl.maxclients > 1);
pmove->runfuncs = runfuncs; pmove->runfuncs = runfuncs;
pmove->time = time * 1000.0f; pmove->time = time * 1000.0f;
@@ -867,7 +876,7 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
Q_strncpy( pmove->physinfo, cls.physinfo, MAX_INFO_STRING ); 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; entity_state_t *ps;
clientdata_t *cd; clientdata_t *cd;
@@ -920,7 +929,7 @@ CL_RunUsercmd
Runs prediction code for user cmd 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; usercmd_t cmd;
@@ -1096,7 +1105,7 @@ void CL_PredictMovement( qboolean repredicting )
cl.local.onground = frame->playerstate[cl.playernum].onground; cl.local.onground = frame->playerstate[cl.playernum].onground;
else cl.local.onground = -1; else cl.local.onground = -1;
if( !repredicting || !cl_lw.value ) if( !repredicting || !CVAR_TO_BOOL( cl_lw ))
cl.local.viewmodel = to->client.viewmodel; cl.local.viewmodel = to->client.viewmodel;
cl.local.repredicting = false; cl.local.repredicting = false;
cl.local.moving = false; cl.local.moving = false;
@@ -1128,7 +1137,7 @@ void CL_PredictMovement( qboolean repredicting )
cl.local.waterlevel = to->client.waterlevel; cl.local.waterlevel = to->client.waterlevel;
cl.local.usehull = to->playerstate.usehull; cl.local.usehull = to->playerstate.usehull;
if( !repredicting || !cl_lw.value ) if( !repredicting || !CVAR_TO_BOOL( cl_lw ))
cl.local.viewmodel = to->client.viewmodel; cl.local.viewmodel = to->client.viewmodel;
if( FBitSet( to->client.flags, FL_ONGROUND )) if( FBitSet( to->client.flags, FL_ONGROUND ))
@@ -1158,7 +1167,7 @@ void CL_PredictMovement( qboolean repredicting )
cl.local.moving = false; cl.local.moving = false;
} }
if( cls.correction_time > 0 && !cl_nosmooth.value && cl_smoothtime.value ) if( cls.correction_time > 0 && !cl_nosmooth->value && cl_smoothtime->value )
{ {
vec3_t delta; vec3_t delta;
float frac; float frac;
@@ -1168,14 +1177,14 @@ void CL_PredictMovement( qboolean repredicting )
cls.correction_time -= host.frametime; cls.correction_time -= host.frametime;
// Make sure smoothtime is postive // Make sure smoothtime is postive
if( cl_smoothtime.value <= 0.0f ) if( cl_smoothtime->value <= 0.0f )
Cvar_DirectSet( &cl_smoothtime, "0.1" ); Cvar_DirectSet( cl_smoothtime, "0.1" );
// Clamp from 0 to cl_smoothtime.value // Clamp from 0 to cl_smoothtime.value
cls.correction_time = bound( 0.0, cls.correction_time, cl_smoothtime.value ); cls.correction_time = bound( 0.0, cls.correction_time, cl_smoothtime->value );
// Compute backward interpolation fraction along full correction // Compute backward interpolation fraction along full correction
frac = 1.0f - cls.correction_time / cl_smoothtime.value; frac = 1.0f - cls.correction_time / cl_smoothtime->value;
// Determine how much error we still have to make up for // Determine how much error we still have to make up for
VectorSubtract( cl.simorg, cl.local.lastorigin, delta ); VectorSubtract( cl.simorg, cl.local.lastorigin, delta );

View File

@@ -232,10 +232,10 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
// loading user settings // loading user settings
CSCR_LoadDefaultCVars( "user.scr" ); CSCR_LoadDefaultCVars( "user.scr" );
if( r_decals.value > mp_decals.value ) if( r_decals->value > mp_decals.value )
Cvar_DirectSet( &r_decals, mp_decals.string ); Cvar_SetValue( "r_decals", mp_decals.value );
} }
else Cvar_DirectSet( &r_decals, NULL ); else Cvar_Reset( "r_decals" );
if( cl.background ) // tell the game parts about background state if( cl.background ) // tell the game parts about background state
Cvar_FullSet( "cl_background", "1", FCVAR_READ_ONLY ); Cvar_FullSet( "cl_background", "1", FCVAR_READ_ONLY );
@@ -258,7 +258,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle )); Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle ));
if( !cls.changelevel && !cls.changedemo ) if( !cls.changelevel && !cls.changedemo )
CL_InitEdicts( cl.maxclients ); // re-arrange edicts CL_InitEdicts (); // re-arrange edicts
// Quake just have a large packet of initialization data // Quake just have a large packet of initialization data
for( i = 1; i < MAX_MODELS; i++ ) for( i = 1; i < MAX_MODELS; i++ )
@@ -302,9 +302,9 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" )); else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" ));
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
{ {
if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name.string ), true )) if( !FS_FileExists( va( "%s.bmp", cl_levelshot_name->string ), true ))
Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen Cvar_Set( "cl_levelshot_name", "*black" ); // render a black screen
cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime) cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime)
} }
@@ -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. 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; int i, newnum, pack;
qboolean forcelink; qboolean forcelink;
@@ -565,7 +565,7 @@ CL_ParseQuakeParticles
================== ==================
*/ */
static void CL_ParseQuakeParticle( sizebuf_t *msg ) void CL_ParseQuakeParticle( sizebuf_t *msg )
{ {
int count, color; int count, color;
vec3_t org, dir; 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; int sound_num;
float vol, attn; float vol, attn;
@@ -694,13 +694,17 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
cl_entity_t *ent; cl_entity_t *ent;
int newnum; int newnum;
memset( &state, 0, sizeof( state ));
newnum = MSG_ReadWord( msg ); // entnum newnum = MSG_ReadWord( msg ); // entnum
if( newnum >= clgame.maxEntities ) if( newnum >= clgame.maxEntities )
Host_Error( "CL_AllocEdict: no free edicts\n" ); Host_Error( "CL_AllocEdict: no free edicts\n" );
ent = CL_EDICT_NUM( newnum );
memset( &ent->prevstate, 0, sizeof( ent->prevstate ));
ent->index = newnum;
// parse baseline // parse baseline
memset( &state, 0, sizeof( state ));
state.modelindex = MSG_ReadByte( msg ); state.modelindex = MSG_ReadByte( msg );
state.frame = MSG_ReadByte( msg ); state.frame = MSG_ReadByte( msg );
state.colormap = MSG_ReadByte( msg ); state.colormap = MSG_ReadByte( msg );
@@ -711,10 +715,8 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
state.angles[1] = MSG_ReadAngle( msg ); state.angles[1] = MSG_ReadAngle( msg );
state.origin[2] = MSG_ReadCoord( msg ); state.origin[2] = MSG_ReadCoord( msg );
state.angles[2] = MSG_ReadAngle( msg ); state.angles[2] = MSG_ReadAngle( msg );
ent = CL_EDICT_NUM( newnum );
ent->index = newnum;
ent->player = CL_IsPlayerIndex( newnum ); ent->player = CL_IsPlayerIndex( newnum );
memcpy( &ent->baseline, &state, sizeof( entity_state_t )); memcpy( &ent->baseline, &state, sizeof( entity_state_t ));
memcpy( &ent->prevstate, &state, sizeof( entity_state_t )); memcpy( &ent->prevstate, &state, sizeof( entity_state_t ));
} }
@@ -816,7 +818,7 @@ CL_QuakeStuffText
================== ==================
*/ */
static void CL_QuakeStuffText( const char *text ) void CL_QuakeStuffText( const char *text )
{ {
Q_strncat( cmd_buf, text, sizeof( cmd_buf )); Q_strncat( cmd_buf, text, sizeof( cmd_buf ));
@@ -831,7 +833,7 @@ CL_QuakeExecStuff
================== ==================
*/ */
static void CL_QuakeExecStuff( void ) void CL_QuakeExecStuff( void )
{ {
char *text = cmd_buf; char *text = cmd_buf;
char token[256]; char token[256];

View File

@@ -41,24 +41,11 @@ CL_CmpStudioTextures
return true if equal return true if equal
==================== ====================
*/ */
static qboolean CL_CmpStudioTextures( int numtexs, mstudiotexture_t *p1, remap_info_t *remap ) qboolean CL_CmpStudioTextures( int numtexs, mstudiotexture_t *p1, mstudiotexture_t *p2 )
{ {
int i; int i;
mstudiotexture_t *p2;
if( !p1 ) // no textures if( !p1 || !p2 ) return false;
return false;
if( !remap ) // current model has no remap
return false;
if( !remap->textures ) // shouldn't happen, just in case
return false;
if( numtexs != remap->numtextures ) // amount of textures differs, it's a different model
return false;
p2 = remap->ptexture;
for( i = 0; i < numtexs; i++, p1++, p2++ ) for( i = 0; i < numtexs; i++, p1++, p2++ )
{ {
@@ -78,7 +65,7 @@ CL_CreateRawTextureFromPixels
Convert texture_t struct into mstudiotexture_t prototype 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; static mstudiotexture_t pin;
byte *pal; byte *pal;
@@ -111,7 +98,7 @@ CL_DuplicateTexture
Dupliacte texture with remap pixels 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; const char *name;
texture_t *tx = NULL; texture_t *tx = NULL;
@@ -154,7 +141,7 @@ CL_UpdateStudioTexture
Update texture top and bottom colors 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; rgbdata_t *pic;
texture_t *tx = NULL; texture_t *tx = NULL;
@@ -215,7 +202,7 @@ CL_UpdateAliasTexture
Update texture top and bottom colors 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]; char texname[MAX_QPATH];
rgbdata_t skin, *pic; rgbdata_t skin, *pic;
@@ -247,68 +234,6 @@ static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture,
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor ); 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 CL_AllocRemapInfo
@@ -317,7 +242,7 @@ Allocate new remap info per entity
and make copy of remap textures 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; remap_info_t *info;
studiohdr_t *phdr; studiohdr_t *phdr;
@@ -357,9 +282,10 @@ static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor
if( !phdr ) return; // bad model? if( !phdr ) return; // bad model?
src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex); src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
dst = (clgame.remap_info[i] ? clgame.remap_info[i]->ptexture : NULL);
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering // NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
if( !CL_CmpStudioTextures( phdr->numtextures, src, clgame.remap_info[i] ) || clgame.remap_info[i]->model != model ) if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != model )
{ {
// this code catches studiomodel change with another studiomodel with remap textures // this code catches studiomodel change with another studiomodel with remap textures
// e.g. playermodel 'barney' with playermodel 'gordon' // e.g. playermodel 'barney' with playermodel 'gordon'
@@ -424,6 +350,68 @@ static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor
info->model = model; 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 CL_ClearAllRemaps
@@ -446,21 +434,3 @@ void CL_ClearAllRemaps( void )
} }
clgame.remap_info = NULL; 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;
}

View File

@@ -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 ) if( fileindex < 0 || fileindex >= MAX_CUSTOM )
return 0; return 0;
@@ -142,6 +142,8 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return 1; return 1;
#endif #endif
return 0; return 0;
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARAM_GAMEPAUSED: case PARAM_GAMEPAUSED:
return cl.paused; return cl.paused;
case PARM_CLIENT_INGAME: case PARM_CLIENT_INGAME:
@@ -162,14 +164,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return (intptr_t)world.deluxedata; return (intptr_t)world.deluxedata;
case PARM_SHADOWDATA: case PARM_SHADOWDATA:
return (intptr_t)world.shadowdata; return (intptr_t)world.shadowdata;
case PARM_FULLSCREEN:
return refState.fullScreen;
case PARM_WIDESCREEN:
return refState.wideScreen;
case PARM_SCREEN_WIDTH:
return refState.width;
case PARM_SCREEN_HEIGHT:
return refState.height;
default: default:
// indicates call from client.dll // indicates call from client.dll
if( checkRef ) if( checkRef )
@@ -185,30 +179,26 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return CL_IsThirdPerson(); return CL_IsThirdPerson();
case PARM_QUAKE_COMPATIBLE: case PARM_QUAKE_COMPATIBLE:
return Host_IsQuakeCompatible(); return Host_IsQuakeCompatible();
case PARM_PLAYER_INDEX:
return cl.playernum + 1;
case PARM_VIEWENT_INDEX:
return cl.viewentity;
case PARM_CONNSTATE: case PARM_CONNSTATE:
return (int)cls.state; return (int)cls.state;
case PARM_PLAYING_DEMO: case PARM_PLAYING_DEMO:
return cls.demoplayback; return cls.demoplayback;
case PARM_WATER_LEVEL: case PARM_WATER_LEVEL:
return cl.local.waterlevel; return cl.local.waterlevel;
case PARM_MAX_CLIENTS:
return cl.maxclients;
case PARM_LOCAL_HEALTH: case PARM_LOCAL_HEALTH:
return cl.local.health; return cl.local.health;
case PARM_LOCAL_GAME: case PARM_LOCAL_GAME:
return Host_IsLocalGame(); return Host_IsLocalGame();
case PARM_NUMENTITIES: case PARM_NUMENTITIES:
return pfnNumberOfEntities(); return pfnNumberOfEntities();
case PARM_GET_CLIENT_PTR: case PARM_NUMMODELS:
return (intptr_t)&cl.time; // with the offset return cl.nummodels;
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;
} }
} }
return 0; return 0;

View File

@@ -20,18 +20,18 @@ GNU General Public License for more details.
#include "input.h" #include "input.h"
#include "library.h" #include "library.h"
CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" ); convar_t *scr_centertime;
CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" ); convar_t *scr_loading;
CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" ); convar_t *scr_download;
CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" ); convar_t *scr_viewsize;
CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" ); convar_t *cl_testlights;
CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" ); convar_t *cl_allow_levelshots;
CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" ); convar_t *cl_levelshot_name;
static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" ); static convar_t *cl_envshot_size;
CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" ); convar_t *v_dark;
static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" ); static convar_t *net_speeds;
static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" ); static convar_t *cl_showfps;
static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" ); static convar_t *cl_showpos;
typedef struct typedef struct
{ {
@@ -59,7 +59,7 @@ void SCR_DrawFPS( int height )
char fpsstring[64]; char fpsstring[64];
int offset; int offset;
if( cls.state != ca_active || !cl_showfps.value || cl.background ) if( cls.state != ca_active || !cl_showfps->value || cl.background )
return; return;
switch( cls.scrshot_action ) switch( cls.scrshot_action )
@@ -95,7 +95,7 @@ void SCR_DrawFPS( int height )
if( curfps < minfps ) minfps = curfps; if( curfps < minfps ) minfps = curfps;
if( curfps > maxfps ) maxfps = curfps; if( curfps > maxfps ) maxfps = curfps;
if( cl_showfps.value == 2 ) if( cl_showfps->value == 2 )
Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps ); Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps );
else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps ); else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps );
MakeRGBA( color, 255, 255, 255, 255 ); MakeRGBA( color, 255, 255, 255, 255 );
@@ -119,7 +119,7 @@ void SCR_DrawPos( void )
cl_entity_t *ent; cl_entity_t *ent;
rgba_t color; rgba_t color;
if( cls.state != ca_active || !cl_showpos.value || cl.background ) if( cls.state != ca_active || !cl_showpos->value || cl.background )
return; return;
ent = CL_GetLocalPlayer(); ent = CL_GetLocalPlayer();
@@ -164,7 +164,7 @@ void SCR_NetSpeeds( void )
if( !host.allow_console ) if( !host.allow_console )
return; return;
if( !net_speeds.value || cls.state != ca_active ) if( !net_speeds->value || cls.state != ca_active )
return; return;
// prevent to get too big values at max // prevent to get too big values at max
@@ -252,7 +252,7 @@ VID_WriteOverviewScript
Create overview script file Create overview script file
=============== ===============
*/ */
static void VID_WriteOverviewScript( void ) void VID_WriteOverviewScript( void )
{ {
ref_overview_t *ov = &clgame.overView; ref_overview_t *ov = &clgame.overView;
string filename; string filename;
@@ -288,14 +288,9 @@ void SCR_MakeScreenShot( void )
qboolean iRet = false; qboolean iRet = false;
int viewsize; int viewsize;
if( cls.scrshot_action == scrshot_inactive )
return;
if( cls.envshot_viewsize > 0 ) if( cls.envshot_viewsize > 0 )
viewsize = cls.envshot_viewsize; viewsize = cls.envshot_viewsize;
else viewsize = cl_envshot_size.value; else viewsize = cl_envshot_size->value;
V_CheckGamma();
switch( cls.scrshot_action ) switch( cls.scrshot_action )
{ {
@@ -322,6 +317,8 @@ void SCR_MakeScreenShot( void )
if( iRet ) if( iRet )
VID_WriteOverviewScript(); // store overview script too VID_WriteOverviewScript(); // store overview script too
break; break;
case scrshot_inactive:
return;
} }
// report // report
@@ -345,11 +342,11 @@ void SCR_MakeScreenShot( void )
SCR_DrawPlaque SCR_DrawPlaque
================ ================
*/ */
static void SCR_DrawPlaque( void ) void SCR_DrawPlaque( void )
{ {
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
{ {
int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name.string, NULL, 0, TF_IMAGE ); int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal ); ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot ); ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING ); if( !cl.background ) CL_DrawHUD( CL_LOADING );
@@ -369,7 +366,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
cl.video_prepped = false; cl.video_prepped = false;
if( !Host_IsDedicated() ) if( !Host_IsDedicated() )
oldclear = gl_clear.value; oldclear = gl_clear->value;
if( CL_IsInMenu( ) && !cls.changedemo && !is_background ) if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{ {
@@ -385,7 +382,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
return; return;
if( !Host_IsDedicated() ) if( !Host_IsDedicated() )
gl_clear.value = 0.0f; gl_clear->value = 0.0f;
if( is_background ) IN_MouseSavePos( ); if( is_background ) IN_MouseSavePos( );
cls.draw_changelevel = !is_background; cls.draw_changelevel = !is_background;
@@ -394,7 +391,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
cl.background = is_background; // set right state before svc_serverdata is came cl.background = is_background; // set right state before svc_serverdata is came
if( !Host_IsDedicated() ) if( !Host_IsDedicated() )
gl_clear.value = oldclear; gl_clear->value = oldclear;
// SNDDMA_LockSound(); // SNDDMA_LockSound();
} }
@@ -416,7 +413,7 @@ void SCR_EndLoadingPlaque( void )
SCR_AddDirtyPoint 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.x1 ) scr_dirty.x1 = x;
if( x > scr_dirty.x2 ) scr_dirty.x2 = x; if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
@@ -445,7 +442,7 @@ void SCR_TileClear( void )
int i, top, bottom, left, right; int i, top, bottom, left, right;
dirty_t clear; dirty_t clear;
if( scr_viewsize.value >= 120 ) if( scr_viewsize->value >= 120 )
return; // full screen rendering return; // full screen rendering
// erase rect will be the union of the past three frames // erase rect will be the union of the past three frames
@@ -561,7 +558,7 @@ void SCR_LoadCreditsFont( void )
{ {
cl_font_t *const font = &cls.creditsFont; cl_font_t *const font = &cls.creditsFont;
qboolean success = false; qboolean success = false;
float scale = hud_fontscale.value; float scale = hud_fontscale->value;
dword crc = 0; dword crc = 0;
// replace default gfx.wad textures by current charset's font // replace default gfx.wad textures by current charset's font
@@ -573,15 +570,15 @@ void SCR_LoadCreditsFont( void )
"creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 ) "creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 )
{ {
if( FS_FileExists( charsetFnt, false )) 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 ) 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 ) 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 // copy font size for client.dll
if( success ) if( success )
@@ -603,7 +600,7 @@ SCR_InstallParticlePalette
INTERNAL RESOURCE INTERNAL RESOURCE
================ ================
*/ */
static void SCR_InstallParticlePalette( void ) void SCR_InstallParticlePalette( void )
{ {
rgbdata_t *pic; rgbdata_t *pic;
int i; int i;
@@ -649,21 +646,21 @@ void SCR_RegisterTextures( void )
// register gfx.wad images // register gfx.wad images
if( FS_FileExists( "gfx/paused.lmp", false )) 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 )) 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( FS_FileExists( "gfx/lambda.lmp", false ))
{ {
if( cl_allow_levelshots.value ) if( cl_allow_levelshots->value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|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|TF_ALLOW_NEAREST ); else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
} }
else if( FS_FileExists( "gfx/loading.lmp", false )) else if( FS_FileExists( "gfx/loading.lmp", false ))
{ {
if( cl_allow_levelshots.value ) if( cl_allow_levelshots->value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|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|TF_ALLOW_NEAREST ); 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 ); cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
@@ -676,9 +673,9 @@ SCR_SizeUp_f
Keybinding command Keybinding command
================= =================
*/ */
static void SCR_SizeUp_f( void ) void SCR_SizeUp_f( void )
{ {
Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 )); Cvar_SetValue( "viewsize", Q_min( scr_viewsize->value + 10, 120 ));
} }
@@ -689,9 +686,9 @@ SCR_SizeDown_f
Keybinding command Keybinding command
================= =================
*/ */
static void SCR_SizeDown_f( void ) void SCR_SizeDown_f( void )
{ {
Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 )); Cvar_SetValue( "viewsize", Q_max( scr_viewsize->value - 10, 30 ));
} }
/* /*
@@ -718,7 +715,9 @@ void SCR_VidInit( void )
// notify vgui about screen size change // notify vgui about screen size change
if( clgame.hInstance ) if( clgame.hInstance )
{ {
VGui_Startup( refState.width, refState.height ); // do not pass client pointer, we do not want to
// re-initialize vgui2
VGui_Startup( NULL, refState.width, refState.height );
} }
CL_ClearSpriteTextures(); // now all hud sprites are invalid CL_ClearSpriteTextures(); // now all hud sprites are invalid
@@ -729,7 +728,6 @@ void SCR_VidInit( void )
// restart console size // restart console size
Con_VidInit (); Con_VidInit ();
Touch_NotifyResize();
} }
/* /*
@@ -741,18 +739,18 @@ void SCR_Init( void )
{ {
if( scr_init ) return; if( scr_init ) return;
Cvar_RegisterVariable( &scr_centertime ); scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" );
Cvar_RegisterVariable( &cl_levelshot_name ); cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" );
Cvar_RegisterVariable( &cl_allow_levelshots ); cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
Cvar_RegisterVariable( &scr_loading ); scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" );
Cvar_RegisterVariable( &scr_download ); scr_download = Cvar_Get( "scr_download", "-1", 0, "downloading bar progress" );
Cvar_RegisterVariable( &cl_testlights ); cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" );
Cvar_RegisterVariable( &cl_envshot_size ); cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", FCVAR_ARCHIVE, "envshot size of cube side" );
Cvar_RegisterVariable( &v_dark ); v_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" );
Cvar_RegisterVariable( &scr_viewsize ); scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" );
Cvar_RegisterVariable( &net_speeds ); net_speeds = Cvar_Get( "net_speeds", "0", FCVAR_ARCHIVE, "show network packets" );
Cvar_RegisterVariable( &cl_showfps ); cl_showfps = Cvar_Get( "cl_showfps", "0", FCVAR_ARCHIVE, "show client fps" );
Cvar_RegisterVariable( &cl_showpos ); cl_showpos = Cvar_Get( "cl_showpos", "0", FCVAR_ARCHIVE, "show local player position and velocity" );
// register our commands // register our commands
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" ); Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );

View File

@@ -57,7 +57,35 @@ const char *cl_default_sprites[] =
"sprites/shellchrome.spr", "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 ) void CL_AddClientResources( void )
{ {
const char *snd;
char filepath[MAX_QPATH]; char filepath[MAX_QPATH];
int i; int i;
@@ -134,37 +161,37 @@ void CL_AddClientResources( void )
} }
// then check sounds // 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 )) 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 )) 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 )) 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 #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 )) if( !FS_FileExists( filepath, false ))
CL_AddClientResource( snd, t_sound ); CL_AddClientResource( cl_ricochet_sounds[i], t_sound );
} }
#endif #endif
} }
@@ -228,7 +255,7 @@ CL_PrepareTEnt
set default values set default values
============== ==============
*/ */
static void CL_PrepareTEnt( TEMPENTITY *pTemp, model_t *pmodel ) void CL_PrepareTEnt( TEMPENTITY *pTemp, model_t *pmodel )
{ {
int frameCount = 0; int frameCount = 0;
int modelIndex = 0; int modelIndex = 0;
@@ -269,10 +296,10 @@ CL_TempEntPlaySound
play collide sound play collide sound
============== ==============
*/ */
static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp ) void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
{ {
float fvol; float fvol;
const char *soundname = NULL; char soundname[32];
qboolean isshellcasing = false; qboolean isshellcasing = false;
int zvel; int zvel;
@@ -283,39 +310,36 @@ static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
switch( pTemp->hitSound ) switch( pTemp->hitSound )
{ {
case BOUNCE_GLASS: case BOUNCE_GLASS:
soundname = SoundList_GetRandom( BounceGlass ); Q_snprintf( soundname, sizeof( soundname ), "debris/glass%i.wav", COM_RandomLong( 1, 4 ));
break; break;
case BOUNCE_METAL: case BOUNCE_METAL:
soundname = SoundList_GetRandom( BounceMetal ); Q_snprintf( soundname, sizeof( soundname ), "debris/metal%i.wav", COM_RandomLong( 1, 6 ));
break; break;
case BOUNCE_FLESH: case BOUNCE_FLESH:
soundname = SoundList_GetRandom( BounceFlesh ); Q_snprintf( soundname, sizeof( soundname ), "debris/flesh%i.wav", COM_RandomLong( 1, 7 ));
break; break;
case BOUNCE_WOOD: case BOUNCE_WOOD:
soundname = SoundList_GetRandom( BounceWood ); Q_snprintf( soundname, sizeof( soundname ), "debris/wood%i.wav", COM_RandomLong( 1, 4 ));
break; break;
case BOUNCE_SHRAP: case BOUNCE_SHRAP:
soundname = SoundList_GetRandom( Ricochet ); Q_strncpy( soundname, cl_ricochet_sounds[COM_RandomLong( 0, 4 )], sizeof( soundname ) );
break; break;
case BOUNCE_SHOTSHELL: 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 isshellcasing = true; // shell casings have different playback parameters
fvol = 0.5f; fvol = 0.5f;
break; break;
case BOUNCE_SHELL: 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 isshellcasing = true; // shell casings have different playback parameters
break; break;
case BOUNCE_CONCRETE: case BOUNCE_CONCRETE:
soundname = SoundList_GetRandom( BounceConcrete ); Q_snprintf( soundname, sizeof( soundname ), "debris/concrete%i.wav", COM_RandomLong( 1, 3 ));
break; break;
default: // null sound default: // null sound
return; return;
} }
if( !soundname )
return;
zvel = abs( pTemp->entity.baseline.origin[2] ); zvel = abs( pTemp->entity.baseline.origin[2] );
// only play one out of every n // only play one out of every n
@@ -356,7 +380,7 @@ CL_TEntAddEntity
add entity to renderlist add entity to renderlist
============== ==============
*/ */
static int CL_TempEntAddEntity( cl_entity_t *pEntity ) int CL_TempEntAddEntity( cl_entity_t *pEntity )
{ {
vec3_t mins, maxs; vec3_t mins, maxs;
@@ -408,7 +432,7 @@ CL_TEntAddEntity
free the first low priority tempent it finds. free the first low priority tempent it finds.
============== ==============
*/ */
static qboolean CL_FreeLowPriorityTempEnt( void ) qboolean CL_FreeLowPriorityTempEnt( void )
{ {
TEMPENTITY *pActive = cl_active_tents; TEMPENTITY *pActive = cl_active_tents;
TEMPENTITY *pPrev = NULL; TEMPENTITY *pPrev = NULL;
@@ -1465,7 +1489,7 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
=============== ===============
R_SparkEffect 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 ) 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 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; sound_t handle;
handle = S_RegisterSound( name );
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
}
static void R_RicochetSoundByIndex( const vec3_t pos, int idx ) handle = S_RegisterSound( cl_ricochet_sounds[sound] );
{
const char *name = SoundList_Get( Ricochet, idx ); S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
if( name )
R_RicochetSoundByName( pos, name );
} }
void GAME_EXPORT R_RicochetSound( const vec3_t pos ) void GAME_EXPORT R_RicochetSound( const vec3_t pos )
{ {
const char *name = SoundList_GetRandom( Ricochet ); R_RicochetSound_( pos, COM_RandomLong( 0, 4 ));
if( name )
R_RicochetSoundByName( pos, name );
} }
/* /*
@@ -1646,14 +1663,10 @@ void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerat
if( !FBitSet( flags, TE_EXPLFLAG_NOSOUND )) if( !FBitSet( flags, TE_EXPLFLAG_NOSOUND ))
{ {
const char *name = SoundList_GetRandom( Explode ); hSound = S_RegisterSound( cl_explode_sounds[COM_RandomLong( 0, 2 )] );
if( name )
{
hSound = S_RegisterSound( name );
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.3f, PITCH_NORM, 0 ); 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; cl_entity_t *pEnt;
dlight_t *dl; dlight_t *dl;
sound_t hSound; sound_t hSound;
const char *name;
if( cls.legacymode ) if( cls.legacymode )
iSize = MSG_ReadByte( msg ); iSize = MSG_ReadByte( msg );
@@ -1954,11 +1966,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[2] = MSG_ReadCoord( &buf ); pos[2] = MSG_ReadCoord( &buf );
R_BlobExplosion( pos ); R_BlobExplosion( pos );
if(( name = SoundList_Get( Explode, 0 ))) hSound = S_RegisterSound( cl_explode_sounds[0] );
{
hSound = S_RegisterSound( name );
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 ); S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
}
break; break;
case TE_SMOKE: case TE_SMOKE:
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
@@ -2011,11 +2020,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
dl->die = cl.time + 0.5; dl->die = cl.time + 0.5;
dl->decay = 300; dl->decay = 300;
if(( name = SoundList_Get( Explode, 0 ))) hSound = S_RegisterSound( cl_explode_sounds[0] );
{ S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 0.6f, PITCH_NORM, 0 );
hSound = S_RegisterSound( name );
S_StartSound( pos, -1, CHAN_AUTO, hSound, VOL_NORM, 1.0f, PITCH_NORM, 0 );
}
break; break;
case TE_BSPDECAL: case TE_BSPDECAL:
case TE_DECAL: case TE_DECAL:
@@ -2243,8 +2249,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, 0, pos, 0 ); CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, 0, pos, 0 );
R_BulletImpactParticles( pos ); R_BulletImpactParticles( pos );
flags = COM_RandomLong( 0, 0x7fff ); flags = COM_RandomLong( 0, 0x7fff );
if( flags < 0x3fff && ( count = SoundList_Count( Ricochet ))) if( flags < 0x3fff )
R_RicochetSoundByIndex( pos, flags % count ); R_RicochetSound_( pos, flags % 5 );
break; break;
case TE_SPRAY: case TE_SPRAY:
case TE_SPRITE_SPRAY: case TE_SPRITE_SPRAY:
@@ -2408,7 +2414,7 @@ LIGHT STYLE MANAGEMENT
CL_ClearLightStyles CL_ClearLightStyles
================ ================
*/ */
static void CL_ClearLightStyles( void ) void CL_ClearLightStyles( void )
{ {
memset( cl.lightstyles, 0, sizeof( cl.lightstyles )); memset( cl.lightstyles, 0, sizeof( cl.lightstyles ));
} }
@@ -2466,7 +2472,7 @@ dlight_t cl_elights[MAX_ELIGHTS];
CL_ClearDlights CL_ClearDlights
================ ================
*/ */
static void CL_ClearDlights( void ) void CL_ClearDlights( void )
{ {
memset( cl_dlights, 0, sizeof( cl_dlights )); memset( cl_dlights, 0, sizeof( cl_dlights ));
memset( cl_elights, 0, sizeof( cl_elights )); memset( cl_elights, 0, sizeof( cl_elights ));
@@ -2618,12 +2624,12 @@ CL_UpdateFlashlight
update client flashlight 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 forward, view_ofs;
vec3_t vecSrc, vecEnd; vec3_t vecSrc, vecEnd;
float falloff; float falloff;
pmtrace_t trace; pmtrace_t *trace;
cl_entity_t *hit; cl_entity_t *hit;
dlight_t *dl; dlight_t *dl;
@@ -2654,65 +2660,32 @@ static void CL_UpdateFlashlight( cl_entity_t *ent )
VectorAdd( ent->origin, view_ofs, vecSrc ); VectorAdd( ent->origin, view_ofs, vecSrc );
VectorMA( vecSrc, FLASHLIGHT_DISTANCE, forward, vecEnd ); VectorMA( vecSrc, FLASHLIGHT_DISTANCE, forward, vecEnd );
trace = CL_TraceLine( vecSrc, vecEnd, PM_STUDIO_BOX ); trace = CL_VisTraceLine( vecSrc, vecEnd, PM_STUDIO_BOX );
// update flashlight endpos // update flashlight endpos
dl = CL_AllocDlight( ent->index ); dl = CL_AllocDlight( ent->index );
#if 1 #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 )) if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
VectorCopy( hit->origin, dl->origin ); VectorCopy( hit->origin, dl->origin );
else VectorCopy( trace.endpos, dl->origin ); else VectorCopy( trace->endpos, dl->origin );
#else #else
VectorCopy( trace->endpos, dl->origin ); VectorCopy( trace->endpos, dl->origin );
#endif #endif
// compute falloff // compute falloff
falloff = trace.fraction * FLASHLIGHT_DISTANCE; falloff = trace->fraction * FLASHLIGHT_DISTANCE;
if( falloff < 500.0f ) falloff = 1.0f; if( falloff < 500.0f ) falloff = 1.0f;
else falloff = 500.0f / falloff; else falloff = 500.0f / falloff;
falloff *= falloff; falloff *= falloff;
// apply brigthness to dlight // apply brigthness to dlight
dl->color.r = dl->color.g = dl->color.b = bound( 0, falloff * 255, 255 ); dl->color.r = bound( 0, falloff * 255, 255 );
dl->color.g = bound( 0, falloff * 255, 255 );
dl->color.b = bound( 0, falloff * 255, 255 );
dl->die = cl.time + 0.01f; // die on next frame dl->die = cl.time + 0.01f; // die on next frame
dl->radius = 80; 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 CL_AddEntityEffects
@@ -2722,41 +2695,50 @@ apply various effects to entity origin or attachment
*/ */
void CL_AddEntityEffects( cl_entity_t *ent ) void CL_AddEntityEffects( cl_entity_t *ent )
{ {
// players have special set of effects, from CL_LinkPlayers // yellow flies effect 'monster stuck in the wall'
if( ent->player && ent->index != cl.viewentity ) if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ) && !RP_LOCALCLIENT( ent ))
{ R_EntityParticles( ent );
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
R_EntityBrightlight( ent, ent->index /* 4 in GoldSrc */, 0 );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT )) if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
R_EntityDimlight( ent, ent->index /* 4 in GoldSrc */ );
}
else if( RP_LOCALCLIENT( ent ))
{ {
// from CL_PlayerFlashlight if( ent->player && !Host_IsQuakeCompatible( ))
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT )) {
R_EntityBrightlight( ent, ent->index /* 1 in GoldSrc */, 400 );
else if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
CL_UpdateFlashlight( ent ); CL_UpdateFlashlight( ent );
} }
else else
{ {
// from CL_LinkPacketEntities dlight_t *dl = CL_AllocDlight( ent->index );
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD )) dl->color.r = dl->color.g = dl->color.b = 100;
R_EntityParticles( ent ); dl->radius = COM_RandomFloat( 200, 231 );
VectorCopy( ent->origin, dl->origin );
dl->die = cl.time + 0.001;
}
}
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT )) if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
R_EntityBrightlight( ent, ent->index, 0 ); {
dlight_t *dl = CL_AllocDlight( ent->index );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT )) dl->color.r = dl->color.g = dl->color.b = 250;
R_EntityDimlight( ent, ent->index ); 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;
}
// add light effect
if( FBitSet( ent->curstate.effects, EF_LIGHT )) if( FBitSet( ent->curstate.effects, EF_LIGHT ))
R_EntityLight( ent, ent->curstate.number ); {
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 // 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 ); dlight_t *dl = CL_AllocDlight( ent->index );
vec3_t fv; vec3_t fv;
@@ -2785,11 +2767,15 @@ void CL_AddModelEffects( cl_entity_t *ent )
vec3_t neworigin; vec3_t neworigin;
vec3_t oldorigin; vec3_t oldorigin;
if( !ent->model || ent->player ) if( !ent->model ) return;
return;
if( ent->model->type != mod_alias && ent->model->type != mod_studio ) switch( ent->model->type )
return; {
case mod_alias:
case mod_studio:
break;
default: return;
}
if( cls.demoplayback == DEMO_QUAKE1 ) if( cls.demoplayback == DEMO_QUAKE1 )
{ {
@@ -2809,15 +2795,19 @@ void CL_AddModelEffects( cl_entity_t *ent )
if( FBitSet( ent->model->flags, STUDIO_GIB )) if( FBitSet( ent->model->flags, STUDIO_GIB ))
R_RocketTrail( oldorigin, neworigin, 2 ); 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 ); 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 ); 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 ); 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; dl->color.r = dl->color.g = dl->color.b = 200;
VectorCopy( ent->origin, dl->origin ); VectorCopy( ent->origin, dl->origin );
@@ -2831,9 +2821,11 @@ void CL_AddModelEffects( cl_entity_t *ent )
R_RocketTrail( oldorigin, neworigin, 0 ); 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 ); 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 ); R_RocketTrail( oldorigin, neworigin, 6 );
} }
@@ -2851,10 +2843,10 @@ void CL_TestLights( void )
float f, r; float f, r;
dlight_t *dl; dlight_t *dl;
if( !cl_testlights.value ) if( !CVAR_TO_BOOL( cl_testlights ))
return; return;
numLights = bound( 1, cl_testlights.value, MAX_DLIGHTS ); numLights = bound( 1, cl_testlights->value, MAX_DLIGHTS );
AngleVectors( cl.viewangles, forward, right, NULL ); AngleVectors( cl.viewangles, forward, right, NULL );
for( i = 0; i < numLights; i++ ) for( i = 0; i < numLights; i++ )
@@ -2913,7 +2905,7 @@ CL_PlayerDecal
spray custom colored decal (clan logo etc) 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; int textureIndex = 0;
customization_t *pCust = NULL; customization_t *pCust = NULL;

View File

@@ -81,6 +81,7 @@ void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b );
void R_RicochetSound( const vec3_t pos ); void R_RicochetSound( const vec3_t pos );
struct dlight_s *CL_AllocDlight( int key ); struct dlight_s *CL_AllocDlight( int key );
struct dlight_s *CL_AllocElight( 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_AddEntityEffects( cl_entity_t *ent );
void CL_AddModelEffects( cl_entity_t *ent ); void CL_AddModelEffects( cl_entity_t *ent );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags ); void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );

View File

@@ -68,7 +68,7 @@ qboolean SCR_NextMovie( void )
return true; return true;
} }
static void SCR_CreateStartupVids( void ) void SCR_CreateStartupVids( void )
{ {
file_t *f; file_t *f;
@@ -202,6 +202,7 @@ SCR_PlayCinematic
*/ */
qboolean SCR_PlayCinematic( const char *arg ) qboolean SCR_PlayCinematic( const char *arg )
{ {
string path;
const char *fullpath; const char *fullpath;
fullpath = FS_GetDiskPath( arg, false ); fullpath = FS_GetDiskPath( arg, false );

View File

@@ -29,7 +29,7 @@ V_CalcViewRect
calc frame rectangle (Quake1 style) calc frame rectangle (Quake1 style)
=============== ===============
*/ */
static void V_CalcViewRect( void ) void V_CalcViewRect( void )
{ {
qboolean full = false; qboolean full = false;
int sb_lines; int sb_lines;
@@ -39,7 +39,7 @@ static void V_CalcViewRect( void )
{ {
// intermission is always full screen // intermission is always full screen
if( cl.intermission ) size = 120.0f; if( cl.intermission ) size = 120.0f;
else size = scr_viewsize.value; else size = scr_viewsize->value;
if( size >= 120.0f ) if( size >= 120.0f )
sb_lines = 0; // no status bar at all sb_lines = 0; // no status bar at all
@@ -47,12 +47,12 @@ static void V_CalcViewRect( void )
sb_lines = 24; // no inventory sb_lines = 24; // no inventory
else sb_lines = 48; else sb_lines = 48;
if( scr_viewsize.value >= 100.0f ) if( scr_viewsize->value >= 100.0f )
{ {
full = true; full = true;
size = 100.0f; size = 100.0f;
} }
else size = scr_viewsize.value; else size = scr_viewsize->value;
if( cl.intermission ) if( cl.intermission )
{ {
@@ -88,7 +88,7 @@ static void V_CalcViewRect( void )
V_SetupViewModel V_SetupViewModel
=============== ===============
*/ */
static void V_SetupViewModel( void ) void V_SetupViewModel( void )
{ {
cl_entity_t *view = &clgame.viewent; cl_entity_t *view = &clgame.viewent;
player_info_t *info = &cl.players[cl.playernum]; player_info_t *info = &cl.players[cl.playernum];
@@ -118,7 +118,7 @@ static void V_SetupViewModel( void )
V_SetRefParams V_SetRefParams
=============== ===============
*/ */
static void V_SetRefParams( ref_params_t *fd ) void V_SetRefParams( ref_params_t *fd )
{ {
memset( fd, 0, sizeof( ref_params_t )); memset( fd, 0, sizeof( ref_params_t ));
@@ -144,7 +144,7 @@ static void V_SetRefParams( ref_params_t *fd )
VectorCopy( cl.viewangles, fd->cl_viewangles ); VectorCopy( cl.viewangles, fd->cl_viewangles );
fd->health = cl.local.health; fd->health = cl.local.health;
VectorCopy( cl.crosshairangle, fd->crosshairangle ); VectorCopy( cl.crosshairangle, fd->crosshairangle );
fd->viewsize = scr_viewsize.value; fd->viewsize = scr_viewsize->value;
VectorCopy( cl.punchangle, fd->punchangle ); VectorCopy( cl.punchangle, fd->punchangle );
fd->maxclients = cl.maxclients; fd->maxclients = cl.maxclients;
@@ -182,7 +182,7 @@ V_MergeOverviewRefdef
merge refdef with overview settings 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; ref_overview_t *ov = &clgame.overView;
float aspect; float aspect;
@@ -281,7 +281,7 @@ static void V_AdjustFov( float *fov_x, float *fov_y, float width, float height,
V_GetRefParams 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 // part1: deniable updates
VectorCopy( fd->simvel, cl.simvel ); VectorCopy( fd->simvel, cl.simvel );
@@ -311,7 +311,7 @@ static void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
rvp->fov_y = V_CalcFov( &rvp->fov_x, clgame.viewport[2], clgame.viewport[3] ); rvp->fov_y = V_CalcFov( &rvp->fov_x, clgame.viewport[2], clgame.viewport[3] );
// adjust FOV for widescreen // adjust FOV for widescreen
if( refState.wideScreen && r_adjust_fov.value ) if( refState.wideScreen && r_adjust_fov->value )
V_AdjustFov( &rvp->fov_x, &rvp->fov_y, clgame.viewport[2], clgame.viewport[3], false ); V_AdjustFov( &rvp->fov_x, &rvp->fov_y, clgame.viewport[2], clgame.viewport[3], false );
rvp->flags = 0; rvp->flags = 0;
@@ -339,7 +339,7 @@ qboolean V_PreRender( void )
// if the screen is disabled (loading plaque is up) // if the screen is disabled (loading plaque is up)
if( cls.disable_screen ) if( cls.disable_screen )
{ {
if(( host.realtime - cls.disable_screen ) > cl_timeout.value ) if(( host.realtime - cls.disable_screen ) > cl_timeout->value )
{ {
Con_Reportf( "V_PreRender: loading plaque timed out\n" ); Con_Reportf( "V_PreRender: loading plaque timed out\n" );
cls.disable_screen = 0.0f; cls.disable_screen = 0.0f;
@@ -347,8 +347,6 @@ qboolean V_PreRender( void )
return false; return false;
} }
V_CheckGamma();
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active )); ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
GL_UpdateSwapInterval( ); GL_UpdateSwapInterval( );
@@ -366,13 +364,11 @@ V_RenderView
*/ */
void V_RenderView( void ) void V_RenderView( void )
{ {
// HACKHACK: make ref params static ref_params_t rp;
// not really critical but allows client.dll to take address of refdef and don't trigger ASan
static ref_params_t rp;
ref_viewpass_t rvp; ref_viewpass_t rvp;
int viewnum = 0; int viewnum = 0;
if( !cl.video_prepped || ( !ui_renderworld.value && UI_IsVisible() && !cl.background )) if( !cl.video_prepped || ( !ui_renderworld->value && UI_IsVisible() && !cl.background ))
return; // still loading return; // still loading
V_CalcViewRect (); // compute viewport rectangle V_CalcViewRect (); // compute viewport rectangle
@@ -408,14 +404,14 @@ void V_RenderView( void )
#define NODE_INTERVAL_X(x) (x * 16.0f) #define NODE_INTERVAL_X(x) (x * 16.0f)
#define NODE_INTERVAL_Y(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; 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 ) ); 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.Begin( TRI_LINES );
ref.dllFuncs.Vertex3f( x, y, 0 ); ref.dllFuncs.Vertex3f( x, y, 0 );
@@ -423,7 +419,7 @@ static void R_DrawNodeConnection( float x, float y, float x2, float y2 )
ref.dllFuncs.End( ); 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; float downScale = scale * 0.8f;
@@ -470,13 +466,13 @@ static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int show
world.recursion_level--; world.recursion_level--;
} }
static void R_ShowTree( void ) void R_ShowTree( void )
{ {
float x = (float)((refState.width - (int)POINT_SIZE) >> 1); float x = (float)((refState.width - (int)POINT_SIZE) >> 1);
float y = NODE_INTERVAL_Y(1.0f); float y = NODE_INTERVAL_Y(1.0f);
mleaf_t *viewleaf; mleaf_t *viewleaf;
if( !cl.worldmodel || !r_showtree.value ) if( !cl.worldmodel || !CVAR_TO_BOOL( r_showtree ))
return; return;
world.recursion_level = 0; world.recursion_level = 0;
@@ -551,8 +547,5 @@ void V_PostRender( void )
SCR_MakeScreenShot(); SCR_MakeScreenShot();
ref.dllFuncs.R_AllowFog( true ); ref.dllFuncs.R_AllowFog( true );
Platform_SetTimer( 0.0f );
ref.dllFuncs.R_EndFrame(); ref.dllFuncs.R_EndFrame();
V_CheckGammaEnd();
} }

View File

@@ -174,26 +174,6 @@ typedef struct
// at every server map change // at every server map change
typedef struct 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 servercount; // server identification for prespawns
int validsequence; // this is the sequence number of the last good int validsequence; // this is the sequence number of the last good
// world snapshot/update we got. If this is 0, we can't // 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 video_prepped; // false if on new level or new ref dll
qboolean audio_prepped; // false if on new level or new snd dll qboolean audio_prepped; // false if on new level or new snd dll
qboolean paused;
int delta_sequence; // acknowledged sequence number int delta_sequence; // acknowledged sequence number
@@ -224,6 +205,11 @@ typedef struct
runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds
local_state_t predicted_frames[MULTIPLAYER_BACKUP]; // local client state 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 double timedelta; // floating delta between two updates
char serverinfo[MAX_SERVERINFO_STRING]; char serverinfo[MAX_SERVERINFO_STRING];
@@ -237,6 +223,7 @@ typedef struct
// player final info // player final info
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
int viewentity;
vec3_t viewangles; vec3_t viewangles;
vec3_t viewheight; vec3_t viewheight;
vec3_t punchangle; vec3_t punchangle;
@@ -249,9 +236,14 @@ typedef struct
float addangletotal; float addangletotal;
float prevaddangletotal; float prevaddangletotal;
// predicted velocity // predicted origin and velocity
vec3_t simorg;
vec3_t simvel; vec3_t simvel;
// server state information
int playernum;
int maxclients;
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES]; entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
int instanced_baseline_count; int instanced_baseline_count;
@@ -259,6 +251,8 @@ typedef struct
char event_precache[MAX_EVENTS][MAX_QPATH]; char event_precache[MAX_EVENTS][MAX_QPATH];
char files_precache[MAX_CUSTOM][MAX_QPATH]; char files_precache[MAX_CUSTOM][MAX_QPATH];
lightstyle_t lightstyles[MAX_LIGHTSTYLES]; lightstyle_t lightstyles[MAX_LIGHTSTYLES];
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
int nummodels;
int numfiles; int numfiles;
consistency_t consistency_list[MAX_MODELS]; consistency_t consistency_list[MAX_MODELS];
@@ -342,7 +336,8 @@ typedef struct
byte charWidths[256]; // scaled widths byte charWidths[256]; // scaled widths
int charHeight; // scaled height int charHeight; // scaled height
int type; // fixed width font or variable 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 qboolean valid; // all rectangles are valid
} cl_font_t; } cl_font_t;
@@ -428,6 +423,13 @@ typedef struct
float applied_angle; float applied_angle;
} screen_shake_t; } screen_shake_t;
typedef enum
{
NET_REQUEST_CANCEL = 0, // request was cancelled for some reasons
NET_REQUEST_GAMEUI, // called from GameUI
NET_REQUEST_CLIENT, // called from Client
} net_request_type_t;
typedef struct typedef struct
{ {
net_response_t resp; net_response_t resp;
@@ -489,7 +491,9 @@ typedef struct
client_textmessage_t *titles; // title messages, not network messages client_textmessage_t *titles; // title messages, not network messages
int numTitles; int numTitles;
net_request_type_t request_type; // filter the requests
net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more
net_request_t *master_request; // queued master request
efrag_t *free_efrags; // linked efrags efrag_t *free_efrags; // linked efrags
cl_entity_t viewent; // viewmodel cl_entity_t viewent; // viewmodel
@@ -623,10 +627,7 @@ typedef struct
file_t *demofile; file_t *demofile;
file_t *demoheader; // contain demo startup info in case we record a demo on this level file_t *demoheader; // contain demo startup info in case we record a demo on this level
qboolean internetservers_wait; // internetservers is waiting for dns request qboolean internetservers_wait; // internetservers is waiting for dns request
qboolean internetservers_pending; // if true, clean master server pings qboolean internetservers_pending; // internetservers is waiting for dns request
uint32_t internetservers_key; // compare key to validate master server reply
char internetservers_query[512]; // cached query
uint32_t internetservers_query_len;
// legacy mode support // legacy mode support
qboolean legacymode; // one-way 48 protocol compatibility qboolean legacymode; // one-way 48 protocol compatibility
@@ -658,55 +659,51 @@ extern convar_t cl_logocolor;
extern convar_t cl_allow_download; extern convar_t cl_allow_download;
extern convar_t cl_allow_upload; extern convar_t cl_allow_upload;
extern convar_t cl_download_ingame; extern convar_t cl_download_ingame;
extern convar_t cl_nopred; extern convar_t *cl_nopred;
extern convar_t cl_timeout; extern convar_t *cl_timeout;
extern convar_t cl_nodelta; extern convar_t *cl_nodelta;
extern convar_t cl_interp; extern convar_t *cl_interp;
extern convar_t cl_nointerp; extern convar_t *cl_nointerp;
extern convar_t cl_showerror; extern convar_t *cl_showerror;
extern convar_t cl_nosmooth; extern convar_t *cl_nosmooth;
extern convar_t cl_smoothtime; extern convar_t *cl_smoothtime;
extern convar_t cl_crosshair; extern convar_t *cl_crosshair;
extern convar_t cl_testlights; extern convar_t *cl_testlights;
extern convar_t cl_cmdrate; extern convar_t *cl_cmdrate;
extern convar_t cl_updaterate; extern convar_t *cl_updaterate;
extern convar_t cl_solid_players; extern convar_t *cl_solid_players;
extern convar_t cl_idealpitchscale; extern convar_t *cl_idealpitchscale;
extern convar_t cl_allow_levelshots; extern convar_t *cl_allow_levelshots;
extern convar_t cl_lightstyle_lerping; extern convar_t *cl_lightstyle_lerping;
extern convar_t cl_draw_particles; extern convar_t *cl_draw_particles;
extern convar_t cl_draw_tracers; extern convar_t *cl_draw_tracers;
extern convar_t cl_levelshot_name; extern convar_t *cl_levelshot_name;
extern convar_t cl_draw_beams; extern convar_t *cl_draw_beams;
extern convar_t cl_clockreset; extern convar_t *cl_clockreset;
extern convar_t cl_fixtimerate; extern convar_t *cl_fixtimerate;
extern convar_t hud_fontscale; extern convar_t *hud_fontscale;
extern convar_t hud_fontrender; extern convar_t *hud_scale;
extern convar_t hud_scale; extern convar_t *gl_showtextures;
extern convar_t hud_scale_minimal_width; extern convar_t *cl_bmodelinterp;
extern convar_t r_showtextures; extern convar_t *cl_lw; // local weapons
extern convar_t cl_bmodelinterp; extern convar_t *cl_charset;
extern convar_t cl_lw; // local weapons extern convar_t *cl_trace_messages;
extern convar_t cl_charset; extern convar_t *hud_utf8;
extern convar_t cl_trace_stufftext; extern convar_t *cl_showevents;
extern convar_t cl_trace_messages; extern convar_t *scr_centertime;
extern convar_t cl_trace_events; extern convar_t *scr_viewsize;
extern convar_t hud_utf8; extern convar_t *scr_loading;
extern convar_t cl_showevents; extern convar_t *v_dark; // start from dark
extern convar_t scr_centertime; extern convar_t *net_graph;
extern convar_t scr_viewsize; extern convar_t *rate;
extern convar_t scr_loading; extern convar_t *m_ignore;
extern convar_t v_dark; // start from dark extern convar_t *r_showtree;
extern convar_t net_graph; extern convar_t *ui_renderworld;
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_SetLightstyle( int style, const char* s, float f );
void CL_RunLightStyles( void );
void CL_DecayLights( void ); void CL_DecayLights( void );
dlight_t *CL_GetDynamicLight( int number ); dlight_t *CL_GetDynamicLight( int number );
dlight_t *CL_GetEntityLight( int number ); dlight_t *CL_GetEntityLight( int number );
@@ -717,8 +714,12 @@ dlight_t *CL_GetEntityLight( int number );
// cl_cmds.c // cl_cmds.c
// //
void CL_Quit_f( void ); 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_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_LevelShot_f( void );
void CL_SetSky_f( void ); void CL_SetSky_f( void );
void SCR_Viewpos_f( void ); void SCR_Viewpos_f( void );
@@ -739,6 +740,8 @@ void CL_ClearResourceLists( void );
void CL_Parse_Debug( qboolean enable ); void CL_Parse_Debug( qboolean enable );
void CL_Parse_RecordCommand( int cmd, int startoffset ); void CL_Parse_RecordCommand( int cmd, int startoffset );
void CL_ResetFrame( frame_t *frame ); void CL_ResetFrame( frame_t *frame );
void CL_WriteMessageHistory( void );
const char *CL_MsgInfo( int cmd );
// //
// cl_efx.c // cl_efx.c
@@ -749,6 +752,7 @@ void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel );
// cl_main.c // cl_main.c
// //
void CL_Init( void ); void CL_Init( void );
void CL_SendCommand( void );
void CL_Disconnect_f( void ); void CL_Disconnect_f( void );
void CL_ProcessFile( qboolean successfully_received, const char *filename ); void CL_ProcessFile( qboolean successfully_received, const char *filename );
void CL_WriteUsercmd( sizebuf_t *msg, int from, int to ); void CL_WriteUsercmd( sizebuf_t *msg, int from, int to );
@@ -757,8 +761,10 @@ qboolean CL_PrecacheResources( void );
void CL_SetupOverviewParams( void ); void CL_SetupOverviewParams( void );
void CL_UpdateFrameLerp( void ); void CL_UpdateFrameLerp( void );
int CL_IsDevOverviewMode( void ); int CL_IsDevOverviewMode( void );
void CL_PingServers_f( void );
void CL_SignonReply( void ); void CL_SignonReply( void );
void CL_ClearState( void ); void CL_ClearState( void );
size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat );
// //
// cl_demo.c // cl_demo.c
@@ -774,6 +780,8 @@ void CL_CheckStartupDemos( void );
void CL_WriteDemoJumpTime( void ); void CL_WriteDemoJumpTime( void );
void CL_CloseDemoHeader( void ); void CL_CloseDemoHeader( void );
void CL_DemoCompleted( void ); void CL_DemoCompleted( void );
void CL_StopPlayback( void );
void CL_StopRecord( void );
void CL_PlayDemo_f( void ); void CL_PlayDemo_f( void );
void CL_TimeDemo_f( void ); void CL_TimeDemo_f( void );
void CL_StartDemos_f( void ); void CL_StartDemos_f( void );
@@ -781,7 +789,6 @@ void CL_Demos_f( void );
void CL_DeleteDemo_f( void ); void CL_DeleteDemo_f( void );
void CL_Record_f( void ); void CL_Record_f( void );
void CL_Stop_f( void ); void CL_Stop_f( void );
int CL_GetDemoComment( const char *demoname, char *comment );
// //
// cl_events.c // cl_events.c
@@ -789,9 +796,12 @@ int CL_GetDemoComment( const char *demoname, char *comment );
void CL_ParseEvent( sizebuf_t *msg ); void CL_ParseEvent( sizebuf_t *msg );
void CL_ParseReliableEvent( sizebuf_t *msg ); void CL_ParseReliableEvent( sizebuf_t *msg );
void CL_SetEventIndex( const char *szEvName, int ev_index ); 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, 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 ); 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_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func );
void CL_BatchResourceRequest( qboolean initialize );
int CL_EstimateNeededResources( void );
void CL_ResetEvent( event_info_t *ei ); void CL_ResetEvent( event_info_t *ei );
word CL_EventIndex( const char *name ); word CL_EventIndex( const char *name );
void CL_FireEvents( void ); void CL_FireEvents( void );
@@ -800,10 +810,9 @@ void CL_FireEvents( void );
// cl_font.c // cl_font.c
// //
qboolean CL_FixedFont( cl_font_t *font ); 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_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, convar_t *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_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_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 ); 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 ); void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height );
@@ -816,9 +825,12 @@ int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags,
// //
void CL_UnloadProgs( void ); void CL_UnloadProgs( void );
qboolean CL_LoadProgs( const char *name ); 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_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_DrawHUD( int state );
void CL_InitEdicts( int maxclients ); void CL_InitEdicts( void );
void CL_FreeEdicts( void ); void CL_FreeEdicts( void );
void CL_ClearWorld( void ); void CL_ClearWorld( void );
void CL_DrawCenterPrint( void ); void CL_DrawCenterPrint( void );
@@ -826,24 +838,35 @@ void CL_ClearSpriteTextures( void );
void CL_CenterPrint( const char *text, float y ); void CL_CenterPrint( const char *text, float y );
void CL_TextMessageParse( byte *pMemFile, int fileSize ); void CL_TextMessageParse( byte *pMemFile, int fileSize );
client_textmessage_t *CL_TextMessageGet( const char *pName ); client_textmessage_t *CL_TextMessageGet( const char *pName );
int pfnDecalIndexFromName( const char *szDecalName );
int pfnIndexFromTrace( struct pmtrace_s *pTrace );
model_t *CL_ModelHandle( int modelindex ); model_t *CL_ModelHandle( int modelindex );
void NetAPI_CancelAllRequests( void ); void NetAPI_CancelAllRequests( void );
int CL_FindModelIndex( const char *m );
cl_entity_t *CL_GetLocalPlayer( void ); cl_entity_t *CL_GetLocalPlayer( void );
model_t *CL_LoadClientSprite( const char *filename ); model_t *CL_LoadClientSprite( const char *filename );
model_t *CL_LoadModel( const char *modelname, int *index ); model_t *CL_LoadModel( const char *modelname, int *index );
HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags ); HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags );
void SPR_AdjustSize( float *x, float *y, float *w, float *h ); 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 ); int CL_GetScreenInfo( SCREENINFO *pscrinfo );
void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a );
void CL_PlayerTrace( float *start, float *end, int traceFlags, int ignore_pe, pmtrace_t *tr );
void CL_PlayerTraceExt( float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ), pmtrace_t *tr );
pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ); 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 ); const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend );
int PM_CL_PointContents( const float *p, int *truecontents ); int PM_CL_PointContents( const float *p, int *truecontents );
void CL_SetTraceHull( int hull );
void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input
cl_entity_t* CL_GetViewModel( void );
void pfnGetScreenFade( struct screenfade_s *fade );
physent_t *pfnGetPhysent( int idx ); physent_t *pfnGetPhysent( int idx );
struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend ); struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend );
movevars_t *pfnGetMoveVars( void ); movevars_t *pfnGetMoveVars( void );
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height ); void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
void CL_DisableScissor( scissor_state_t *scissor ); 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 ); 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 ) _inline cl_entity_t *CL_EDICT_NUM( int n )
{ {
@@ -863,49 +886,16 @@ _inline cl_entity_t *CL_EDICT_NUM( int n )
// //
// cl_parse.c // cl_parse.c
// //
void CL_ParseSetAngle( sizebuf_t *msg );
void CL_ParseServerData( sizebuf_t *msg, qboolean legacy );
void CL_ParseLightStyle( sizebuf_t *msg );
void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy );
void CL_ParseResource( sizebuf_t *msg );
void CL_ParseClientData( sizebuf_t *msg );
void CL_UpdateUserPings( sizebuf_t *msg );
void CL_ParseParticles( sizebuf_t *msg );
void CL_ParseRestoreSoundPacket( sizebuf_t *msg );
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy );
void CL_ParseSignon( sizebuf_t *msg );
void CL_ParseRestore( sizebuf_t *msg );
void CL_ParseStaticDecal( sizebuf_t *msg );
void CL_ParseAddAngle( sizebuf_t *msg );
void CL_RegisterUserMessage( sizebuf_t *msg );
void CL_ParseMovevars( sizebuf_t *msg );
void CL_ParseResourceRequest( sizebuf_t *msg );
void CL_ParseCustomization( sizebuf_t *msg );
void CL_ParseCrosshairAngle( sizebuf_t *msg );
void CL_ParseSoundFade( sizebuf_t *msg );
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 );
void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ); void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message );
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message );
void CL_LegacyPrecache_f( void );
void CL_ParseTempEntity( sizebuf_t *msg ); void CL_ParseTempEntity( sizebuf_t *msg );
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf ); qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
qboolean CL_RequestMissingResources( void ); qboolean CL_RequestMissingResources( void );
void CL_RegisterResources ( sizebuf_t *msg ); void CL_RegisterResources ( sizebuf_t *msg );
void CL_ParseViewEntity( sizebuf_t *msg ); void CL_ParseViewEntity( sizebuf_t *msg );
void CL_ParseServerTime( 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, qboolean normal_message );
void CL_LegacyPrecache_f( void );
// //
// cl_scrn.c // cl_scrn.c
@@ -913,6 +903,8 @@ void CL_LegacyPrecache_f( void );
void SCR_VidInit( void ); void SCR_VidInit( void );
void SCR_TileClear( void ); void SCR_TileClear( void );
void SCR_DirtyScreen( void ); void SCR_DirtyScreen( void );
void SCR_AddDirtyPoint( int x, int y );
void SCR_InstallParticlePalette( void );
void SCR_EndLoadingPlaque( void ); void SCR_EndLoadingPlaque( void );
void SCR_RegisterTextures( void ); void SCR_RegisterTextures( void );
void SCR_LoadCreditsFont( void ); void SCR_LoadCreditsFont( void );
@@ -948,17 +940,20 @@ void CL_InitClientMove( void );
void CL_PredictMovement( qboolean repredicting ); void CL_PredictMovement( qboolean repredicting );
void CL_CheckPredictionError( void ); void CL_CheckPredictionError( void );
qboolean CL_IsPredicted( void ); qboolean CL_IsPredicted( void );
int CL_TruePointContents( const vec3_t p );
int CL_WaterEntity( const float *rgflPos ); int CL_WaterEntity( const float *rgflPos );
cl_entity_t *CL_GetWaterEntity( 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_VisTraceLine( vec3_t start, vec3_t end, int flags );
pmtrace_t CL_TraceLine( 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_MoveSpectatorCamera( void );
void CL_SetLastUpdate( void ); void CL_SetLastUpdate( void );
void CL_RedoPrediction( void ); void CL_RedoPrediction( void );
void CL_PushPMStates( void ); void CL_PushPMStates( void );
void CL_PopPMStates( void ); void CL_PopPMStates( void );
void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient ); void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient );
void CL_SetIdealPitch( void );
// //
// cl_qparse.c // cl_qparse.c
@@ -975,17 +970,21 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType );
void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset ); void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset );
qboolean CL_GetEntitySpatialization( struct channel_s *ch ); qboolean CL_GetEntitySpatialization( struct channel_s *ch );
qboolean CL_GetMovieSpatialization( struct rawchan_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_ComputePlayerOrigin( cl_entity_t *clent );
void CL_ProcessPacket( frame_t *frame ); void CL_ProcessPacket( frame_t *frame );
void CL_MoveThirdpersonCamera( void ); void CL_MoveThirdpersonCamera( void );
qboolean CL_IsPlayerIndex( int idx ); qboolean CL_IsPlayerIndex( int idx );
void CL_SetIdealPitch( void );
void CL_EmitEntities( void ); void CL_EmitEntities( void );
// //
// cl_remap.c // cl_remap.c
// //
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e ); 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 ); void CL_ClearAllRemaps( void );
// //
@@ -1002,17 +1001,18 @@ const ref_overview_t *GL_GetOverviewParms( void );
// //
void R_StoreEfrags( efrag_t **ppefrag, int framecount ); void R_StoreEfrags( efrag_t **ppefrag, int framecount );
void R_AddEfrags( cl_entity_t *ent ); void R_AddEfrags( cl_entity_t *ent );
// //
// cl_tent.c // cl_tent.c
// //
struct particle_s; struct particle_s;
int CL_AddEntity( int entityType, cl_entity_t *pEnt );
void CL_WeaponAnim( int iAnim, int body ); void CL_WeaponAnim( int iAnim, int body );
void CL_ClearEffects( void ); void CL_ClearEffects( void );
void CL_ClearEfrags( void ); void CL_ClearEfrags( void );
void CL_TestLights( void ); void CL_TestLights( void );
void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale ); 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_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 R_FreeDeadParticles( struct particle_s **ppparticles );
void CL_AddClientResource( const char *filename, int type ); void CL_AddClientResource( const char *filename, int type );
void CL_AddClientResources( void ); void CL_AddClientResources( void );
@@ -1034,11 +1034,12 @@ void CL_ReadPointFile_f( void );
void CL_DrawEFX( float time, qboolean fTrans ); void CL_DrawEFX( float time, qboolean fTrans );
void CL_ThinkParticle( double frametime, particle_t *p ); void CL_ThinkParticle( double frametime, particle_t *p );
void CL_ReadLineFile_f( void ); void CL_ReadLineFile_f( void );
void CL_RunLightStyles( void );
// //
// console.c // console.c
// //
extern convar_t con_fontsize; extern convar_t *con_fontsize;
int Con_Visible( void ); int Con_Visible( void );
qboolean Con_FixedFont( void ); qboolean Con_FixedFont( void );
void Con_VidInit( void ); void Con_VidInit( void );
@@ -1053,23 +1054,27 @@ int Con_UtfProcessChar( int in );
int Con_UtfProcessCharForce( int in ); int Con_UtfProcessCharForce( int in );
int Con_UtfMoveLeft( char *str, int pos ); int Con_UtfMoveLeft( char *str, int pos );
int Con_UtfMoveRight( char *str, int pos, int length ); 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_GetCurFont( void );
cl_font_t *Con_GetFont( int num ); cl_font_t *Con_GetFont( int num );
void Con_DrawCharacterLen( int number, int *width, int *height ); 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 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 GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c
void Con_CharEvent( int key ); void Con_CharEvent( int key );
void Con_RestoreFont( void );
void Key_Console( int key ); void Key_Console( int key );
void Key_Message( int key ); void Key_Message( int key );
void Con_FastClose( void ); void Con_FastClose( void );
void Con_Bottom( void ); void Con_Bottom( void );
void Con_Top( void );
void Con_PageDown( int lines ); void Con_PageDown( int lines );
void Con_PageUp( int lines ); void Con_PageUp( int lines );
// //
// s_main.c // 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_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_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath );
void S_StopBackgroundTrack( void ); void S_StopBackgroundTrack( void );
@@ -1116,6 +1121,11 @@ void UI_ConnectionProgress_Precache( void );
void UI_ConnectionProgress_Connect( const char *server ); void UI_ConnectionProgress_Connect( const char *server );
void UI_ConnectionProgress_ChangeLevel( void ); void UI_ConnectionProgress_ChangeLevel( void );
void UI_ConnectionProgress_ParseServerInfo( const char *server ); 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 // cl_mobile.c

View File

@@ -22,16 +22,13 @@ GNU General Public License for more details.
#include "wadfile.h" #include "wadfile.h"
#include "input.h" #include "input.h"
static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" ); convar_t *con_notifytime;
static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" ); convar_t *scr_conspeed;
CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" ); convar_t *con_fontsize;
static CVAR_DEFINE_AUTO( con_fontrender, "2", FCVAR_ARCHIVE, "console font render mode (0: additive, 1: holes, 2: trans)" ); convar_t *con_charset;
static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" ); convar_t *con_fontscale;
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" ); convar_t *con_fontnum;
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" ); convar_t *con_color;
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 int g_codepage = 0;
static qboolean g_utf8 = false; static qboolean g_utf8 = false;
@@ -141,9 +138,8 @@ typedef struct
static console_t con; static console_t con;
static void Con_ClearField( field_t *edit ); void Con_ClearField( field_t *edit );
static void Field_CharEvent( field_t *edit, int ch ); void Field_CharEvent( field_t *edit, int ch );
static void Con_InvalidateFonts( void );
static void Con_LoadHistory( con_history_t *self ); static void Con_LoadHistory( con_history_t *self );
static void Con_SaveHistory( con_history_t *self ); static void Con_SaveHistory( con_history_t *self );
@@ -153,7 +149,7 @@ static void Con_SaveHistory( con_history_t *self );
Con_Clear_f Con_Clear_f
================ ================
*/ */
static void Con_Clear_f( void ) void Con_Clear_f( void )
{ {
con.lines_count = 0; con.lines_count = 0;
con.backscroll = 0; // go to end con.backscroll = 0; // go to end
@@ -166,28 +162,29 @@ Con_SetColor
*/ */
static void Con_SetColor( void ) static void Con_SetColor( void )
{ {
vec3_t color;
int r, g, b; int r, g, b;
int num; int num;
if( !FBitSet( con_color.flags, FCVAR_CHANGED )) if( !FBitSet( con_color->flags, FCVAR_CHANGED ))
return; return;
num = sscanf( con_color.string, "%i %i %i", &r, &g, &b ); num = sscanf( con_color->string, "%i %i %i", &r, &g, &b );
switch( num ) switch( num )
{ {
case 1: case 1:
Con_DefaultColor( r, r, r, false ); Con_DefaultColor( r, r, r );
break; break;
case 3: case 3:
Con_DefaultColor( r, g, b, false ); Con_DefaultColor( r, g, b );
break; break;
default: default:
Cvar_DirectSet( &con_color, con_color.def_string ); Cvar_DirectSet( con_color, con_color->def_string );
break; break;
} }
ClearBits( con_color.flags, FCVAR_CHANGED ); ClearBits( con_color->flags, FCVAR_CHANGED );
} }
/* /*
@@ -208,7 +205,7 @@ void Con_ClearNotify( void )
Con_ClearTyping Con_ClearTyping
================ ================
*/ */
static void Con_ClearTyping( void ) void Con_ClearTyping( void )
{ {
Con_ClearField( &con.input ); Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth; con.input.widthInChars = con.linewidth;
@@ -221,7 +218,7 @@ static void Con_ClearTyping( void )
Con_MessageMode_f Con_MessageMode_f
================ ================
*/ */
static void Con_MessageMode_f( void ) void Con_MessageMode_f( void )
{ {
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged(); g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
@@ -237,7 +234,7 @@ static void Con_MessageMode_f( void )
Con_MessageMode2_f Con_MessageMode2_f
================ ================
*/ */
static void Con_MessageMode2_f( void ) void Con_MessageMode2_f( void )
{ {
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged(); g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
@@ -282,7 +279,7 @@ void Con_ToggleConsole_f( void )
Con_SetTimes_f Con_SetTimes_f
================ ================
*/ */
static void Con_SetTimes_f( void ) void Con_SetTimes_f( void )
{ {
int newtimes; int newtimes;
@@ -305,7 +302,7 @@ Notifies the console code about the current time
went backwards) went backwards)
================ ================
*/ */
static void Con_FixTimes( void ) void Con_FixTimes( void )
{ {
double diff; double diff;
int i; int i;
@@ -326,7 +323,7 @@ Con_DeleteLine
Deletes the first line from the console history. Deletes the first line from the console history.
================ ================
*/ */
static void Con_DeleteLine( void ) void Con_DeleteLine( void )
{ {
if( con.lines_count == 0 ) if( con.lines_count == 0 )
return; return;
@@ -341,7 +338,7 @@ Con_DeleteLastLine
Deletes the last line from the console history. Deletes the last line from the console history.
================ ================
*/ */
static void Con_DeleteLastLine( void ) void Con_DeleteLastLine( void )
{ {
if( con.lines_count == 0 ) if( con.lines_count == 0 )
return; return;
@@ -400,7 +397,7 @@ Con_AddLine
Appends a given string as a new line to the console. 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; char *putpos;
con_lineinfo_t *p; con_lineinfo_t *p;
@@ -446,7 +443,7 @@ Con_CheckResize
If the line width has changed, reformat the buffer. If the line width has changed, reformat the buffer.
================ ================
*/ */
static void Con_CheckResize( void ) void Con_CheckResize( void )
{ {
int charWidth = 8; int charWidth = 8;
int i, width; int i, width;
@@ -495,7 +492,7 @@ void Con_PageDown( int lines )
Con_Top Con_Top
================ ================
*/ */
static void Con_Top( void ) void Con_Top( void )
{ {
con.backscroll = CON_MAXLINES; con.backscroll = CON_MAXLINES;
} }
@@ -541,14 +538,15 @@ INTERNAL RESOURCE
static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font ) static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
{ {
qboolean success = false; qboolean success = false;
float scale = con_fontscale.value; float scale = con_fontscale->value;
if( font->valid ) if( font->valid )
return; // already loaded 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 else
{ {
@@ -561,14 +559,14 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
if( Q_snprintf( path, sizeof( path ), if( Q_snprintf( path, sizeof( path ),
"font%i_%s.fnt", fontNumber, Cvar_VariableString( "con_charset" )) > 0 ) "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 ) if( !success )
{ {
Q_snprintf( path, sizeof( path ), "fonts/font%i", fontNumber ); 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 // quake fixed font as fallback
// keep source to print directly into conback image // 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" ); Con_DPrintf( S_ERROR "failed to load console font\n" );
} }
} }
@@ -595,8 +593,8 @@ static void Con_LoadConchars( void )
Con_LoadConsoleFont( i, con.chars + i ); Con_LoadConsoleFont( i, con.chars + i );
// select properly fontsize // select properly fontsize
if( con_fontnum.value >= 0 && con_fontnum.value <= CON_NUMFONTS - 1 ) if( con_fontnum->value >= 0 && con_fontnum->value <= CON_NUMFONTS - 1 )
fontSize = con_fontnum.value; fontSize = con_fontnum->value;
else if( refState.width <= 640 ) else if( refState.width <= 640 )
fontSize = 0; fontSize = 0;
else if( refState.width >= 1280 ) else if( refState.width >= 1280 )
@@ -810,7 +808,7 @@ compute string width and height in screen pixels
*/ */
void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ) void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height )
{ {
CL_DrawStringLen( con.curFont, pText, length, height, FONT_DRAW_UTF8 ); return CL_DrawStringLen( con.curFont, pText, length, height, FONT_DRAW_UTF8 );
} }
/* /*
@@ -832,20 +830,19 @@ Con_Init
*/ */
void Con_Init( void ) void Con_Init( void )
{ {
int i;
if( host.type == HOST_DEDICATED ) if( host.type == HOST_DEDICATED )
return; // dedicated server already have console return; // dedicated server already have console
// must be init before startup video subsystem // must be init before startup video subsystem
Cvar_RegisterVariable( &scr_conspeed ); scr_conspeed = Cvar_Get( "scr_conspeed", "600", FCVAR_ARCHIVE, "console moving speed" );
Cvar_RegisterVariable( &con_notifytime ); con_notifytime = Cvar_Get( "con_notifytime", "3", FCVAR_ARCHIVE, "notify time to live" );
Cvar_RegisterVariable( &con_fontsize ); con_fontsize = Cvar_Get( "con_fontsize", "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
Cvar_RegisterVariable( &con_charset ); con_charset = Cvar_Get( "con_charset", "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
Cvar_RegisterVariable( &con_fontscale ); con_fontscale = Cvar_Get( "con_fontscale", "1.0", FCVAR_ARCHIVE, "scale font texture" );
Cvar_RegisterVariable( &con_fontrender ); con_fontnum = Cvar_Get( "con_fontnum", "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
Cvar_RegisterVariable( &con_fontnum ); con_color = Cvar_Get( "con_color", "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
Cvar_RegisterVariable( &con_color );
Cvar_RegisterVariable( &scr_drawversion );
Cvar_RegisterVariable( &con_oldfont );
// init the console buffer // init the console buffer
con.bufsize = CON_TEXTSIZE; con.bufsize = CON_TEXTSIZE;
@@ -1123,7 +1120,7 @@ EDIT FIELDS
Con_ClearField Con_ClearField
================ ================
*/ */
static void Con_ClearField( field_t *edit ) void Con_ClearField( field_t *edit )
{ {
memset( edit->buffer, 0, MAX_STRING ); memset( edit->buffer, 0, MAX_STRING );
edit->cursor = 0; edit->cursor = 0;
@@ -1146,7 +1143,7 @@ static void Field_Set( field_t *f, const char *string )
Field_Paste Field_Paste
================ ================
*/ */
static void Field_Paste( field_t *edit ) void Field_Paste( field_t *edit )
{ {
char *cbd; char *cbd;
int i, pasteLen; int i, pasteLen;
@@ -1182,7 +1179,7 @@ in-game talk, and menu fields
Key events are used for non-printable characters, others are gotten from char events. 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; int len;
@@ -1253,7 +1250,7 @@ static void Field_KeyDownEvent( field_t *edit, int key )
Field_CharEvent Field_CharEvent
================== ==================
*/ */
static void Field_CharEvent( field_t *edit, int ch ) void Field_CharEvent( field_t *edit, int ch )
{ {
int len; int len;
@@ -1314,7 +1311,7 @@ static void Field_CharEvent( field_t *edit, int ch )
Field_DrawInputLine 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 len, cursorChar;
int drawLen; int drawLen;
@@ -1686,7 +1683,7 @@ Con_DrawInput
The input line scrolls horizontally if typing goes beyond the right edge 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; int y;
@@ -1706,7 +1703,7 @@ Con_DrawDebugLines
Custom debug messages Custom debug messages
================ ================
*/ */
static int Con_DrawDebugLines( void ) int Con_DrawDebugLines( void )
{ {
notify_t *notify = con.notify; notify_t *notify = con.notify;
int i, count = 0; int i, count = 0;
@@ -1757,15 +1754,11 @@ void Con_DrawDebug( void )
string dlstring; string dlstring;
int x, y; int x, y;
if( scr_download.value != -1.0f ) if( scr_download->value != -1.0f )
{ {
int length;
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs", Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
host.downloadcount, host.downloadfile, scr_download.value, Sys_DoubleTime() - timeStart ); host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
x = refState.width - 500;
Con_DrawStringLen( dlstring, &length, NULL );
length = Q_max( length, 500 );
x = refState.width - length * 1.05f;
y = con.curFont->charHeight * 1.05f; y = con.curFont->charHeight * 1.05f;
Con_DrawString( x, y, dlstring, g_color_table[7] ); Con_DrawString( x, y, dlstring, g_color_table[7] );
} }
@@ -1791,7 +1784,7 @@ Con_DrawNotify
Draws the last few lines of output transparently over the game top 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; double time = cl.time;
int i, x, y = 0; int i, x, y = 0;
@@ -1806,7 +1799,7 @@ static void Con_DrawNotify( void )
{ {
con_lineinfo_t *l = &CON_LINES( i ); con_lineinfo_t *l = &CON_LINES( i );
if( l->addtime < ( time - con_notifytime.value )) if( l->addtime < ( time - con_notifytime->value ))
continue; continue;
Con_DrawString( x, y, l->start, g_color_table[7] ); Con_DrawString( x, y, l->start, g_color_table[7] );
@@ -1843,7 +1836,7 @@ If alpha is 0, the line is not drawn, but still wrapped and its height
returned. returned.
================ ================
*/ */
static int Con_DrawConsoleLine( int y, int lineno ) int Con_DrawConsoleLine( int y, int lineno )
{ {
con_lineinfo_t *li = &CON_LINES( lineno ); con_lineinfo_t *li = &CON_LINES( lineno );
@@ -1898,7 +1891,7 @@ Con_DrawConsole
Draws the console with the solid background Draws the console with the solid background
================ ================
*/ */
static void Con_DrawSolidConsole( int lines ) void Con_DrawSolidConsole( int lines )
{ {
int i, x, y; int i, x, y;
float fraction; float fraction;
@@ -1988,7 +1981,7 @@ void Con_DrawConsole( void )
if( cls.state == ca_connecting || cls.state == ca_connected ) if( cls.state == ca_connecting || cls.state == ca_connected )
{ {
if( !cl_allow_levelshots.value && !cls.timedemo ) if( !cl_allow_levelshots->value )
{ {
if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console ) if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console )
con.vislines = con.showlines = 0; con.vislines = con.showlines = 0;
@@ -1998,7 +1991,7 @@ void Con_DrawConsole( void )
{ {
con.showlines = 0; con.showlines = 0;
if( host_developer.value >= DEV_EXTENDED && !cls.timedemo ) if( host_developer.value >= DEV_EXTENDED )
Con_DrawNotify(); // draw notify lines Con_DrawNotify(); // draw notify lines
} }
} }
@@ -2030,7 +2023,7 @@ void Con_DrawConsole( void )
{ {
if( con.vislines ) if( con.vislines )
Con_DrawSolidConsole( con.vislines ); Con_DrawSolidConsole( con.vislines );
else if( cls.state == ca_active && ( cls.key_dest == key_game || cls.key_dest == key_message ) && !cls.timedemo ) else if( cls.state == ca_active && ( cls.key_dest == key_game || cls.key_dest == key_message ))
Con_DrawNotify(); // draw notify lines Con_DrawNotify(); // draw notify lines
} }
break; break;
@@ -2052,31 +2045,30 @@ void Con_DrawVersion( void )
byte *color = g_color_table[7]; byte *color = g_color_table[7];
int stringLen, charH = 0; int stringLen, charH = 0;
int start, height = refState.height; int start, height = refState.height;
qboolean draw_version = false;
string curbuild; string curbuild;
if( !scr_drawversion.value || CL_IsDevOverviewMode() == 2 || net_graph.value ) switch( cls.scrshot_action )
return;
if( cls.key_dest == key_menu )
{ {
Q_snprintf( curbuild, sizeof( curbuild ), case scrshot_normal:
"v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( )); case scrshot_snapshot:
draw_version = true;
break;
} }
else
if( !host.force_draw_version )
{ {
qboolean draw_version; if(( cls.key_dest != key_menu && !draw_version ) || CL_IsDevOverviewMode() == 2 || net_graph->value )
draw_version = cls.scrshot_action == scrshot_normal
|| cls.scrshot_action == scrshot_snapshot
|| host.force_draw_version_time > host.realtime;
if( !draw_version )
return; 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( host.force_draw_version_time > host.realtime )
host.force_draw_version = false;
if( host.force_draw_version || 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 ); Con_DrawStringLen( curbuild, &stringLen, &charH );
start = refState.width - stringLen * 1.05f; start = refState.width - stringLen * 1.05f;
height -= charH * 1.05f; height -= charH * 1.05f;
@@ -2106,7 +2098,7 @@ void Con_RunConsole( void )
} }
else con.showlines = 0; // none visible else con.showlines = 0; // none visible
lines_per_frame = fabs( scr_conspeed.value ) * host.realframetime; lines_per_frame = fabs( scr_conspeed->value ) * host.realframetime;
if( con.showlines < con.vislines ) if( con.showlines < con.vislines )
{ {
@@ -2121,33 +2113,35 @@ void Con_RunConsole( void )
con.vislines = con.showlines; 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 // update codepage parameters
if( !Q_stricmp( con_charset.string, "cp1251" )) if( !Q_stricmp( con_charset->string, "cp1251" ))
{ {
g_codepage = 1251; g_codepage = 1251;
} }
else if( !Q_stricmp( con_charset.string, "cp1252" )) else if( !Q_stricmp( con_charset->string, "cp1252" ))
{ {
g_codepage = 1252; g_codepage = 1252;
} }
else else
{ {
Con_Printf( S_WARN "Unknown charset %s, defaulting to cp1252", con_charset.string ); Con_Printf( S_WARN "Unknown charset %s, defaulting to cp1252", con_charset->string );
Cvar_DirectSet( &con_charset, "cp1252" ); Cvar_DirectSet( con_charset, "cp1252" );
g_codepage = 1252; g_codepage = 1252;
} }
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" ); g_utf8 = !Q_stricmp( cl_charset->string, "utf-8" );
Con_InvalidateFonts(); Con_InvalidateFonts();
Con_LoadConchars(); Con_LoadConchars();
ClearBits( con_charset.flags, FCVAR_CHANGED ); ClearBits( con_charset->flags, FCVAR_CHANGED );
ClearBits( con_fontnum.flags, FCVAR_CHANGED ); ClearBits( con_fontnum->flags, FCVAR_CHANGED );
ClearBits( con_fontscale.flags, FCVAR_CHANGED ); ClearBits( con_fontscale->flags, FCVAR_CHANGED );
ClearBits( cl_charset.flags, FCVAR_CHANGED ); ClearBits( cl_charset->flags, FCVAR_CHANGED );
ClearBits( con_oldfont.flags, FCVAR_CHANGED );
} }
} }
@@ -2187,17 +2181,12 @@ INTERNAL RESOURCE
*/ */
void Con_VidInit( void ) void Con_VidInit( void )
{ {
const uint flags = TF_IMAGE|TF_ALLOW_NEAREST;
if( !con.historyLoaded ) if( !con.historyLoaded )
{ {
Con_LoadHistory( &con.history ); Con_LoadHistory( &con.history );
con.historyLoaded = true; con.historyLoaded = true;
} }
if( Sys_CheckParm( "-oldfont" ))
Cvar_DirectSet( &con_oldfont, "1" );
Con_LoadConchars(); Con_LoadConchars();
Con_CheckResize(); Con_CheckResize();
#if XASH_LOW_MEMORY #if XASH_LOW_MEMORY
@@ -2208,28 +2197,28 @@ void Con_VidInit( void )
{ {
// trying to load truecolor image first // trying to load truecolor image first
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false )) 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, flags ); con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
if( !con.background ) if( !con.background )
{ {
if( FS_FileExists( "cached/conback640", false )) if( FS_FileExists( "cached/conback640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, flags ); con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/conback", false )) else if( FS_FileExists( "cached/conback", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, flags ); con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
} }
} }
else else
{ {
// trying to load truecolor image first // trying to load truecolor image first
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false )) 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, flags ); con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
if( !con.background ) if( !con.background )
{ {
if( FS_FileExists( "cached/loading640", false )) if( FS_FileExists( "cached/loading640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, flags ); con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/loading", false )) else if( FS_FileExists( "cached/loading", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, flags ); con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
} }
} }
@@ -2315,20 +2304,11 @@ Con_DefaultColor
called from MainUI 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 ); r = bound( 0, r, 255 );
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 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 ); MakeRGBA( g_color_table[7], r, g, b, 255 );
} }

View File

@@ -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

View File

@@ -45,24 +45,22 @@ static struct joy_axis_s
} joyaxis[MAX_AXES] = { 0 }; } joyaxis[MAX_AXES] = { 0 };
static byte currentbinding; // add posibility to remap keys, to place it in joykeys[] static byte currentbinding; // add posibility to remap keys, to place it in joykeys[]
static qboolean joy_initialized; static qboolean joy_initialized;
convar_t *joy_enable;
static CVAR_DEFINE_AUTO( joy_pitch, "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick pitch sensitivity" ); static convar_t *joy_pitch;
static CVAR_DEFINE_AUTO( joy_yaw, "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick yaw sensitivity" ); static convar_t *joy_yaw;
static CVAR_DEFINE_AUTO( joy_side, "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick side sensitivity. Values from -1.0 to 1.0" ); static convar_t *joy_forward;
static CVAR_DEFINE_AUTO( joy_forward, "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick forward sensitivity. Values from -1.0 to 1.0" ); static convar_t *joy_side;
static CVAR_DEFINE_AUTO( joy_lt_threshold, "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "left trigger threshold. Value from 0 to 32767"); static convar_t *joy_found;
static CVAR_DEFINE_AUTO( joy_rt_threshold, "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "right trigger threshold. Value from 0 to 32767" ); static convar_t *joy_index;
static CVAR_DEFINE_AUTO( joy_side_key_threshold, "24576", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "side axis key event emit threshold. Value from 0 to 32767" ); static convar_t *joy_lt_threshold;
static CVAR_DEFINE_AUTO( joy_forward_key_threshold, "24576", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis key event emit threshold. Value from 0 to 32767"); static convar_t *joy_rt_threshold;
static CVAR_DEFINE_AUTO( joy_side_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "side axis deadzone. Value from 0 to 32767" ); static convar_t *joy_side_deadzone;
static CVAR_DEFINE_AUTO( joy_forward_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis deadzone. Value from 0 to 32767"); static convar_t *joy_forward_deadzone;
static CVAR_DEFINE_AUTO( joy_pitch_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "pitch axis deadzone. Value from 0 to 32767"); static convar_t *joy_side_key_threshold;
static CVAR_DEFINE_AUTO( joy_yaw_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "yaw axis deadzone. Value from 0 to 32767" ); static convar_t *joy_forward_key_threshold;
static CVAR_DEFINE_AUTO( joy_axis_binding, "sfpyrl", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "axis hardware id to engine inner axis binding, " static convar_t *joy_pitch_deadzone;
"s - side, f - forward, y - yaw, p - pitch, r - left trigger, l - right trigger" ); static convar_t *joy_yaw_deadzone;
static CVAR_DEFINE_AUTO( joy_found, "0", FCVAR_READ_ONLY, "is joystick is connected" ); static convar_t *joy_axis_binding;
static CVAR_DEFINE_AUTO( joy_index, "0", FCVAR_READ_ONLY, "current active joystick" );
CVAR_DEFINE_AUTO( joy_enable, "1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable joystick" );
/* /*
============ ============
@@ -71,7 +69,7 @@ Joy_IsActive
*/ */
qboolean Joy_IsActive( void ) qboolean Joy_IsActive( void )
{ {
return joy_found.value && joy_enable.value; return joy_found->value && joy_enable->value;
} }
/* /*
@@ -96,7 +94,7 @@ void Joy_HatMotionEvent( byte hat, byte value )
}; };
int i; int i;
if( !joy_found.value ) if( !joy_found->value )
return; return;
for( i = 0; i < ARRAYSIZE( keys ); i++ ) for( i = 0; i < ARRAYSIZE( keys ); i++ )
@@ -127,11 +125,11 @@ static void Joy_ProcessTrigger( const engineAxis_t engineAxis, short value )
{ {
case JOY_AXIS_RT: case JOY_AXIS_RT:
trigButton = K_JOY2; trigButton = K_JOY2;
trigThreshold = joy_rt_threshold.value; trigThreshold = joy_rt_threshold->value;
break; break;
case JOY_AXIS_LT: case JOY_AXIS_LT:
trigButton = K_JOY1; trigButton = K_JOY1;
trigThreshold = joy_lt_threshold.value; trigThreshold = joy_lt_threshold->value;
break; break;
default: default:
Con_Reportf( S_ERROR "Joy_ProcessTrigger: invalid axis = %i", engineAxis ); Con_Reportf( S_ERROR "Joy_ProcessTrigger: invalid axis = %i", engineAxis );
@@ -161,12 +159,12 @@ static int Joy_GetHatValueForAxis( const engineAxis_t engineAxis )
switch( engineAxis ) switch( engineAxis )
{ {
case JOY_AXIS_SIDE: case JOY_AXIS_SIDE:
threshold = joy_side_key_threshold.value; threshold = joy_side_key_threshold->value;
negative = JOY_HAT_LEFT; negative = JOY_HAT_LEFT;
positive = JOY_HAT_RIGHT; positive = JOY_HAT_RIGHT;
break; break;
case JOY_AXIS_FWD: case JOY_AXIS_FWD:
threshold = joy_side_key_threshold.value; threshold = joy_side_key_threshold->value;
negative = JOY_HAT_UP; negative = JOY_HAT_UP;
positive = JOY_HAT_DOWN; positive = JOY_HAT_DOWN;
break; break;
@@ -200,10 +198,10 @@ static void Joy_ProcessStick( const engineAxis_t engineAxis, short value )
switch( engineAxis ) switch( engineAxis )
{ {
case JOY_AXIS_FWD: deadzone = joy_forward_deadzone.value; break; case JOY_AXIS_FWD: deadzone = joy_forward_deadzone->value; break;
case JOY_AXIS_SIDE: deadzone = joy_side_deadzone.value; break; case JOY_AXIS_SIDE: deadzone = joy_side_deadzone->value; break;
case JOY_AXIS_PITCH: deadzone = joy_pitch_deadzone.value; break; case JOY_AXIS_PITCH: deadzone = joy_pitch_deadzone->value; break;
case JOY_AXIS_YAW: deadzone = joy_yaw_deadzone.value; break; case JOY_AXIS_YAW: deadzone = joy_yaw_deadzone->value; break;
default: default:
Con_Reportf( S_ERROR "Joy_ProcessStick: invalid axis = %i", engineAxis ); Con_Reportf( S_ERROR "Joy_ProcessStick: invalid axis = %i", engineAxis );
break; break;
@@ -238,7 +236,7 @@ Axis events
*/ */
void Joy_AxisMotionEvent( byte axis, short value ) void Joy_AxisMotionEvent( byte axis, short value )
{ {
if( !joy_found.value ) if( !joy_found->value )
return; return;
if( axis >= MAX_AXES ) if( axis >= MAX_AXES )
@@ -273,7 +271,7 @@ Trackball events. UNDONE
*/ */
void Joy_BallMotionEvent( byte ball, short xrel, short yrel ) void Joy_BallMotionEvent( byte ball, short xrel, short yrel )
{ {
//if( !joy_found.value ) //if( !joy_found->value )
// return; // return;
} }
@@ -286,7 +284,7 @@ Button events
*/ */
void Joy_ButtonEvent( byte button, byte down ) void Joy_ButtonEvent( byte button, byte down )
{ {
if( !joy_found.value ) if( !joy_found->value )
return; return;
// generic game button code. // generic game button code.
@@ -311,7 +309,7 @@ Called when joystick is removed. For future expansion
*/ */
void Joy_RemoveEvent( void ) void Joy_RemoveEvent( void )
{ {
if( joy_found.value ) if( joy_found->value )
Cvar_FullSet( "joy_found", "0", FCVAR_READ_ONLY ); Cvar_FullSet( "joy_found", "0", FCVAR_READ_ONLY );
} }
@@ -324,7 +322,7 @@ Called when joystick is removed. For future expansion
*/ */
void Joy_AddEvent( void ) void Joy_AddEvent( void )
{ {
if( joy_enable.value && !joy_found.value ) if( joy_enable->value && !joy_found->value )
Cvar_FullSet( "joy_found", "1", FCVAR_READ_ONLY ); Cvar_FullSet( "joy_found", "1", FCVAR_READ_ONLY );
} }
@@ -340,9 +338,9 @@ void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
if( !Joy_IsActive() ) if( !Joy_IsActive() )
return; return;
if( FBitSet( joy_axis_binding.flags, FCVAR_CHANGED ) ) if( FBitSet( joy_axis_binding->flags, FCVAR_CHANGED ) )
{ {
const char *bind = joy_axis_binding.string; const char *bind = joy_axis_binding->string;
size_t i; size_t i;
for( i = 0; bind[i]; i++ ) for( i = 0; bind[i]; i++ )
@@ -359,18 +357,18 @@ void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
} }
} }
ClearBits( joy_axis_binding.flags, FCVAR_CHANGED ); ClearBits( joy_axis_binding->flags, FCVAR_CHANGED );
} }
*fw -= joy_forward.value * (float)joyaxis[JOY_AXIS_FWD ].val/(float)SHRT_MAX; // must be form -1.0 to 1.0 *fw -= joy_forward->value * (float)joyaxis[JOY_AXIS_FWD ].val/(float)SHRT_MAX; // must be form -1.0 to 1.0
*side += joy_side.value * (float)joyaxis[JOY_AXIS_SIDE].val/(float)SHRT_MAX; *side += joy_side->value * (float)joyaxis[JOY_AXIS_SIDE].val/(float)SHRT_MAX;
#if !defined(XASH_SDL) #if !defined(XASH_SDL)
*dpitch += joy_pitch.value * (float)joyaxis[JOY_AXIS_PITCH].val/(float)SHRT_MAX * host.realframetime; // abs axis rotate is frametime related *dpitch += joy_pitch->value * (float)joyaxis[JOY_AXIS_PITCH].val/(float)SHRT_MAX * host.realframetime; // abs axis rotate is frametime related
*dyaw -= joy_yaw.value * (float)joyaxis[JOY_AXIS_YAW ].val/(float)SHRT_MAX * host.realframetime; *dyaw -= joy_yaw->value * (float)joyaxis[JOY_AXIS_YAW ].val/(float)SHRT_MAX * host.realframetime;
#else #else
// HACKHACK: SDL have inverted look axis. // HACKHACK: SDL have inverted look axis.
*dpitch -= joy_pitch.value * (float)joyaxis[JOY_AXIS_PITCH].val/(float)SHRT_MAX * host.realframetime; *dpitch -= joy_pitch->value * (float)joyaxis[JOY_AXIS_PITCH].val/(float)SHRT_MAX * host.realframetime;
*dyaw += joy_yaw.value * (float)joyaxis[JOY_AXIS_YAW ].val/(float)SHRT_MAX * host.realframetime; *dyaw += joy_yaw->value * (float)joyaxis[JOY_AXIS_YAW ].val/(float)SHRT_MAX * host.realframetime;
#endif #endif
} }
@@ -383,31 +381,32 @@ Main init procedure
*/ */
void Joy_Init( void ) void Joy_Init( void )
{ {
Cvar_RegisterVariable( &joy_pitch ); joy_pitch = Cvar_Get( "joy_pitch", "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick pitch sensitivity" );
Cvar_RegisterVariable( &joy_yaw ); joy_yaw = Cvar_Get( "joy_yaw", "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick yaw sensitivity" );
Cvar_RegisterVariable( &joy_side ); joy_side = Cvar_Get( "joy_side", "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick side sensitivity. Values from -1.0 to 1.0" );
Cvar_RegisterVariable( &joy_forward ); joy_forward = Cvar_Get( "joy_forward", "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick forward sensitivity. Values from -1.0 to 1.0" );
Cvar_RegisterVariable( &joy_lt_threshold ); joy_lt_threshold = Cvar_Get( "joy_lt_threshold", "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "left trigger threshold. Value from 0 to 32767");
Cvar_RegisterVariable( &joy_rt_threshold ); joy_rt_threshold = Cvar_Get( "joy_rt_threshold", "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "right trigger threshold. Value from 0 to 32767" );
// emit a key event at 75% axis move // emit a key event at 75% axis move
Cvar_RegisterVariable( &joy_side_key_threshold ); joy_side_key_threshold = Cvar_Get( "joy_side_key_threshold", "24576", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "side axis key event emit threshold. Value from 0 to 32767" );
Cvar_RegisterVariable( &joy_forward_key_threshold ); joy_forward_key_threshold = Cvar_Get( "joy_forward_key_threshold", "24576", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis key event emit threshold. Value from 0 to 32767");
// by default, we rely on deadzone detection come from system, but some glitchy devices report false deadzones // by default, we rely on deadzone detection come from system, but some glitchy devices report false deadzones
Cvar_RegisterVariable( &joy_side_deadzone ); joy_side_deadzone = Cvar_Get( "joy_side_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "side axis deadzone. Value from 0 to 32767" );
Cvar_RegisterVariable( &joy_forward_deadzone ); joy_forward_deadzone = Cvar_Get( "joy_forward_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis deadzone. Value from 0 to 32767");
Cvar_RegisterVariable( &joy_pitch_deadzone ); joy_pitch_deadzone = Cvar_Get( "joy_pitch_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "pitch axis deadzone. Value from 0 to 32767");
Cvar_RegisterVariable( &joy_yaw_deadzone ); joy_yaw_deadzone = Cvar_Get( "joy_yaw_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "yaw axis deadzone. Value from 0 to 32767" );
Cvar_RegisterVariable( &joy_axis_binding ); joy_axis_binding = Cvar_Get( "joy_axis_binding", "sfpyrl", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "axis hardware id to engine inner axis binding, "
Cvar_RegisterVariable( &joy_found ); "s - side, f - forward, y - yaw, p - pitch, r - left trigger, l - right trigger" );
joy_found = Cvar_Get( "joy_found", "0", FCVAR_READ_ONLY, "is joystick is connected" );
// we doesn't loaded config.cfg yet, so this cvar is not archive. // we doesn't loaded config.cfg yet, so this cvar is not archive.
// change by +set joy_index in cmdline // change by +set joy_index in cmdline
Cvar_RegisterVariable( &joy_index ); joy_index = Cvar_Get( "joy_index", "0", FCVAR_READ_ONLY, "current active joystick" );
Cvar_RegisterVariable( &joy_enable ); joy_enable = Cvar_Get( "joy_enable", "1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable joystick" );
// renamed from -nojoy to -noenginejoy to not conflict with // renamed from -nojoy to -noenginejoy to not conflict with
// client.dll's joystick support // client.dll's joystick support
@@ -417,7 +416,7 @@ void Joy_Init( void )
return; return;
} }
Cvar_FullSet( "joy_found", va( "%d", Platform_JoyInit( joy_index.value )), FCVAR_READ_ONLY ); Cvar_FullSet( "joy_found", va( "%d", Platform_JoyInit( joy_index->value )), FCVAR_READ_ONLY );
joy_initialized = true; joy_initialized = true;
} }

View File

@@ -132,8 +132,6 @@ static struct touch_s
int whitetexture; int whitetexture;
int joytexture; // touch indicator int joytexture; // touch indicator
qboolean configchanged; qboolean configchanged;
float actual_aspect_ratio; // maximum aspect ratio from launch, or aspect ratio when entering editor
float config_aspect_ratio; // aspect ratio set by command from config or after entering editor
} touch; } touch;
// private to the engine flags // private to the engine flags
@@ -142,27 +140,28 @@ static struct touch_s
touchdefaultbutton_t g_DefaultButtons[256]; touchdefaultbutton_t g_DefaultButtons[256];
int g_LastDefaultButton; int g_LastDefaultButton;
static CVAR_DEFINE_AUTO( touch_in_menu, "0", FCVAR_FILTERABLE, "draw touch in menu (for internal use only)" ); convar_t *touch_pitch;
static CVAR_DEFINE_AUTO( touch_forwardzone, "0.06", FCVAR_FILTERABLE, "forward touch zone" ); convar_t *touch_yaw;
static CVAR_DEFINE_AUTO( touch_sidezone, "0.06", FCVAR_FILTERABLE, "side touch zone" ); convar_t *touch_forwardzone;
static CVAR_DEFINE_AUTO( touch_pitch, "90", FCVAR_FILTERABLE, "touch pitch sensitivity" ); convar_t *touch_sidezone;
static CVAR_DEFINE_AUTO( touch_yaw, "120", FCVAR_FILTERABLE, "touch yaw sensitivity" ); convar_t *touch_nonlinear_look;
static CVAR_DEFINE_AUTO( touch_nonlinear_look, "0", FCVAR_FILTERABLE, "enable nonlinear touch look" ); convar_t *touch_pow_mult;
static CVAR_DEFINE_AUTO( touch_pow_factor, "1.3", FCVAR_FILTERABLE, "set > 1 to enable" ); convar_t *touch_pow_factor;
static CVAR_DEFINE_AUTO( touch_pow_mult, "400.0", FCVAR_FILTERABLE, "power multiplier, usually 200-1000" ); convar_t *touch_exp_mult;
static CVAR_DEFINE_AUTO( touch_exp_mult, "0", FCVAR_FILTERABLE, "exponent multiplier, usually 20-200, 0 to disable" ); convar_t *touch_grid_enable;
static CVAR_DEFINE_AUTO( touch_grid_count, "50", FCVAR_FILTERABLE, "touch grid count" ); convar_t *touch_grid_count;
static CVAR_DEFINE_AUTO( touch_grid_enable, "1", FCVAR_FILTERABLE, "enable touch grid" ); convar_t *touch_config_file;
static CVAR_DEFINE_AUTO( touch_config_file, "touch.cfg", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "current touch profile file" ); convar_t *touch_in_menu;
static CVAR_DEFINE_AUTO( touch_precise_amount, "0.5", FCVAR_FILTERABLE, "sensitivity multiplier for precise-look" ); convar_t *touch_joy_radius;
static CVAR_DEFINE_AUTO( touch_highlight_r, "1.0", 0, "highlight r color" ); convar_t *touch_dpad_radius;
static CVAR_DEFINE_AUTO( touch_highlight_g, "1.0", 0, "highlight g color" ); convar_t *touch_move_indicator;
static CVAR_DEFINE_AUTO( touch_highlight_b, "1.0", 0, "highlight b color" ); convar_t *touch_highlight_r;
static CVAR_DEFINE_AUTO( touch_highlight_a, "1.0", 0, "highlight alpha" ); convar_t *touch_highlight_g;
static CVAR_DEFINE_AUTO( touch_dpad_radius, "1.0", FCVAR_FILTERABLE, "dpad radius multiplier" ); convar_t *touch_highlight_b;
static CVAR_DEFINE_AUTO( touch_joy_radius, "1.0", FCVAR_FILTERABLE, "joy radius multiplier" ); convar_t *touch_highlight_a;
static CVAR_DEFINE_AUTO( touch_move_indicator, "0.0", FCVAR_FILTERABLE, "indicate move events (0 to disable)" ); convar_t *touch_precise_amount;
static CVAR_DEFINE_AUTO( touch_joy_texture, "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator"); convar_t *touch_joy_texture;
CVAR_DEFINE_AUTO( touch_enable, DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable touch controls" ); CVAR_DEFINE_AUTO( touch_enable, DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable touch controls" );
CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate touch with mouse" ); CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate touch with mouse" );
@@ -170,42 +169,13 @@ CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate
#define B(x) (button->x) #define B(x) (button->x)
#define SCR_W ((float)refState.width) #define SCR_W ((float)refState.width)
#define SCR_H ((float)refState.height) #define SCR_H ((float)refState.height)
#define TO_SCRN_Y(x) (refState.width * (x) * Touch_AspectRatio()) #define TO_SCRN_Y(x) (refState.height * (x))
#define TO_SCRN_X(x) (refState.width * (x)) #define TO_SCRN_X(x) (refState.width * (x))
static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 ); static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 );
static void IN_TouchEditClear( void ); static void IN_TouchEditClear( void );
static void Touch_InitConfig( void ); static void Touch_InitConfig( void );
void Touch_NotifyResize( void )
{
if( refState.width && refState.height && ( !touch.configchanged || !touch.actual_aspect_ratio ))
{
float aspect_ratio = SCR_H/SCR_W;
if( aspect_ratio < 0.99 && aspect_ratio > touch.actual_aspect_ratio )
touch.actual_aspect_ratio = aspect_ratio;
}
}
static inline float Touch_AspectRatio( void )
{
if( touch.config_aspect_ratio )
return touch.config_aspect_ratio;
else if( touch.actual_aspect_ratio )
return touch.actual_aspect_ratio;
else if( refState.width && refState.height )
return SCR_H/SCR_W;
else
return 9.0f / 16.0f;
}
static void Touch_ConfigAspectRatio_f( void )
{
touch.config_aspect_ratio = Q_atof( Cmd_Argv( 1 ));
}
/* /*
========================== ==========================
Touch_ExportButtonToConfig Touch_ExportButtonToConfig
@@ -237,7 +207,7 @@ static inline int Touch_ExportButtonToConfig( file_t *f, touch_button_t *button,
if( keepAspect ) if( keepAspect )
{ {
float aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(Touch_AspectRatio()) ); float aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(SCR_H/SCR_W) );
FS_Printf( f, " %f\n", aspect ); FS_Printf( f, " %f\n", aspect );
} }
else FS_Printf( f, "\n" ); else FS_Printf( f, "\n" );
@@ -252,7 +222,7 @@ Touch_DumpConfig
Dump config to file 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; file_t *f;
touch_button_t *button; touch_button_t *button;
@@ -272,38 +242,36 @@ static qboolean Touch_DumpConfig( const char *name, const char *profilename )
FS_Printf( f, "\ntouch_config_file \"%s\"\n", profilename ); FS_Printf( f, "\ntouch_config_file \"%s\"\n", profilename );
FS_Printf( f, "\n// touch cvars\n" ); FS_Printf( f, "\n// touch cvars\n" );
FS_Printf( f, "\n// sensitivity settings\n" ); FS_Printf( f, "\n// sensitivity settings\n" );
FS_Printf( f, "touch_pitch \"%f\"\n", touch_pitch.value ); FS_Printf( f, "touch_pitch \"%f\"\n", touch_pitch->value );
FS_Printf( f, "touch_yaw \"%f\"\n", touch_yaw.value ); FS_Printf( f, "touch_yaw \"%f\"\n", touch_yaw->value );
FS_Printf( f, "touch_forwardzone \"%f\"\n", touch_forwardzone.value ); FS_Printf( f, "touch_forwardzone \"%f\"\n", touch_forwardzone->value );
FS_Printf( f, "touch_sidezone \"%f\"\n", touch_sidezone.value ); FS_Printf( f, "touch_sidezone \"%f\"\n", touch_sidezone->value );
FS_Printf( f, "touch_nonlinear_look \"%d\"\n", touch_nonlinear_look.value ? 1 : 0 ); FS_Printf( f, "touch_nonlinear_look \"%d\"\n", CVAR_TO_BOOL(touch_nonlinear_look));
FS_Printf( f, "touch_pow_factor \"%f\"\n", touch_pow_factor.value ); FS_Printf( f, "touch_pow_factor \"%f\"\n", touch_pow_factor->value );
FS_Printf( f, "touch_pow_mult \"%f\"\n", touch_pow_mult.value ); FS_Printf( f, "touch_pow_mult \"%f\"\n", touch_pow_mult->value );
FS_Printf( f, "touch_exp_mult \"%f\"\n", touch_exp_mult.value ); FS_Printf( f, "touch_exp_mult \"%f\"\n", touch_exp_mult->value );
FS_Printf( f, "\n// grid settings\n" ); FS_Printf( f, "\n// grid settings\n" );
FS_Printf( f, "touch_grid_count \"%d\"\n", (int)touch_grid_count.value ); FS_Printf( f, "touch_grid_count \"%d\"\n", (int)touch_grid_count->value );
FS_Printf( f, "touch_grid_enable \"%d\"\n", touch_grid_enable.value ? 1 : 0 ); FS_Printf( f, "touch_grid_enable \"%d\"\n", CVAR_TO_BOOL(touch_grid_enable));
FS_Printf( f, "\n// global overstroke (width, r, g, b, a)\n" ); FS_Printf( f, "\n// global overstroke (width, r, g, b, a)\n" );
FS_Printf( f, "touch_set_stroke %d %d %d %d %d\n", touch.swidth, touch.scolor[0], touch.scolor[1], touch.scolor[2], touch.scolor[3] ); FS_Printf( f, "touch_set_stroke %d %d %d %d %d\n", touch.swidth, touch.scolor[0], touch.scolor[1], touch.scolor[2], touch.scolor[3] );
FS_Printf( f, "\n// highlight when pressed\n" ); FS_Printf( f, "\n// highlight when pressed\n" );
FS_Printf( f, "touch_highlight_r \"%f\"\n", touch_highlight_r.value ); FS_Printf( f, "touch_highlight_r \"%f\"\n", touch_highlight_r->value );
FS_Printf( f, "touch_highlight_g \"%f\"\n", touch_highlight_g.value ); FS_Printf( f, "touch_highlight_g \"%f\"\n", touch_highlight_g->value );
FS_Printf( f, "touch_highlight_b \"%f\"\n", touch_highlight_b.value ); FS_Printf( f, "touch_highlight_b \"%f\"\n", touch_highlight_b->value );
FS_Printf( f, "touch_highlight_a \"%f\"\n", touch_highlight_a.value ); FS_Printf( f, "touch_highlight_a \"%f\"\n", touch_highlight_a->value );
FS_Printf( f, "\n// _joy and _dpad options\n" ); FS_Printf( f, "\n// _joy and _dpad options\n" );
FS_Printf( f, "touch_dpad_radius \"%f\"\n", touch_dpad_radius.value ); FS_Printf( f, "touch_dpad_radius \"%f\"\n", touch_dpad_radius->value );
FS_Printf( f, "touch_joy_radius \"%f\"\n", touch_joy_radius.value ); FS_Printf( f, "touch_joy_radius \"%f\"\n", touch_joy_radius->value );
FS_Printf( f, "\n// how much slowdown when Precise Look button pressed\n" ); FS_Printf( f, "\n// how much slowdown when Precise Look button pressed\n" );
FS_Printf( f, "touch_precise_amount \"%f\"\n", touch_precise_amount.value ); FS_Printf( f, "touch_precise_amount \"%f\"\n", touch_precise_amount->value );
FS_Printf( f, "\n// enable/disable move indicator\n" ); FS_Printf( f, "\n// enable/disable move indicator\n" );
FS_Printf( f, "touch_move_indicator \"%f\"\n", touch_move_indicator.value ); FS_Printf( f, "touch_move_indicator \"%f\"\n", touch_move_indicator->value );
FS_Printf( f, "\n// reset menu state when execing config\n" ); FS_Printf( f, "\n// reset menu state when execing config\n" );
FS_Printf( f, "touch_setclientonly 0\n" ); FS_Printf( f, "touch_setclientonly 0\n" );
FS_Printf( f, "\n// touch buttons\n" ); FS_Printf( f, "\n// touch buttons\n" );
FS_Printf( f, "touch_removeall\n" ); FS_Printf( f, "touch_removeall\n" );
FS_Printf( f, "touch_aspectratio %f\n", Touch_AspectRatio());
for( button = touch.list_user.first; button; button = button->next ) for( button = touch.list_user.first; button; button = button->next )
{ {
@@ -333,18 +301,18 @@ void Touch_WriteConfig( void )
if( Sys_CheckParm( "-nowriteconfig" ) || !touch.configchanged || !touch.config_loaded ) if( Sys_CheckParm( "-nowriteconfig" ) || !touch.configchanged || !touch.config_loaded )
return; return;
Con_DPrintf( "Touch_WriteConfig(): %s\n", 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( newconfigfile, sizeof( newconfigfile ), "%s.new", touch_config_file->string );
Q_snprintf( oldconfigfile, sizeof( oldconfigfile ), "%s.bak", touch_config_file.string ); Q_snprintf( oldconfigfile, sizeof( oldconfigfile ), "%s.bak", touch_config_file->string );
if( Touch_DumpConfig( newconfigfile, touch_config_file.string )) if( Touch_DumpConfig( newconfigfile, touch_config_file->string ))
{ {
FS_Delete( oldconfigfile ); FS_Delete( oldconfigfile );
FS_Rename( touch_config_file.string, oldconfigfile ); FS_Rename( touch_config_file->string, oldconfigfile );
FS_Delete( touch_config_file.string ); FS_Delete( touch_config_file->string );
FS_Rename( newconfigfile, touch_config_file.string ); FS_Rename( newconfigfile, touch_config_file->string );
} }
} }
@@ -409,7 +377,7 @@ static void Touch_GenerateCode_f( void )
if( FBitSet( flags, TOUCH_FL_DEF_HIDE )) if( FBitSet( flags, TOUCH_FL_DEF_HIDE ))
SetBits( flags, TOUCH_FL_HIDE ); SetBits( flags, TOUCH_FL_HIDE );
aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(Touch_AspectRatio()) ); aspect = ( B(y2) - B(y1) ) / ( ( B(x2) - B(x1) ) /(SCR_H/SCR_W) );
if( memcmp( &c, &B(color), sizeof( rgba_t ) ) ) if( memcmp( &c, &B(color), sizeof( rgba_t ) ) )
{ {
Con_Printf( "unsigned char color[] = { %d, %d, %d, %d };\n", B(color[0]), B(color[1]), B(color[2]), B(color[3]) ); Con_Printf( "unsigned char color[] = { %d, %d, %d, %d };\n", B(color[0]), B(color[1]), B(color[2]), B(color[3]) );
@@ -425,7 +393,7 @@ static void Touch_RoundAll_f( void )
{ {
touch_button_t *button; touch_button_t *button;
if( !touch_grid_enable.value ) if( !touch_grid_enable->value )
return; return;
for( button = touch.list_user.first; button; button = button->next ) for( button = touch.list_user.first; button; button = button->next )
@@ -582,7 +550,6 @@ static void Touch_RemoveAll_f( void )
{ {
IN_TouchEditClear(); IN_TouchEditClear();
Touch_ClearList( &touch.list_user ); Touch_ClearList( &touch.list_user );
touch.config_aspect_ratio = 0.0f;
} }
static void Touch_SetColor( touchbuttonlist_t *list, const char *name, byte *color ) static void Touch_SetColor( touchbuttonlist_t *list, const char *name, byte *color )
@@ -760,8 +727,6 @@ static void Touch_SetCommand_f( void )
Con_Printf( S_USAGE "touch_setcommand <name> <command>\n" ); Con_Printf( S_USAGE "touch_setcommand <name> <command>\n" );
} }
static void Touch_LoadDefaults_f( void );
static void Touch_ReloadConfig_f( void ) static void Touch_ReloadConfig_f( void )
{ {
touch.state = state_none; touch.state = state_none;
@@ -771,15 +736,8 @@ static void Touch_ReloadConfig_f( void )
touch.selection->finger = -1; touch.selection->finger = -1;
touch.edit = touch.selection = NULL; touch.edit = touch.selection = NULL;
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1; touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
if( FS_FileExists( touch_config_file.string, true ) )
{ Cbuf_AddTextf( "exec %s\n", touch_config_file->string );
Cbuf_AddTextf( "exec \"%s\"\n", touch_config_file.string );
}
else
{
Touch_LoadDefaults_f();
touch.configchanged = true;
}
} }
static touch_button_t *Touch_AddButton( touchbuttonlist_t *list, static touch_button_t *Touch_AddButton( touchbuttonlist_t *list,
@@ -827,7 +785,7 @@ void Touch_AddClientButton( const char *name, const char *texture, const char *c
IN_TouchCheckCoords( &x1, &y1, &x2, &y2 ); IN_TouchCheckCoords( &x1, &y1, &x2, &y2 );
if( round == round_aspect ) if( round == round_aspect )
{ {
y2 = y1 + ( x2 - x1 ) / (Touch_AspectRatio()) * aspect; y2 = y1 + ( x2 - x1 ) * (SCR_W/SCR_H) * aspect;
} }
button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true ); button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true );
button->flags |= flags | TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT; button->flags |= flags | TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT;
@@ -852,7 +810,7 @@ static void Touch_LoadDefaults_f( void )
if( g_DefaultButtons[i].texturefile[0] == '#' ) if( g_DefaultButtons[i].texturefile[0] == '#' )
y2 = y1 + ( (float)clgame.scrInfo.iCharHeight / (float)clgame.scrInfo.iHeight ) * g_DefaultButtons[i].aspect + touch.swidth*2/SCR_H; y2 = y1 + ( (float)clgame.scrInfo.iCharHeight / (float)clgame.scrInfo.iHeight ) * g_DefaultButtons[i].aspect + touch.swidth*2/SCR_H;
else else
y2 = y1 + (( x2 - x1 ) / Touch_AspectRatio()) * g_DefaultButtons[i].aspect; y2 = y1 + ( x2 - x1 ) * (SCR_W/SCR_H) * g_DefaultButtons[i].aspect;
} }
IN_TouchCheckCoords( &x1, &y1, &x2, &y2 ); IN_TouchCheckCoords( &x1, &y1, &x2, &y2 );
@@ -860,7 +818,6 @@ static void Touch_LoadDefaults_f( void )
button->flags |= g_DefaultButtons[i].flags; button->flags |= g_DefaultButtons[i].flags;
button->aspect = g_DefaultButtons[i].aspect; button->aspect = g_DefaultButtons[i].aspect;
} }
touch.configchanged = true;
} }
// Add default button from client // Add default button from client
@@ -953,7 +910,7 @@ static void Touch_AddButton_f( void )
if( aspect ) if( aspect )
{ {
if( B( texturefile )[0] != '#' ) if( B( texturefile )[0] != '#' )
B( y2 ) = B( y1 ) + (( B( x2 ) - B( x1 )) / Touch_AspectRatio() ) * aspect; B( y2 ) = B( y1 ) + ( B( x2 ) - B( x1 )) * ( SCR_W / SCR_H ) * aspect;
B( aspect ) = aspect; B( aspect ) = aspect;
} }
} }
@@ -961,39 +918,11 @@ static void Touch_AddButton_f( void )
static void Touch_EnableEdit_f( void ) static void Touch_EnableEdit_f( void )
{ {
touch_button_t *button;
float current_ratio = SCR_H/SCR_W;
if( touch.state == state_none ) if( touch.state == state_none )
touch.state = state_edit; touch.state = state_edit;
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1; touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
touch.move_button = NULL; touch.move_button = NULL;
touch.configchanged = true; touch.configchanged = true;
/* try determine the best ratio
* User enters editor. Window now have correct size. Need to fix aspect ratio in some cases */
// Case A: no config was loaded, touch was generated with lower height, but window was resized higher, reset it to actual size
if( touch.actual_aspect_ratio > current_ratio )
touch.actual_aspect_ratio = current_ratio;
if( !touch.config_aspect_ratio )
touch.config_aspect_ratio = touch.actual_aspect_ratio;
// Case B: config was loaded, but window may be resized later, so keep y coordinate as is
touch.actual_aspect_ratio = current_ratio;
// convert coordinates to actual aspect ratio after it was updated
if( touch.config_aspect_ratio != touch.actual_aspect_ratio )
{
for( button = touch.list_user.first; button; button = button->next )
{
B(y1) /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
B(y2) /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
// clamp positions to make buttons visible by user
if( B(y2) > 1.0f )
{
B(y1) -= B(y2) - 1.0f;
B(y2) -= B(y2) - 1.0f;
}
}
touch.config_aspect_ratio = touch.actual_aspect_ratio;
}
} }
static void Touch_DisableEdit_f( void ) static void Touch_DisableEdit_f( void )
@@ -1006,7 +935,7 @@ static void Touch_DisableEdit_f( void )
touch.edit = touch.selection = NULL; touch.edit = touch.selection = NULL;
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1; touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
if( touch_in_menu.value ) if( CVAR_TO_BOOL( touch_in_menu ))
{ {
Cvar_Set( "touch_in_menu", "0" ); Cvar_Set( "touch_in_menu", "0" );
} }
@@ -1028,7 +957,7 @@ static void Touch_DeleteProfile_f( void )
static void Touch_InitEditor( void ) static void Touch_InitEditor( void )
{ {
float x = 0.1f * (Touch_AspectRatio()); float x = 0.1f * (SCR_H/SCR_W);
float y = 0.05f; float y = 0.05f;
touch_button_t *temp; touch_button_t *temp;
rgba_t color; rgba_t color;
@@ -1123,34 +1052,33 @@ void Touch_Init( void )
Cmd_AddRestrictedCommand( "touch_generate_code", Touch_GenerateCode_f, "create code sample for mobility API" ); Cmd_AddRestrictedCommand( "touch_generate_code", Touch_GenerateCode_f, "create code sample for mobility API" );
Cmd_AddCommand( "touch_fade", Touch_Fade_f, "start fade animation for selected buttons" ); Cmd_AddCommand( "touch_fade", Touch_Fade_f, "start fade animation for selected buttons" );
Cmd_AddRestrictedCommand( "touch_toggleselection", Touch_ToggleSelection_f, "toggle vidibility on selected button in editor" ); Cmd_AddRestrictedCommand( "touch_toggleselection", Touch_ToggleSelection_f, "toggle vidibility on selected button in editor" );
Cmd_AddRestrictedCommand( "touch_aspectratio", Touch_ConfigAspectRatio_f, "set current aspect ratio" );
// not saved, just runtime state for scripting // not saved, just runtime state for scripting
Cvar_RegisterVariable( &touch_in_menu ); touch_in_menu = Cvar_Get( "touch_in_menu", "0", FCVAR_FILTERABLE, "draw touch in menu (for internal use only)" );
// sensitivity configuration // sensitivity configuration
Cvar_RegisterVariable( &touch_forwardzone ); touch_forwardzone = Cvar_Get( "touch_forwardzone", "0.06", FCVAR_FILTERABLE, "forward touch zone" );
Cvar_RegisterVariable( &touch_sidezone ); touch_sidezone = Cvar_Get( "touch_sidezone", "0.06", FCVAR_FILTERABLE, "side touch zone" );
Cvar_RegisterVariable( &touch_pitch ); touch_pitch = Cvar_Get( "touch_pitch", "90", FCVAR_FILTERABLE, "touch pitch sensitivity" );
Cvar_RegisterVariable( &touch_yaw ); touch_yaw = Cvar_Get( "touch_yaw", "120", FCVAR_FILTERABLE, "touch yaw sensitivity" );
Cvar_RegisterVariable( &touch_nonlinear_look ); touch_nonlinear_look = Cvar_Get( "touch_nonlinear_look", "0", FCVAR_FILTERABLE, "enable nonlinear touch look" );
Cvar_RegisterVariable( &touch_pow_factor ); touch_pow_factor = Cvar_Get( "touch_pow_factor", "1.3", FCVAR_FILTERABLE, "set > 1 to enable" );
Cvar_RegisterVariable( &touch_pow_mult ); touch_pow_mult = Cvar_Get( "touch_pow_mult", "400.0", FCVAR_FILTERABLE, "power multiplier, usually 200-1000" );
Cvar_RegisterVariable( &touch_exp_mult ); touch_exp_mult = Cvar_Get( "touch_exp_mult", "0", FCVAR_FILTERABLE, "exponent multiplier, usually 20-200, 0 to disable" );
// touch.cfg // touch.cfg
Cvar_RegisterVariable( &touch_grid_count ); touch_grid_count = Cvar_Get( "touch_grid_count", "50", FCVAR_FILTERABLE, "touch grid count" );
Cvar_RegisterVariable( &touch_grid_enable ); touch_grid_enable = Cvar_Get( "touch_grid_enable", "1", FCVAR_FILTERABLE, "enable touch grid" );
Cvar_RegisterVariable( &touch_config_file ); touch_config_file = Cvar_Get( "touch_config_file", "touch.cfg", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "current touch profile file" );
Cvar_RegisterVariable( &touch_precise_amount ); touch_precise_amount = Cvar_Get( "touch_precise_amount", "0.5", FCVAR_FILTERABLE, "sensitivity multiplier for precise-look" );
Cvar_RegisterVariable( &touch_highlight_r ); touch_highlight_r = Cvar_Get( "touch_highlight_r", "1.0", 0, "highlight r color" );
Cvar_RegisterVariable( &touch_highlight_g ); touch_highlight_g = Cvar_Get( "touch_highlight_g", "1.0", 0, "highlight g color" );
Cvar_RegisterVariable( &touch_highlight_b ); touch_highlight_b = Cvar_Get( "touch_highlight_b", "1.0", 0, "highlight b color" );
Cvar_RegisterVariable( &touch_highlight_a ); touch_highlight_a = Cvar_Get( "touch_highlight_a", "1.0", 0, "highlight alpha" );
Cvar_RegisterVariable( &touch_dpad_radius ); touch_dpad_radius = Cvar_Get( "touch_dpad_radius", "1.0", FCVAR_FILTERABLE, "dpad radius multiplier" );
Cvar_RegisterVariable( &touch_joy_radius ); touch_joy_radius = Cvar_Get( "touch_joy_radius", "1.0", FCVAR_FILTERABLE, "joy radius multiplier" );
Cvar_RegisterVariable( &touch_move_indicator ); touch_move_indicator = Cvar_Get( "touch_move_indicator", "0.0", FCVAR_FILTERABLE, "indicate move events (0 to disable)" );
Cvar_RegisterVariable( &touch_joy_texture ); touch_joy_texture = Cvar_Get( "touch_joy_texture", "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator");
// input devices cvar // input devices cvar
Cvar_RegisterVariable( &touch_enable ); Cvar_RegisterVariable( &touch_enable );
@@ -1160,7 +1088,7 @@ void Touch_Init( void )
#if SDL_VERSION_ATLEAST( 2, 0, 10 ) #if SDL_VERSION_ATLEAST( 2, 0, 10 )
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" ); SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" );
SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" ); SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" );
#elif defined(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH) #else
SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" ); SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" );
#endif #endif
@@ -1181,9 +1109,9 @@ static void Touch_InitConfig( void )
/// TODO: hud font /// TODO: hud font
//pfnGetScreenInfo( NULL ); //HACK: update hud screen parameters like iHeight //pfnGetScreenInfo( NULL ); //HACK: update hud screen parameters like iHeight
if( FS_FileExists( touch_config_file.string, true ) ) if( FS_FileExists( touch_config_file->string, true ) )
{ {
Cbuf_AddTextf( "exec \"%s\"\n", touch_config_file.string ); Cbuf_AddTextf( "exec \"%s\"\n", touch_config_file->string );
Cbuf_Execute(); Cbuf_Execute();
} }
else else
@@ -1192,7 +1120,7 @@ static void Touch_InitConfig( void )
} }
Touch_InitEditor(); Touch_InitEditor();
touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture.string, NULL, 0, TF_NOMIPMAP ); touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
touch.whitetexture = R_GetBuiltinTexture( REF_WHITE_TEXTURE ); touch.whitetexture = R_GetBuiltinTexture( REF_WHITE_TEXTURE );
touch.configchanged = false; touch.configchanged = false;
touch.config_loaded = true; touch.config_loaded = true;
@@ -1242,10 +1170,10 @@ static void Touch_DrawTexture ( float x1, float y1, float x2, float y2, int text
0, 0, 1, 1, texture ); 0, 0, 1, 1, texture );
} }
#define GRID_COUNT_X ((int)touch_grid_count.value) #define GRID_COUNT_X ((int)touch_grid_count->value)
#define GRID_COUNT_Y (((int)touch_grid_count.value) * Touch_AspectRatio()) #define GRID_COUNT_Y (((int)touch_grid_count->value) * SCR_H / SCR_W)
#define GRID_X (1.0f/GRID_COUNT_X) #define GRID_X (1.0f/GRID_COUNT_X)
#define GRID_Y (1.0f/Touch_AspectRatio()/GRID_COUNT_X) #define GRID_Y (SCR_W/SCR_H/GRID_COUNT_X)
#define GRID_ROUND_X(x) ((float)round( x * GRID_COUNT_X ) / GRID_COUNT_X) #define GRID_ROUND_X(x) ((float)round( x * GRID_COUNT_X ) / GRID_COUNT_X)
#define GRID_ROUND_Y(x) ((float)round( x * GRID_COUNT_Y ) / GRID_COUNT_Y) #define GRID_ROUND_Y(x) ((float)round( x * GRID_COUNT_Y ) / GRID_COUNT_Y)
@@ -1264,7 +1192,7 @@ static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 )
*y1 -= *y2 - 1, *y2 = 1; *y1 -= *y2 - 1, *y2 = 1;
if( *x2 > 1 ) if( *x2 > 1 )
*x1 -= *x2 - 1, *x2 = 1; *x1 -= *x2 - 1, *x2 = 1;
if( touch_grid_enable.value ) if( CVAR_TO_BOOL( touch_grid_enable ))
{ {
*x1 = GRID_ROUND_X( *x1 ); *x1 = GRID_ROUND_X( *x1 );
*x2 = GRID_ROUND_X( *x2 ); *x2 = GRID_ROUND_X( *x2 );
@@ -1323,7 +1251,7 @@ static float Touch_DrawText( float x1, float y1, float x2, float y2, const char
{ {
while( *s && ( *s != '\n' ) && ( *s != ';' ) && ( x1 < maxx ) ) while( *s && ( *s != '\n' ) && ( *s != ';' ) && ( x1 < maxx ) )
x1 += Touch_DrawCharacter( x1, y1, *s++, size ); x1 += Touch_DrawCharacter( x1, y1, *s++, size );
y1 += cls.creditsFont.charHeight / 1024.f * size / Touch_AspectRatio(); y1 += cls.creditsFont.charHeight / 1024.f * size / SCR_H * SCR_W;
if( y1 >= maxy ) if( y1 >= maxy )
break; break;
@@ -1360,10 +1288,10 @@ static void Touch_DrawButtons( touchbuttonlist_t *list )
if( ( B( finger ) != -1 ) && !FBitSet( B( flags ), TOUCH_FL_CLIENT ) ) if( ( B( finger ) != -1 ) && !FBitSet( B( flags ), TOUCH_FL_CLIENT ) )
{ {
color[0] = bound( 0,(float) color[0] * touch_highlight_r.value, 255 ); color[0] = bound( 0,(float) color[0] * touch_highlight_r->value, 255 );
color[1] = bound( 0,(float) color[1] * touch_highlight_g.value, 255 ); color[1] = bound( 0,(float) color[1] * touch_highlight_g->value, 255 );
color[2] = bound( 0,(float) color[2] * touch_highlight_b.value, 255 ); color[2] = bound( 0,(float) color[2] * touch_highlight_b->value, 255 );
color[3] = bound( 0,(float) color[3] * touch_highlight_a.value, 255 ); color[3] = bound( 0,(float) color[3] * touch_highlight_a->value, 255 );
} }
color[3] *= B( fade ); color[3] *= B( fade );
@@ -1430,18 +1358,17 @@ void Touch_Draw( void )
if( !touch.initialized || ( !touch_enable.value && !touch.clientonly )) if( !touch.initialized || ( !touch_enable.value && !touch.clientonly ))
return; return;
if( cls.key_dest != key_game && !touch_in_menu.value )
return;
Touch_InitConfig(); Touch_InitConfig();
if( cls.key_dest != key_game && !CVAR_TO_BOOL(touch_in_menu) )
return;
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture ); ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
if( touch.state >= state_edit && touch_grid_enable.value ) if( touch.state >= state_edit && CVAR_TO_BOOL(touch_grid_enable) )
{ {
float x; float x;
if( touch_in_menu.value ) if( CVAR_TO_BOOL(touch_in_menu) )
Touch_DrawTexture( 0, 0, 1, 1, touch.whitetexture, 32, 32, 32, 255 ); Touch_DrawTexture( 0, 0, 1, 1, touch.whitetexture, 32, 32, 32, 255 );
else else
Touch_DrawTexture( 0, 0, 1, 1, touch.whitetexture, 0, 0, 0, 112 ); Touch_DrawTexture( 0, 0, 1, 1, touch.whitetexture, 0, 0, 0, 112 );
@@ -1502,19 +1429,19 @@ void Touch_Draw( void )
ref.dllFuncs.Color4ub( 255, 255, 255, 255 ); ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
if( ( touch.move_finger != -1 ) && touch.move_button && touch_move_indicator.value ) if( ( touch.move_finger != -1 ) && touch.move_button && touch_move_indicator->value )
{ {
float width; float width;
float height; float height;
if( FBitSet( touch_joy_texture.flags, FCVAR_CHANGED ) ) if( FBitSet( touch_joy_texture->flags, FCVAR_CHANGED ) )
{ {
ClearBits( touch_joy_texture.flags, FCVAR_CHANGED ); ClearBits( touch_joy_texture->flags, FCVAR_CHANGED );
touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture.string, NULL, 0, TF_NOMIPMAP ); touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
} }
if( touch.move_button->type == touch_move ) if( touch.move_button->type == touch_move )
{ {
width = touch_sidezone.value; width = touch_sidezone->value;
height = touch_forwardzone.value; height = touch_forwardzone->value;
} }
else else
{ {
@@ -1522,13 +1449,13 @@ void Touch_Draw( void )
height = (touch.move_button->y2 - touch.move_button->y1)/2; height = (touch.move_button->y2 - touch.move_button->y1)/2;
} }
ref.dllFuncs.Color4ub( 255, 255, 255, 128 ); ref.dllFuncs.Color4ub( 255, 255, 255, 128 );
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x - GRID_X * touch_move_indicator.value ), ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x - GRID_X * touch_move_indicator->value ),
TO_SCRN_Y( touch.move_start_y - GRID_Y * touch_move_indicator.value ), TO_SCRN_Y( touch.move_start_y - GRID_Y * touch_move_indicator->value ),
TO_SCRN_X( GRID_X * 2 * touch_move_indicator.value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator.value ), 0, 0, 1, 1, touch.joytexture ); TO_SCRN_X( GRID_X * 2 * touch_move_indicator->value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator->value ), 0, 0, 1, 1, touch.joytexture );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 ); ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x + touch.side * width - GRID_X * touch_move_indicator.value ), ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x + touch.side * width - GRID_X * touch_move_indicator->value ),
TO_SCRN_Y( touch.move_start_y - touch.forward * height - GRID_Y * touch_move_indicator.value ), TO_SCRN_Y( touch.move_start_y - touch.forward * height - GRID_Y * touch_move_indicator->value ),
TO_SCRN_X( GRID_X * 2 * touch_move_indicator.value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator.value ), 0, 0, 1, 1, touch.joytexture ); TO_SCRN_X( GRID_X * 2 * touch_move_indicator->value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator->value ), 0, 0, 1, 1, touch.joytexture );
} }
@@ -1637,28 +1564,28 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
if( fingerID == touch.move_finger ) if( fingerID == touch.move_finger )
{ {
// check bounds // check bounds
if( touch_forwardzone.value <= 0 ) if( touch_forwardzone->value <= 0 )
Cvar_SetValue( "touch_forwardzone", 0.5 ); Cvar_SetValue( "touch_forwardzone", 0.5 );
if( touch_sidezone.value <= 0 ) if( touch_sidezone->value <= 0 )
Cvar_SetValue( "touch_sidezone", 0.3 ); Cvar_SetValue( "touch_sidezone", 0.3 );
if( !touch.move_button || touch.move_button->type == touch_move ) if( !touch.move_button || touch.move_button->type == touch_move )
{ {
// move relative to touch start // move relative to touch start
touch.forward = ( touch.move_start_y - y ) / touch_forwardzone.value; touch.forward = ( touch.move_start_y - y ) / touch_forwardzone->value;
touch.side = ( x - touch.move_start_x ) / touch_sidezone.value; touch.side = ( x - touch.move_start_x ) / touch_sidezone->value;
} }
else if( touch.move_button->type == touch_joy ) else if( touch.move_button->type == touch_joy )
{ {
// move relative to joy center // move relative to joy center
touch.forward = ( ( touch.move_button->y2 + touch.move_button->y1 ) - y * 2 ) / ( touch.move_button->y2 - touch.move_button->y1 ) * touch_joy_radius.value; touch.forward = ( ( touch.move_button->y2 + touch.move_button->y1 ) - y * 2 ) / ( touch.move_button->y2 - touch.move_button->y1 ) * touch_joy_radius->value;
touch.side = ( x * 2 - ( touch.move_button->x2 + touch.move_button->x1 ) ) / ( touch.move_button->x2 - touch.move_button->x1 ) * touch_joy_radius.value; touch.side = ( x * 2 - ( touch.move_button->x2 + touch.move_button->x1 ) ) / ( touch.move_button->x2 - touch.move_button->x1 ) * touch_joy_radius->value;
} }
else if( touch.move_button->type == touch_dpad ) else if( touch.move_button->type == touch_dpad )
{ {
// like joy, but without acceleration. useful for bhop // like joy, but without acceleration. useful for bhop
touch.forward = round( ( (touch.move_button->y2 + touch.move_button->y1) - y * 2 ) / ( touch.move_button->y2 - touch.move_button->y1 ) * touch_dpad_radius.value ); touch.forward = round( ( (touch.move_button->y2 + touch.move_button->y1) - y * 2 ) / ( touch.move_button->y2 - touch.move_button->y1 ) * touch_dpad_radius->value );
touch.side = round( ( x * 2 - (touch.move_button->x2 + touch.move_button->x1) ) / ( touch.move_button->x2 - touch.move_button->x1 ) * touch_dpad_radius.value ); touch.side = round( ( x * 2 - (touch.move_button->x2 + touch.move_button->x1) ) / ( touch.move_button->x2 - touch.move_button->x1 ) * touch_dpad_radius->value );
} }
touch.forward = bound( -1, touch.forward, 1 ); touch.forward = bound( -1, touch.forward, 1 );
@@ -1669,9 +1596,9 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
if( fingerID == touch.look_finger ) if( fingerID == touch.look_finger )
{ {
if( touch.precision ) if( touch.precision )
dx *= touch_precise_amount.value, dy *= touch_precise_amount.value; dx *= touch_precise_amount->value, dy *= touch_precise_amount->value;
if( touch_nonlinear_look.value ) if( CVAR_TO_BOOL(touch_nonlinear_look) )
{ {
float dabs, dcos, dsin; float dabs, dcos, dsin;
@@ -1684,11 +1611,11 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
dcos = dx / dabs; dcos = dx / dabs;
dsin = dy / dabs; dsin = dy / dabs;
if( touch_exp_mult.value > 1 ) if( touch_exp_mult->value > 1 )
dabs = ( exp( dabs * touch_exp_mult.value ) - 1 ) / touch_exp_mult.value; dabs = ( exp( dabs * touch_exp_mult->value ) - 1 ) / touch_exp_mult->value;
if( touch_pow_mult.value > 1 && touch_pow_factor.value > 1 ) if( touch_pow_mult->value > 1 && touch_pow_factor->value > 1 )
dabs = pow( dabs * touch_pow_mult.value, touch_pow_factor.value ) / touch_pow_mult.value; dabs = pow( dabs * touch_pow_mult->value, touch_pow_factor->value ) / touch_pow_mult->value;
dx = dabs * dcos; dx = dabs * dcos;
dy = dabs * dsin; dy = dabs * dsin;
@@ -1699,7 +1626,7 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
return; return;
// accumulate // accumulate
touch.yaw -= dx * touch_yaw.value, touch.pitch += dy * touch_pitch.value; touch.yaw -= dx * touch_yaw->value, touch.pitch += dy * touch_pitch->value;
} }
} }
@@ -2022,10 +1949,8 @@ static int Touch_ControlsEvent( touchEventType type, int fingerID, float x, floa
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ) int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy )
{ {
y *= SCR_H/SCR_W/Touch_AspectRatio();
// Con_Printf("%f %f\n", TO_SCRN_X(x), TO_SCRN_Y(y));
// simulate menu mouse click // simulate menu mouse click
if( cls.key_dest != key_game && !touch_in_menu.value ) if( cls.key_dest != key_game && !CVAR_TO_BOOL( touch_in_menu ))
{ {
touch.move_finger = touch.resize_finger = touch.look_finger = -1; touch.move_finger = touch.resize_finger = touch.look_finger = -1;
// Hack for keyboard, hope it help // Hack for keyboard, hope it help

View File

@@ -36,15 +36,16 @@ static struct inputstate_s
float lastpitch, lastyaw; float lastpitch, lastyaw;
} inputstate; } inputstate;
CVAR_DEFINE_AUTO( m_pitch, "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse pitch value" ); extern convar_t *vid_fullscreen;
CVAR_DEFINE_AUTO( m_yaw, "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse yaw value" ); convar_t *m_pitch;
CVAR_DEFINE_AUTO( m_ignore, DEFAULT_M_IGNORE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "ignore mouse events" ); convar_t *m_yaw;
static CVAR_DEFINE_AUTO( look_filter, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "filter look events making it smoother" );
static CVAR_DEFINE_AUTO( m_rawinput, "1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable mouse raw input" );
static CVAR_DEFINE_AUTO( cl_forwardspeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default forward move speed" ); convar_t *m_ignore;
static CVAR_DEFINE_AUTO( cl_backspeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default back move speed" ); convar_t *cl_forwardspeed;
static CVAR_DEFINE_AUTO( cl_sidespeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default side move speed" ); convar_t *cl_sidespeed;
convar_t *cl_backspeed;
convar_t *look_filter;
convar_t *m_rawinput;
/* /*
================ ================
@@ -57,7 +58,7 @@ uint IN_CollectInputDevices( void )
{ {
uint ret = 0; uint ret = 0;
if( !m_ignore.value ) // no way to check is mouse connected, so use cvar only if( !m_ignore->value ) // no way to check is mouse connected, so use cvar only
ret |= INPUT_DEVICE_MOUSE; ret |= INPUT_DEVICE_MOUSE;
if( touch_enable.value ) if( touch_enable.value )
@@ -85,18 +86,18 @@ player is connected to the server
*/ */
void IN_LockInputDevices( qboolean lock ) void IN_LockInputDevices( qboolean lock )
{ {
extern convar_t joy_enable; // private to input system extern convar_t *joy_enable; // private to input system
if( lock ) if( lock )
{ {
SetBits( m_ignore.flags, FCVAR_READ_ONLY ); SetBits( m_ignore->flags, FCVAR_READ_ONLY );
SetBits( joy_enable.flags, FCVAR_READ_ONLY ); SetBits( joy_enable->flags, FCVAR_READ_ONLY );
SetBits( touch_enable.flags, FCVAR_READ_ONLY ); SetBits( touch_enable.flags, FCVAR_READ_ONLY );
} }
else else
{ {
ClearBits( m_ignore.flags, FCVAR_READ_ONLY ); ClearBits( m_ignore->flags, FCVAR_READ_ONLY );
ClearBits( joy_enable.flags, FCVAR_READ_ONLY ); ClearBits( joy_enable->flags, FCVAR_READ_ONLY );
ClearBits( touch_enable.flags, FCVAR_READ_ONLY ); ClearBits( touch_enable.flags, FCVAR_READ_ONLY );
} }
} }
@@ -107,14 +108,14 @@ void IN_LockInputDevices( qboolean lock )
IN_StartupMouse IN_StartupMouse
=========== ===========
*/ */
static void IN_StartupMouse( void ) void IN_StartupMouse( void )
{ {
Cvar_RegisterVariable( &m_ignore ); m_ignore = Cvar_Get( "m_ignore", DEFAULT_M_IGNORE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "ignore mouse events" );
Cvar_RegisterVariable( &m_pitch ); m_pitch = Cvar_Get( "m_pitch", "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse pitch value" );
Cvar_RegisterVariable( &m_yaw ); m_yaw = Cvar_Get( "m_yaw", "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse yaw value" );
Cvar_RegisterVariable( &look_filter ); look_filter = Cvar_Get( "look_filter", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "filter look events making it smoother" );
Cvar_RegisterVariable( &m_rawinput ); m_rawinput = Cvar_Get( "m_rawinput", "1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable mouse raw input" );
// You can use -nomouse argument to prevent using mouse from client // You can use -nomouse argument to prevent using mouse from client
// -noenginemouse will disable all mouse input // -noenginemouse will disable all mouse input
@@ -179,6 +180,9 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
{ {
Platform_SetCursorType( dc_arrow ); Platform_SetCursorType( dc_arrow );
#if XASH_ANDROID
Android_ShowMouse( true );
#endif
#if XASH_USE_EVDEV #if XASH_USE_EVDEV
Evdev_SetGrab( false ); Evdev_SetGrab( false );
#endif #endif
@@ -187,15 +191,14 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
{ {
Platform_SetCursorType( dc_none ); Platform_SetCursorType( dc_none );
#if XASH_ANDROID
Android_ShowMouse( false );
#endif
#if XASH_USE_EVDEV #if XASH_USE_EVDEV
Evdev_SetGrab( true ); Evdev_SetGrab( true );
#endif #endif
} }
// don't leave the user without cursor if they enabled m_ignore
if( m_ignore.value )
return;
if( oldstate == key_game ) if( oldstate == key_game )
{ {
IN_DeactivateMouse(); IN_DeactivateMouse();
@@ -206,19 +209,16 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
} }
} }
static void IN_CheckMouseState( qboolean active ) void IN_CheckMouseState( qboolean active )
{ {
static qboolean s_bRawInput, s_bMouseGrab; static qboolean s_bRawInput, s_bMouseGrab;
#if XASH_WIN32 #if XASH_WIN32
qboolean useRawInput = ( m_rawinput.value && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL; qboolean useRawInput = ( CVAR_TO_BOOL( m_rawinput ) && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL;
#else #else
qboolean useRawInput = true; // always use SDL code qboolean useRawInput = true; // always use SDL code
#endif #endif
if( m_ignore.value )
return;
if( active && useRawInput && !host.mouse_visible && cls.state == ca_active ) if( active && useRawInput && !host.mouse_visible && cls.state == ca_active )
{ {
if( !s_bRawInput ) if( !s_bRawInput )
@@ -313,7 +313,7 @@ void IN_DeactivateMouse( void )
IN_MouseMove IN_MouseMove
================ ================
*/ */
static void IN_MouseMove( void ) void IN_MouseMove( void )
{ {
int x, y; int x, y;
@@ -414,9 +414,9 @@ IN_Init
*/ */
void IN_Init( void ) void IN_Init( void )
{ {
Cvar_RegisterVariable( &cl_forwardspeed ); cl_forwardspeed = Cvar_Get( "cl_forwardspeed", "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default forward move speed" );
Cvar_RegisterVariable( &cl_backspeed ); cl_backspeed = Cvar_Get( "cl_backspeed", "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default back move speed" );
Cvar_RegisterVariable( &cl_sidespeed ); cl_sidespeed = Cvar_Get( "cl_sidespeed", "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default side move speed" );
if( !Host_IsDedicated() ) if( !Host_IsDedicated() )
{ {
@@ -453,8 +453,8 @@ static void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove
{ {
static uint moveflags = T | S; static uint moveflags = T | S;
if( forwardmove ) cmd->forwardmove = forwardmove * cl_forwardspeed.value; if( forwardmove ) cmd->forwardmove = forwardmove * cl_forwardspeed->value;
if( sidemove ) cmd->sidemove = sidemove * cl_sidespeed.value; if( sidemove ) cmd->sidemove = sidemove * cl_sidespeed->value;
if( forwardmove ) if( forwardmove )
{ {
@@ -529,8 +529,8 @@ static void IN_CollectInput( float *forward, float *side, float *pitch, float *y
{ {
float x, y; float x, y;
Platform_MouseMove( &x, &y ); Platform_MouseMove( &x, &y );
*pitch += y * m_pitch.value; *pitch += y * m_pitch->value;
*yaw -= x * m_yaw.value; *yaw -= x * m_yaw->value;
#if XASH_USE_EVDEV #if XASH_USE_EVDEV
IN_EvdevMove( yaw, pitch ); IN_EvdevMove( yaw, pitch );
@@ -540,7 +540,7 @@ static void IN_CollectInput( float *forward, float *side, float *pitch, float *y
Joy_FinalizeMove( forward, side, yaw, pitch ); Joy_FinalizeMove( forward, side, yaw, pitch );
Touch_GetMove( forward, side, yaw, pitch ); Touch_GetMove( forward, side, yaw, pitch );
if( look_filter.value ) if( look_filter->value )
{ {
*pitch = ( inputstate.lastpitch + *pitch ) / 2; *pitch = ( inputstate.lastpitch + *pitch ) / 2;
*yaw = ( inputstate.lastyaw + *yaw ) / 2; *yaw = ( inputstate.lastyaw + *yaw ) / 2;
@@ -588,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 #if XASH_USE_EVDEV
IN_EvdevFrame(); IN_EvdevFrame();
@@ -598,7 +598,7 @@ static void IN_Commands( void )
{ {
float forward = 0, side = 0, pitch = 0, yaw = 0; float forward = 0, side = 0, pitch = 0, yaw = 0;
IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized && !m_ignore.value ); IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized && !CVAR_TO_BOOL( m_ignore ) );
if( cls.key_dest == key_game ) if( cls.key_dest == key_game )
{ {

View File

@@ -46,8 +46,8 @@ uint IN_CollectInputDevices( void );
void IN_LockInputDevices( qboolean lock ); void IN_LockInputDevices( qboolean lock );
void IN_EngineAppendMove( float frametime, void *cmd, qboolean active ); void IN_EngineAppendMove( float frametime, void *cmd, qboolean active );
extern convar_t m_yaw; extern convar_t *m_yaw;
extern convar_t m_pitch; extern convar_t *m_pitch;
// //
// in_touch.c // in_touch.c
// //
@@ -75,7 +75,6 @@ void Touch_ResetDefaultButtons( void );
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ); int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
void Touch_KeyEvent( int key, int down ); void Touch_KeyEvent( int key, int down );
qboolean Touch_WantVisibleCursor( void ); qboolean Touch_WantVisibleCursor( void );
void Touch_NotifyResize( void );
// //
// in_joy.c // in_joy.c

View File

@@ -144,8 +144,8 @@ keyname_t keynames[] =
static void OSK_EnableTextInput( qboolean enable, qboolean force ); static void OSK_EnableTextInput( qboolean enable, qboolean force );
static qboolean OSK_KeyEvent( int key, int down ); static qboolean OSK_KeyEvent( int key, int down );
static CVAR_DEFINE_AUTO( osk_enable, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "enable built-in on-screen keyboard" ); static convar_t *osk_enable;
static CVAR_DEFINE_AUTO( key_rotate, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "rotate arrow keys (0-3)" ); static convar_t *key_rotate;
/* /*
=================== ===================
@@ -332,7 +332,7 @@ int Key_GetKey( const char *pBinding )
Key_Unbind_f Key_Unbind_f
=================== ===================
*/ */
static void Key_Unbind_f( void ) void Key_Unbind_f( void )
{ {
int b; int b;
@@ -358,7 +358,7 @@ static void Key_Unbind_f( void )
Key_Unbindall_f Key_Unbindall_f
=================== ===================
*/ */
static void Key_Unbindall_f( void ) void Key_Unbindall_f( void )
{ {
int i; int i;
@@ -378,7 +378,7 @@ static void Key_Unbindall_f( void )
Key_Reset_f Key_Reset_f
=================== ===================
*/ */
static void Key_Reset_f( void ) void Key_Reset_f( void )
{ {
keyname_t *kn; keyname_t *kn;
int i; int i;
@@ -400,7 +400,7 @@ static void Key_Reset_f( void )
Key_Bind_f Key_Bind_f
=================== ===================
*/ */
static void Key_Bind_f( void ) void Key_Bind_f( void )
{ {
char cmd[1024]; char cmd[1024];
int i, c, b; int i, c, b;
@@ -473,7 +473,7 @@ Key_Bindlist_f
============ ============
*/ */
static void Key_Bindlist_f( void ) void Key_Bindlist_f( void )
{ {
int i; int i;
@@ -513,8 +513,8 @@ void Key_Init( void )
// setup default binding. "unbindall" from config.cfg will be reset it // setup default binding. "unbindall" from config.cfg will be reset it
for( kn = keynames; kn->name; kn++ ) Key_SetBinding( kn->keynum, kn->binding ); for( kn = keynames; kn->name; kn++ ) Key_SetBinding( kn->keynum, kn->binding );
Cvar_RegisterVariable( &osk_enable ); osk_enable = Cvar_Get( "osk_enable", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable built-in on-screen keyboard" );
Cvar_RegisterVariable( &key_rotate ); key_rotate = Cvar_Get( "key_rotate", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "rotate arrow keys (0-3)" );
} }
@@ -523,7 +523,7 @@ void Key_Init( void )
Key_AddKeyCommands 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 button[1024];
char *buttonPtr; char *buttonPtr;
@@ -590,7 +590,7 @@ static qboolean Key_IsAllowedAutoRepeat( int key )
static int Key_Rotate( int key ) static int Key_Rotate( int key )
{ {
if( key_rotate.value == 1.0f ) // CW if( key_rotate->value == 1.0f ) // CW
{ {
if( key == K_UPARROW ) if( key == K_UPARROW )
key = K_LEFTARROW; key = K_LEFTARROW;
@@ -602,7 +602,7 @@ static int Key_Rotate( int key )
key = K_RIGHTARROW; key = K_RIGHTARROW;
} }
else if( key_rotate.value == 3.0f ) // CCW else if( key_rotate->value == 3.0f ) // CCW
{ {
if( key == K_UPARROW ) if( key == K_UPARROW )
key = K_RIGHTARROW; key = K_RIGHTARROW;
@@ -614,7 +614,7 @@ static int Key_Rotate( int key )
key = K_LEFTARROW; key = K_LEFTARROW;
} }
else if( key_rotate.value == 2.0f ) else if( key_rotate->value == 2.0f )
{ {
if( key == K_UPARROW ) if( key == K_UPARROW )
key = K_DOWNARROW; key = K_DOWNARROW;
@@ -719,10 +719,10 @@ void GAME_EXPORT Key_Event( int key, int down )
switch( cls.key_dest ) switch( cls.key_dest )
{ {
case key_game: case key_game:
if( r_showtextures.value ) if( CVAR_TO_BOOL( gl_showtextures ))
{ {
// close texture atlas // close texture atlas
Cvar_DirectSet( &r_showtextures, "0" ); Cvar_SetValue( "r_showtextures", 0.0f );
return; return;
} }
else if( host.mouse_visible && cls.state != ca_cinematic ) else if( host.mouse_visible && cls.state != ca_cinematic )
@@ -797,7 +797,7 @@ Key_EnableTextInput
*/ */
void Key_EnableTextInput( qboolean enable, qboolean force ) void Key_EnableTextInput( qboolean enable, qboolean force )
{ {
if( osk_enable.value ) if( CVAR_TO_BOOL( osk_enable ) )
{ {
OSK_EnableTextInput( enable, force ); OSK_EnableTextInput( enable, force );
return; return;
@@ -995,7 +995,7 @@ struct osk_s
static qboolean OSK_KeyEvent( int key, int down ) static qboolean OSK_KeyEvent( int key, int down )
{ {
if( !osk.enable || !osk_enable.value ) if( !osk.enable || !CVAR_TO_BOOL( osk_enable ) )
return false; return false;
if( osk.sending ) if( osk.sending )
@@ -1055,7 +1055,7 @@ static qboolean OSK_KeyEvent( int key, int down )
break; break;
} }
if( !Q_stricmp( cl_charset.string, "utf-8" ) ) if( !Q_stricmp( cl_charset->string, "utf-8" ) )
ch = (unsigned char)osk.curbutton.val; ch = (unsigned char)osk.curbutton.val;
else else
ch = Con_UtfProcessCharForce( (unsigned char)osk.curbutton.val ); ch = Con_UtfProcessCharForce( (unsigned char)osk.curbutton.val );
@@ -1190,7 +1190,7 @@ void OSK_Draw( void )
float x, y; float x, y;
int i, j; int i, j;
if( !osk.enable || !osk_enable.value || !osk.curbutton.val ) if( !osk.enable || !CVAR_TO_BOOL(osk_enable) || !osk.curbutton.val )
return; return;
// draw keyboard // draw keyboard

View File

@@ -659,7 +659,7 @@ static void make_hull_windings( hull_t *hull, hull_model_t *model )
Con_Reportf( "%i hull polys\n", model->num_polys ); Con_Reportf( "%i hull polys\n", model->num_polys );
} }
void Mod_InitDebugHulls( model_t *loadmodel ) void Mod_InitDebugHulls( void )
{ {
int i; int i;

View File

@@ -8,40 +8,14 @@
struct ref_state_s ref; struct ref_state_s ref;
ref_globals_t refState; ref_globals_t refState;
CVAR_DEFINE_AUTO( gl_vsync, "0", FCVAR_ARCHIVE, "enable vertical syncronization" ); convar_t *gl_vsync;
CVAR_DEFINE_AUTO( r_showtextures, "0", FCVAR_CHEAT, "show all uploaded textures" ); convar_t *gl_showtextures;
CVAR_DEFINE_AUTO( r_adjust_fov, "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" ); convar_t *r_decals;
CVAR_DEFINE_AUTO( r_decals, "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" ); convar_t *r_adjust_fov;
CVAR_DEFINE_AUTO( gl_msaa_samples, "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" ); convar_t *r_showtree;
CVAR_DEFINE_AUTO( gl_clear, "0", FCVAR_ARCHIVE, "clearing screen after each frame" ); convar_t *gl_msaa_samples;
CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" ); convar_t *gl_clear;
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" ); convar_t *r_refdll;
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 ) void R_GetTextureParms( int *w, int *h, int texnum )
{ {
@@ -67,8 +41,18 @@ void GAME_EXPORT GL_FreeImage( const char *name )
ref.dllFuncs.GL_FreeTexture( texnum ); 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 ) void GL_RenderFrame( const ref_viewpass_t *rvp )
{ {
R_UpdateRefState();
VectorCopy( rvp->vieworigin, refState.vieworg ); VectorCopy( rvp->vieworigin, refState.vieworg );
VectorCopy( rvp->viewangles, refState.viewangles ); VectorCopy( rvp->viewangles, refState.viewangles );
@@ -80,6 +64,11 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
return CL_RenderGetParm( parm, arg, false ); // prevent recursion 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 ) static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
{ {
clgame.dllFuncs.pfnStudioEvent( event, e ); clgame.dllFuncs.pfnStudioEvent( event, e );
@@ -109,10 +98,24 @@ static void *pfnMod_Extradata( int type, model_t *m )
return NULL; return NULL;
} }
static void CL_ExtraUpdate( void ) static model_t *pfnMod_GetCurrentLoadingModel( void )
{ {
clgame.dllFuncs.IN_Accumulate(); return loadmodel;
S_ExtraUpdate(); }
static void pfnMod_SetCurrentLoadingModel( model_t *m )
{
loadmodel = m;
}
static void pfnGetPredictedOrigin( vec3_t v )
{
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 static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
@@ -164,6 +167,11 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
0; 0;
} }
static poolhandle_t pfnImage_GetPool( void )
{
return host.imagepool;
}
static const bpc_desc_t *pfnImage_GetPFDesc( int idx ) static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
{ {
return &PFDesc[idx]; return &PFDesc[idx];
@@ -184,6 +192,25 @@ static screenfade_t *pfnRefGetScreenFade( void )
return &clgame.fade; 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 ) static qboolean R_Init_Video_( const int type )
{ {
host.apply_opengl_config = true; host.apply_opengl_config = true;
@@ -204,7 +231,7 @@ static ref_api_t gEngfuncs =
Cvar_VariableString, Cvar_VariableString,
Cvar_SetValue, Cvar_SetValue,
Cvar_Set, Cvar_Set,
Cvar_RegisterVariable, (void*)Cvar_RegisterVariable,
Cvar_FullSet, Cvar_FullSet,
Cmd_AddRefCommand, Cmd_AddRefCommand,
@@ -228,12 +255,16 @@ static ref_api_t gEngfuncs =
Con_DrawString, Con_DrawString,
CL_DrawCenterPrint, CL_DrawCenterPrint,
CL_GetLocalPlayer,
CL_GetViewModel,
CL_GetEntityByIndex,
R_BeamGetEntity, R_BeamGetEntity,
CL_GetWaterEntity, CL_GetWaterEntity,
CL_AddVisibleEntity, CL_AddVisibleEntity,
Mod_SampleSizeForFace, Mod_SampleSizeForFace,
Mod_BoxVisible, Mod_BoxVisible,
pfnGetWorld,
Mod_PointInLeaf, Mod_PointInLeaf,
Mod_CreatePolygonsForHull, Mod_CreatePolygonsForHull,
@@ -250,9 +281,14 @@ static ref_api_t gEngfuncs =
Mod_ForName, Mod_ForName,
pfnMod_Extradata, pfnMod_Extradata,
CL_ModelHandle,
pfnMod_GetCurrentLoadingModel,
pfnMod_SetCurrentLoadingModel,
CL_EntitySetRemapColors,
CL_GetRemapInfoForEntity, CL_GetRemapInfoForEntity,
CL_AllocRemapInfo,
CL_FreeRemapInfo,
CL_UpdateRemapInfo,
CL_ExtraUpdate, CL_ExtraUpdate,
Host_Error, Host_Error,
@@ -260,6 +296,9 @@ static ref_api_t gEngfuncs =
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,
pfnRefGetScreenFade, pfnRefGetScreenFade,
CL_TextMessageGet,
pfnGetPredictedOrigin,
pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo, pfnCL_GetScreenInfo,
pfnSetLocalLightLevel, pfnSetLocalLightLevel,
Sys_CheckParm, Sys_CheckParm,
@@ -293,11 +332,9 @@ static ref_api_t gEngfuncs =
SW_LockBuffer, SW_LockBuffer,
SW_UnlockBuffer, SW_UnlockBuffer,
BuildGammaTable,
LightToTexGamma, LightToTexGamma,
LightToTexGammaEx, R_DoResetGamma,
TextureToGamma,
ScreenGammaTable,
LinearGammaTable,
CL_GetLightStyle, CL_GetLightStyle,
CL_GetDynamicLight, CL_GetDynamicLight,
@@ -311,6 +348,7 @@ static ref_api_t gEngfuncs =
PM_CL_TraceLine, PM_CL_TraceLine,
CL_VisTraceLine, CL_VisTraceLine,
CL_TraceLine, CL_TraceLine,
pfnGetMoveVars,
Image_AddCmdFlags, Image_AddCmdFlags,
Image_SetForceFlags, Image_SetForceFlags,
@@ -322,6 +360,7 @@ static ref_api_t gEngfuncs =
FS_CopyImage, FS_CopyImage,
FS_FreeImage, FS_FreeImage,
Image_SetMDLPointer, Image_SetMDLPointer,
pfnImage_GetPool,
pfnImage_GetPFDesc, pfnImage_GetPFDesc,
pfnDrawNormalTriangles, pfnDrawNormalTriangles,
@@ -340,14 +379,14 @@ static void R_UnloadProgs( void )
Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY ); Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY );
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG );
Cmd_Unlink( CMD_REFDLL );
COM_FreeLibrary( ref.hInstance ); COM_FreeLibrary( ref.hInstance );
ref.hInstance = NULL; ref.hInstance = NULL;
memset( &refState, 0, sizeof( refState )); memset( &refState, 0, sizeof( refState ));
memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs )); memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs ));
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG );
Cmd_Unlink( CMD_REFDLL );
} }
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src ) static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
@@ -403,7 +442,7 @@ static qboolean R_LoadProgs( const char *name )
// make local copy of engfuncs to prevent overwrite it with user dll // make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs )); 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 ); COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" ); Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
@@ -492,7 +531,6 @@ static qboolean R_LoadRenderer( const char *refopt )
return false; return false;
} }
Cvar_FullSet( "r_refdll_loaded", refopt, FCVAR_READ_ONLY );
Con_Reportf( "Renderer %s initialized\n", refdll ); Con_Reportf( "Renderer %s initialized\n", refdll );
return true; return true;
@@ -511,17 +549,21 @@ static void SetWidthAndHeightFromCommandLine( void )
return; return;
} }
R_SaveVideoMode( width, height, width, height, false ); R_SaveVideoMode( width, height, width, height );
} }
static void SetFullscreenModeFromCommandLine( void ) static void SetFullscreenModeFromCommandLine( void )
{ {
if( Sys_CheckParm( "-borderless" )) #if !XASH_MOBILE_PLATFORM
Cvar_DirectSet( &vid_fullscreen, "2" ); if( Sys_CheckParm( "-fullscreen" ))
else if( Sys_CheckParm( "-fullscreen" )) {
Cvar_DirectSet( &vid_fullscreen, "1" ); Cvar_Set( "fullscreen", "1" );
}
else if( Sys_CheckParm( "-windowed" )) else if( Sys_CheckParm( "-windowed" ))
Cvar_DirectSet( &vid_fullscreen, "0" ); {
Cvar_Set( "fullscreen", "0" );
}
#endif
} }
static void R_CollectRendererNames( void ) static void R_CollectRendererNames( void )
@@ -541,9 +583,6 @@ static void R_CollectRendererNames( void )
#if XASH_REF_GL4ES_ENABLED #if XASH_REF_GL4ES_ENABLED
"gl4es", "gl4es",
#endif #endif
#if XASH_REF_GLES3COMPAT_ENABLED
"gles3compat",
#endif
#if XASH_REF_SOFT_ENABLED #if XASH_REF_SOFT_ENABLED
"soft", "soft",
#endif #endif
@@ -564,9 +603,6 @@ static void R_CollectRendererNames( void )
#if XASH_REF_GL4ES_ENABLED #if XASH_REF_GL4ES_ENABLED
"GL4ES", "GL4ES",
#endif #endif
#if XASH_REF_GLES3COMPAT_ENABLED
"GLES3 (gl2_shim)"
#endif
#if XASH_REF_SOFT_ENABLED #if XASH_REF_SOFT_ENABLED
"Software", "Software",
#endif #endif
@@ -582,15 +618,14 @@ qboolean R_Init( void )
qboolean success = false; qboolean success = false;
string requested; string requested;
Cvar_RegisterVariable( &gl_vsync ); gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
Cvar_RegisterVariable( &r_showtextures ); gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" );
Cvar_RegisterVariable( &r_adjust_fov ); r_adjust_fov = Cvar_Get( "r_adjust_fov", "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
Cvar_RegisterVariable( &r_decals ); r_decals = Cvar_Get( "r_decals", "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
Cvar_RegisterVariable( &gl_msaa_samples ); gl_msaa_samples = Cvar_Get( "gl_msaa_samples", "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" );
Cvar_RegisterVariable( &gl_clear ); gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
Cvar_RegisterVariable( &r_showtree ); r_showtree = Cvar_Get( "r_showtree", "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
Cvar_RegisterVariable( &r_refdll ); r_refdll = Cvar_Get( "r_refdll", "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
Cvar_RegisterVariable( &r_refdll_loaded );
// cvars that are expected to exist // cvars that are expected to exist
Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" ); Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );
@@ -611,7 +646,6 @@ qboolean R_Init( void )
// cvars that are expected to exist by client.dll // cvars that are expected to exist by client.dll
// refdll should just get pointer to them // 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( "r_drawentities", "1", FCVAR_CHEAT, "render entities" );
Cvar_Get( "cl_himodels", "1", FCVAR_ARCHIVE, "draw high-resolution player models in multiplayer" ); Cvar_Get( "cl_himodels", "1", FCVAR_ARCHIVE, "draw high-resolution player models in multiplayer" );
@@ -635,9 +669,9 @@ qboolean R_Init( void )
if( !success && Sys_GetParmFromCmdLine( "-ref", requested )) if( !success && Sys_GetParmFromCmdLine( "-ref", requested ))
success = R_LoadRenderer( requested ); success = R_LoadRenderer( requested );
if( !success && COM_CheckString( r_refdll.string )) if( !success && COM_CheckString( r_refdll->string ))
{ {
Q_strncpy( requested, r_refdll.string, sizeof( requested )); Q_strncpy( requested, r_refdll->string, sizeof( requested ));
success = R_LoadRenderer( requested ); success = R_LoadRenderer( requested );
} }
@@ -657,7 +691,7 @@ qboolean R_Init( void )
if( !success ) if( !success )
{ {
Host_Error( "Can't initialize any renderer. Check your video drivers!\n" ); Host_Error( "Can't initialize any renderer. Check your video drivers!" );
return false; return false;
} }

View File

@@ -46,12 +46,13 @@ void R_GetTextureParms( int *w, int *h, int texnum );
void GL_RenderFrame( const struct ref_viewpass_s *rvp ); void GL_RenderFrame( const struct ref_viewpass_s *rvp );
// common engine and renderer cvars // common engine and renderer cvars
extern convar_t r_decals; extern convar_t *r_decals;
extern convar_t r_adjust_fov; extern convar_t *r_adjust_fov;
extern convar_t gl_clear; extern convar_t *gl_clear;
qboolean R_Init( void ); qboolean R_Init( void );
void R_Shutdown( void ); void R_Shutdown( void );
void R_UpdateRefState( void );
extern triangleapi_t gTriApi; extern triangleapi_t gTriApi;

View File

@@ -1,7 +1,6 @@
/* /*
s_dsp.c - digital signal processing algorithms for audio FX s_dsp.c - digital signal processing algorithms for audio FX
Copyright (C) 2009 Uncle Mike Copyright (C) 2009 Uncle Mike
Copyright (C) 2016-2024 Alibek Omarov
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -79,7 +78,7 @@ typedef struct dly_s
int *lpdelayline; int *lpdelayline;
} dly_t; } dly_t;
static const sx_preset_t rgsxpre[] = const sx_preset_t rgsxpre[] =
{ {
// -------reverb-------- -------delay-------- // -------reverb-------- -------delay--------
// lp mod size refl rvblp delay feedback dlylp left // lp mod size refl rvblp delay feedback dlylp left
@@ -116,7 +115,7 @@ static const sx_preset_t rgsxpre[] =
// 0x0045dca8 enginegl.exe // 0x0045dca8 enginegl.exe
// SHA256: 42383d32cd712e59ee2c1bd78b7ba48814e680e7026c4223e730111f34a60d66 // SHA256: 42383d32cd712e59ee2c1bd78b7ba48814e680e7026c4223e730111f34a60d66
static const sx_preset_t rgsxpre_hlalpha052[] = const sx_preset_t rgsxpre_hlalpha052[] =
{ {
// -------reverb-------- -------delay-------- // -------reverb-------- -------delay--------
// lp mod size refl rvblp delay feedback dlylp left // lp mod size refl rvblp delay feedback dlylp left
@@ -151,50 +150,51 @@ static const sx_preset_t rgsxpre_hlalpha052[] =
{ 0.0, 0.0, 0.001, 0.999, 0.0, 0.2, 0.8, 2.0, 0.05 }, // 28 { 0.0, 0.0, 0.001, 0.999, 0.0, 0.2, 0.8, 2.0, 0.05 }, // 28
}; };
static const sx_preset_t *ptable = rgsxpre; const sx_preset_t *ptable = rgsxpre;
// cvars // cvars
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing" ); convar_t *dsp_off; // disable dsp
static CVAR_DEFINE_AUTO( dsp_coeff_table, "0", FCVAR_ARCHIVE, "select DSP coefficient table: 0 for release or 1 for alpha 0.52" ); convar_t *roomwater_type; // water room_type
static CVAR_DEFINE_AUTO( room_type, "0", 0, "current room type preset" ); convar_t *room_type; // current room type
convar_t *hisound; // DSP quality
static CVAR_DEFINE( roomwater_type, "waterroom_type", "14", 0, "water room type" );
static CVAR_DEFINE( hisound, "room_hires", "2", FCVAR_ARCHIVE, "dsp quality. 1 for 22k, 2 for 44k(recommended) and 3 for 96k" );
// underwater/special fx modulations // underwater/special fx modulations
static CVAR_DEFINE( sxmod_mod, "room_mod", "0", 0, "stereo amptitude modulation for room" ); convar_t *sxmod_mod;
static CVAR_DEFINE( sxmod_lowpass, "room_lp", "0", 0, "for water fx, lowpass for entire room" ); convar_t *sxmod_lowpass;
// stereo delay(no feedback) // stereo delay(no feedback)
static CVAR_DEFINE( sxste_delay, "room_left", "0", 0, "left channel delay time" ); convar_t *sxste_delay; // straight left delay
// mono reverb // mono reverb
static CVAR_DEFINE( sxrvb_lp, "room_rvblp", "1", 0, "reverb: low pass filtering level" ); convar_t *sxrvb_lp; // lowpass
static CVAR_DEFINE( sxrvb_feedback, "room_refl", "0", 0, "reverb: decay time" ); convar_t *sxrvb_feedback; // reverb decay. Higher -- longer
static CVAR_DEFINE( sxrvb_size, "room_size", "0", 0, "reverb: initial reflection size" ); convar_t *sxrvb_size; // room size. Higher -- larger
// mono delay // mono delay
static CVAR_DEFINE( sxdly_lp, "room_dlylp", "1", 0, "mono delay: low pass filtering level" ); convar_t *sxdly_lp; // lowpass
static CVAR_DEFINE( sxdly_feedback, "room_feedback", "0.2", 0, "mono delay: decay time" ); convar_t *sxdly_feedback; // cycles
static CVAR_DEFINE( sxdly_delay, "room_delay", "0.8", 0, "mono delay: delay time" ); convar_t *sxdly_delay; // current delay in seconds
static int idsp_dma_speed; convar_t *dsp_room; // for compability
convar_t *dsp_coeff_table; // use release or 0.52 style
int idsp_dma_speed;
int idsp_room; int idsp_room;
static int room_typeprev; int room_typeprev;
// routines // routines
static int sxamodl, sxamodr; // amplitude modulation values int sxamodl, sxamodr; // amplitude modulation values
static int sxamodlt, sxamodrt; // modulation targets int sxamodlt, sxamodrt; // modulation targets
static int sxmod1cur, sxmod2cur; int sxmod1cur, sxmod2cur;
static int sxmod1, sxmod2; int sxmod1, sxmod2;
static int sxhires; int sxhires;
static portable_samplepair_t *paintto = NULL; portable_samplepair_t *paintto = NULL;
static dly_t rgsxdly[MAXDLY]; // stereo is last dly_t rgsxdly[MAXDLY]; // stereo is last
static int rgsxlp[MAXLP]; int rgsxlp[MAXLP];
static void SX_Profiling_f( void ); void SX_Profiling_f( void );
/* /*
============ ============
@@ -202,12 +202,14 @@ SX_ReloadRoomFX
============ ============
*/ */
static void SX_ReloadRoomFX( void ) void SX_ReloadRoomFX( void )
{ {
SetBits( sxste_delay.flags, FCVAR_CHANGED ); if( !dsp_room ) return; // not initialized
SetBits( sxrvb_feedback.flags, FCVAR_CHANGED );
SetBits( sxdly_delay.flags, FCVAR_CHANGED ); SetBits( sxste_delay->flags, FCVAR_CHANGED );
SetBits( room_type.flags, FCVAR_CHANGED ); SetBits( sxrvb_feedback->flags, FCVAR_CHANGED );
SetBits( sxdly_delay->flags, FCVAR_CHANGED );
SetBits( room_type->flags, FCVAR_CHANGED );
} }
/* /*
@@ -225,33 +227,36 @@ void SX_Init( void )
sxamodr = sxamodl = sxamodrt = sxamodlt = 255; sxamodr = sxamodl = sxamodrt = sxamodlt = 255;
idsp_dma_speed = SOUND_11k; idsp_dma_speed = SOUND_11k;
Cvar_RegisterVariable( &hisound ); hisound = Cvar_Get( "room_hires", "2", FCVAR_ARCHIVE, "dsp quality. 1 for 22k, 2 for 44k(recommended) and 3 for 96k" );
sxhires = 2; sxhires = 2;
sxmod1cur = sxmod1 = 350 * ( idsp_dma_speed / SOUND_11k ); sxmod1cur = sxmod1 = 350 * ( idsp_dma_speed / SOUND_11k );
sxmod2cur = sxmod2 = 450 * ( idsp_dma_speed / SOUND_11k ); sxmod2cur = sxmod2 = 450 * ( idsp_dma_speed / SOUND_11k );
Cvar_RegisterVariable( &dsp_off ); dsp_off = Cvar_Get( "dsp_off", "0", FCVAR_ARCHIVE, "disable DSP processing" );
Cvar_RegisterVariable( &dsp_coeff_table ); dsp_coeff_table = Cvar_Get( "dsp_coeff_table", "0", FCVAR_ARCHIVE, "select DSP coefficient table: 0 for release or 1 for alpha 0.52" );
Cvar_RegisterVariable( &roomwater_type ); roomwater_type = Cvar_Get( "waterroom_type", "14", 0, "water room type" );
Cvar_RegisterVariable( &room_type ); room_type = Cvar_Get( "room_type", "0", 0, "current room type preset" );
Cvar_RegisterVariable( &sxmod_lowpass ); sxmod_lowpass = Cvar_Get( "room_lp", "0", 0, "for water fx, lowpass for entire room" );
Cvar_RegisterVariable( &sxmod_mod ); sxmod_mod = Cvar_Get( "room_mod", "0", 0, "stereo amptitude modulation for room" );
Cvar_RegisterVariable( &sxrvb_size ); sxrvb_size = Cvar_Get( "room_size", "0", 0, "reverb: initial reflection size" );
Cvar_RegisterVariable( &sxrvb_feedback ); sxrvb_feedback = Cvar_Get( "room_refl", "0", 0, "reverb: decay time" );
Cvar_RegisterVariable( &sxrvb_lp ); sxrvb_lp = Cvar_Get( "room_rvblp", "1", 0, "reverb: low pass filtering level" );
Cvar_RegisterVariable( &sxdly_delay ); sxdly_delay = Cvar_Get( "room_delay", "0.8", 0, "mono delay: delay time" );
Cvar_RegisterVariable( &sxdly_feedback ); sxdly_feedback = Cvar_Get( "room_feedback", "0.2", 0, "mono delay: decay time" );
Cvar_RegisterVariable( &sxdly_lp ); sxdly_lp = Cvar_Get( "room_dlylp", "1", 0, "mono delay: low pass filtering level" );
Cvar_RegisterVariable( &sxste_delay ); sxste_delay = Cvar_Get( "room_left", "0", 0, "left channel delay time" );
Cmd_AddCommand( "dsp_profile", SX_Profiling_f, "dsp stress-test, first argument is room_type" ); Cmd_AddCommand( "dsp_profile", SX_Profiling_f, "dsp stress-test, first argument is room_type" );
// for compability
dsp_room = room_type;
SX_ReloadRoomFX(); SX_ReloadRoomFX();
} }
@@ -262,7 +267,7 @@ DLY_Free
Free memory allocated for DSP Free memory allocated for DSP
=========== ===========
*/ */
static void DLY_Free( int idelay ) void DLY_Free( int idelay )
{ {
Assert( idelay >= 0 && idelay < MAXDLY ); Assert( idelay >= 0 && idelay < MAXDLY );
@@ -298,7 +303,7 @@ DLY_Init
Initialize dly Initialize dly
=========== ===========
*/ */
static int DLY_Init( int idelay, float delay ) int DLY_Init( int idelay, float delay )
{ {
dly_t *cur; dly_t *cur;
@@ -334,7 +339,7 @@ DLY_MovePointer
Checks overflow and moves pointer Checks overflow and moves pointer
============ ============
*/ */
static void DLY_MovePointer( dly_t *dly ) _inline void DLY_MovePointer( dly_t *dly )
{ {
if( ++dly->idelayinput >= dly->cdelaysamplesmax ) if( ++dly->idelayinput >= dly->cdelaysamplesmax )
dly->idelayinput = 0; dly->idelayinput = 0;
@@ -350,12 +355,12 @@ DLY_CheckNewStereoDelayVal
Update stereo processor settings if we are in new room Update stereo processor settings if we are in new room
============= =============
*/ */
static void DLY_CheckNewStereoDelayVal( void ) void DLY_CheckNewStereoDelayVal( void )
{ {
dly_t *const dly = &rgsxdly[STEREODLY]; dly_t *const dly = &rgsxdly[STEREODLY];
float delay = sxste_delay.value; float delay = sxste_delay->value;
if( !FBitSet( sxste_delay.flags, FCVAR_CHANGED )) if( !FBitSet( sxste_delay->flags, FCVAR_CHANGED ))
return; return;
if( delay == 0 ) if( delay == 0 )
@@ -398,7 +403,7 @@ DLY_DoStereoDelay
Do stereo processing Do stereo processing
============= =============
*/ */
static void DLY_DoStereoDelay( int count ) void DLY_DoStereoDelay( int count )
{ {
int delay, samplexf; int delay, samplexf;
dly_t *const dly = &rgsxdly[STEREODLY]; dly_t *const dly = &rgsxdly[STEREODLY];
@@ -463,12 +468,12 @@ DLY_CheckNewDelayVal
Update delay processor settings if we are in new room Update delay processor settings if we are in new room
============= =============
*/ */
static void DLY_CheckNewDelayVal( void ) void DLY_CheckNewDelayVal( void )
{ {
float delay = sxdly_delay.value; float delay = sxdly_delay->value;
dly_t *const dly = &rgsxdly[MONODLY]; dly_t *const dly = &rgsxdly[MONODLY];
if( FBitSet( sxdly_delay.flags, FCVAR_CHANGED )) if( FBitSet( sxdly_delay->flags, FCVAR_CHANGED ))
{ {
if( delay == 0 ) if( delay == 0 )
{ {
@@ -498,8 +503,8 @@ static void DLY_CheckNewDelayVal( void )
} }
} }
dly->lp = sxdly_lp.value; dly->lp = sxdly_lp->value;
dly->delayfeedback = 255 * sxdly_feedback.value; dly->delayfeedback = 255 * sxdly_feedback->value;
} }
/* /*
@@ -509,7 +514,7 @@ DLY_DoDelay
Do delay processing Do delay processing
============= =============
*/ */
static void DLY_DoDelay( int count ) void DLY_DoDelay( int count )
{ {
dly_t *const dly = &rgsxdly[MONODLY]; dly_t *const dly = &rgsxdly[MONODLY];
portable_samplepair_t *paint = paintto; portable_samplepair_t *paint = paintto;
@@ -560,7 +565,7 @@ RVB_SetUpDly
Set up dly for reverb Set up dly for reverb
=========== ===========
*/ */
static void RVB_SetUpDly( int pos, float delay, int kmod ) void RVB_SetUpDly( int pos, float delay, int kmod )
{ {
int samples; int samples;
@@ -596,13 +601,13 @@ RVB_CheckNewReverbVal
Update reverb settings if we are in new room Update reverb settings if we are in new room
=========== ===========
*/ */
static void RVB_CheckNewReverbVal( void ) void RVB_CheckNewReverbVal( void )
{ {
dly_t *const dly1 = &rgsxdly[REVERBPOS]; dly_t *const dly1 = &rgsxdly[REVERBPOS];
dly_t *const dly2 = &rgsxdly[REVERBPOS + 1]; dly_t *const dly2 = &rgsxdly[REVERBPOS + 1];
float delay = sxrvb_size.value; float delay = sxrvb_size->value;
if( FBitSet( sxrvb_size.flags, FCVAR_CHANGED )) if( FBitSet( sxrvb_size->flags, FCVAR_CHANGED ))
{ {
if( delay == 0.0f ) if( delay == 0.0f )
{ {
@@ -611,13 +616,13 @@ static void RVB_CheckNewReverbVal( void )
} }
else else
{ {
RVB_SetUpDly( REVERBPOS, sxrvb_size.value, 500 ); RVB_SetUpDly( REVERBPOS, sxrvb_size->value, 500 );
RVB_SetUpDly( REVERBPOS+1, sxrvb_size.value * 0.71f, 700 ); RVB_SetUpDly( REVERBPOS+1, sxrvb_size->value * 0.71f, 700 );
} }
} }
dly1->lp = dly2->lp = sxrvb_lp.value; dly1->lp = dly2->lp = sxrvb_lp->value;
dly1->delayfeedback = dly2->delayfeedback = (int)(255 * sxrvb_feedback.value); dly1->delayfeedback = dly2->delayfeedback = (int)(255 * sxrvb_feedback->value);
} }
/* /*
@@ -627,7 +632,7 @@ RVB_DoReverbForOneDly
Do reverberation for one dly Do reverberation for one dly
=========== ===========
*/ */
static int RVB_DoReverbForOneDly( dly_t *dly, const int vlr, const portable_samplepair_t *samplepair ) int RVB_DoReverbForOneDly( dly_t *dly, const int vlr, const portable_samplepair_t *samplepair )
{ {
int delay; int delay;
int samplexf; int samplexf;
@@ -701,7 +706,7 @@ RVB_DoReverb
Do reverberation processing Do reverberation processing
=========== ===========
*/ */
static void RVB_DoReverb( int count ) void RVB_DoReverb( int count )
{ {
dly_t *const dly1 = &rgsxdly[REVERBPOS]; dly_t *const dly1 = &rgsxdly[REVERBPOS];
dly_t *const dly2 = &rgsxdly[REVERBPOS+1]; dly_t *const dly2 = &rgsxdly[REVERBPOS+1];
@@ -718,7 +723,7 @@ static void RVB_DoReverb( int count )
voutm = RVB_DoReverbForOneDly( dly1, vlr, paint ); voutm = RVB_DoReverbForOneDly( dly1, vlr, paint );
voutm += RVB_DoReverbForOneDly( dly2, vlr, paint ); voutm += RVB_DoReverbForOneDly( dly2, vlr, paint );
if( dsp_coeff_table.value == 1.0f ) if( dsp_coeff_table->value == 1.0f )
voutm /= 6; // alpha voutm /= 6; // alpha
else voutm = (11 * voutm) >> 6; else voutm = (11 * voutm) >> 6;
@@ -734,18 +739,18 @@ RVB_DoAMod
Do amplification modulation processing Do amplification modulation processing
=========== ===========
*/ */
static void RVB_DoAMod( int count ) void RVB_DoAMod( int count )
{ {
portable_samplepair_t *paint = paintto; portable_samplepair_t *paint = paintto;
if( !sxmod_lowpass.value && !sxmod_mod.value ) if( !sxmod_lowpass->value && !sxmod_mod->value )
return; return;
for( ; count; count--, paint++ ) for( ; count; count--, paint++ )
{ {
portable_samplepair_t res = *paint; portable_samplepair_t res = *paint;
if( sxmod_lowpass.value ) if( sxmod_lowpass->value )
{ {
res.left = rgsxlp[0] + rgsxlp[1] + rgsxlp[2] + rgsxlp[3] + rgsxlp[4] + res.left; res.left = rgsxlp[0] + rgsxlp[1] + rgsxlp[2] + rgsxlp[3] + rgsxlp[4] + res.left;
res.right = rgsxlp[5] + rgsxlp[6] + rgsxlp[7] + rgsxlp[8] + rgsxlp[9] + res.right; res.right = rgsxlp[5] + rgsxlp[6] + rgsxlp[7] + rgsxlp[8] + rgsxlp[9] + res.right;
@@ -767,7 +772,7 @@ static void RVB_DoAMod( int count )
rgsxlp[8] = rgsxlp[9]; rgsxlp[8] = rgsxlp[9];
} }
if( sxmod_mod.value ) if( sxmod_mod->value )
{ {
if( --sxmod1cur < 0 ) if( --sxmod1cur < 0 )
sxmod1cur = sxmod1; sxmod1cur = sxmod1;
@@ -807,9 +812,13 @@ DSP_Process
(xash dsp interface) (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 || !sampleCount ) if( dsp_off->value )
return;
// don't process DSP while in menu
if( cls.key_dest == key_menu || !sampleCount )
return; return;
// preset is already installed by CheckNewDspPresets // preset is already installed by CheckNewDspPresets
@@ -830,7 +839,7 @@ DSP_ClearState
*/ */
void DSP_ClearState( void ) void DSP_ClearState( void )
{ {
Cvar_DirectSet( &room_type, "0" ); Cvar_SetValue( "room_type", 0.0f );
SX_ReloadRoomFX(); SX_ReloadRoomFX();
} }
@@ -843,12 +852,12 @@ CheckNewDspPresets
*/ */
void CheckNewDspPresets( void ) void CheckNewDspPresets( void )
{ {
if( dsp_off.value != 0.0f ) if( dsp_off->value != 0.0f )
return; return;
if( FBitSet( dsp_coeff_table.flags, FCVAR_CHANGED )) if( FBitSet( dsp_coeff_table->flags, FCVAR_CHANGED ))
{ {
switch( (int)dsp_coeff_table.value ) switch( (int)dsp_coeff_table->value )
{ {
case 0: // release case 0: // release
ptable = rgsxpre; ptable = rgsxpre;
@@ -864,20 +873,20 @@ void CheckNewDspPresets( void )
SX_ReloadRoomFX(); SX_ReloadRoomFX();
room_typeprev = -1; room_typeprev = -1;
ClearBits( dsp_coeff_table.flags, FCVAR_CHANGED ); ClearBits( dsp_coeff_table->flags, FCVAR_CHANGED );
} }
if( s_listener.waterlevel > 2 ) if( s_listener.waterlevel > 2 )
idsp_room = roomwater_type.value; idsp_room = roomwater_type->value;
else idsp_room = room_type.value; else idsp_room = room_type->value;
// don't pass invalid presets // don't pass invalid presets
idsp_room = bound( 0, idsp_room, MAX_ROOM_TYPES ); idsp_room = bound( 0, idsp_room, MAX_ROOM_TYPES );
if( FBitSet( hisound.flags, FCVAR_CHANGED )) if( FBitSet( hisound->flags, FCVAR_CHANGED ))
{ {
sxhires = hisound.value; sxhires = hisound->value;
ClearBits( hisound.flags, FCVAR_CHANGED ); ClearBits( hisound->flags, FCVAR_CHANGED );
} }
if( idsp_room == room_typeprev && idsp_room == 0 ) if( idsp_room == room_typeprev && idsp_room == 0 )
@@ -889,15 +898,15 @@ void CheckNewDspPresets( void )
cur = ptable + idsp_room; cur = ptable + idsp_room;
Cvar_DirectSetValue( &sxmod_lowpass, cur->room_lp ); Cvar_SetValue( "room_lp", cur->room_lp );
Cvar_DirectSetValue( &sxmod_mod, cur->room_mod ); Cvar_SetValue( "room_mod", cur->room_mod );
Cvar_DirectSetValue( &sxrvb_size, cur->room_size ); Cvar_SetValue( "room_size", cur->room_size );
Cvar_DirectSetValue( &sxrvb_feedback, cur->room_refl ); Cvar_SetValue( "room_refl", cur->room_refl );
Cvar_DirectSetValue( &sxrvb_lp, cur->room_rvblp ); Cvar_SetValue( "room_rvblp", cur->room_rvblp );
Cvar_DirectSetValue( &sxdly_delay, cur->room_delay ); Cvar_SetValue( "room_delay", cur->room_delay );
Cvar_DirectSetValue( &sxdly_feedback, cur->room_feedback ); Cvar_SetValue( "room_feedback", cur->room_feedback );
Cvar_DirectSetValue( &sxdly_lp, cur->room_dlylp ); Cvar_SetValue( "room_dlylp", cur->room_dlylp );
Cvar_DirectSetValue( &sxste_delay, cur->room_left ); Cvar_SetValue( "room_left", cur->room_left );
} }
room_typeprev = idsp_room; room_typeprev = idsp_room;
@@ -906,15 +915,15 @@ void CheckNewDspPresets( void )
DLY_CheckNewDelayVal( ); DLY_CheckNewDelayVal( );
DLY_CheckNewStereoDelayVal(); DLY_CheckNewStereoDelayVal();
ClearBits( sxrvb_size.flags, FCVAR_CHANGED ); ClearBits( sxrvb_size->flags, FCVAR_CHANGED );
ClearBits( sxdly_delay.flags, FCVAR_CHANGED ); ClearBits( sxdly_delay->flags, FCVAR_CHANGED );
ClearBits( sxste_delay.flags, FCVAR_CHANGED ); ClearBits( sxste_delay->flags, FCVAR_CHANGED );
} }
static void SX_Profiling_f( void ) void SX_Profiling_f( void )
{ {
portable_samplepair_t testbuffer[512]; portable_samplepair_t testbuffer[512];
float oldroom = room_type.value; float oldroom = room_type->value;
double start, end; double start, end;
int i, calls; int i, calls;
@@ -926,7 +935,7 @@ static void SX_Profiling_f( void )
if( Cmd_Argc() > 1 ) if( Cmd_Argc() > 1 )
{ {
Cvar_DirectSetValue( &room_type, Q_atof( Cmd_Argv( 1 ))); Cvar_SetValue( "room_type", Q_atof( Cmd_Argv( 1 )));
SX_ReloadRoomFX(); SX_ReloadRoomFX();
CheckNewDspPresets(); // we just need idsp_room immediately, for message below CheckNewDspPresets(); // we just need idsp_room immediately, for message below
} }
@@ -936,7 +945,7 @@ static void SX_Profiling_f( void )
start = Sys_DoubleTime(); start = Sys_DoubleTime();
for( calls = 10000; calls; calls-- ) for( calls = 10000; calls; calls-- )
{ {
DSP_Process( testbuffer, 512 ); DSP_Process( idsp_room, testbuffer, 512 );
} }
end = Sys_DoubleTime(); end = Sys_DoubleTime();
@@ -944,7 +953,7 @@ static void SX_Profiling_f( void )
if( Cmd_Argc() > 1 ) if( Cmd_Argc() > 1 )
{ {
Cvar_DirectSetValue( &room_type, oldroom ); Cvar_SetValue( "room_type", oldroom );
SX_ReloadRoomFX(); SX_ReloadRoomFX();
CheckNewDspPresets(); CheckNewDspPresets();
} }

View File

@@ -91,7 +91,7 @@ void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime
S_IsClient S_IsClient
================= =================
*/ */
static qboolean S_IsClient( int entnum ) qboolean S_IsClient( int entnum )
{ {
return ( entnum == s_listener.entnum ); return ( entnum == s_listener.entnum );
} }
@@ -124,7 +124,7 @@ void S_FreeChannel( channel_t *ch )
S_UpdateSoundFade S_UpdateSoundFade
================= =================
*/ */
static void S_UpdateSoundFade( void ) void S_UpdateSoundFade( void )
{ {
float f, totaltime, elapsed; float f, totaltime, elapsed;
@@ -184,7 +184,7 @@ override any other sound playing on the same channel (see code comments below fo
exceptions). exceptions).
================= =================
*/ */
static qboolean SND_FStreamIsPlaying( sfx_t *sfx ) qboolean SND_FStreamIsPlaying( sfx_t *sfx )
{ {
int ch_idx; int ch_idx;
@@ -399,7 +399,7 @@ returns TRUE if sound was altered,
returns FALSE if sound was not found (sound is not playing) 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; channel_t *ch;
int i; int i;
@@ -457,7 +457,7 @@ static int S_AlterChannel( int entnum, int channel, sfx_t *sfx, int vol, int pit
S_SpatializeChannel 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; float lscale, rscale, scale;
@@ -480,7 +480,7 @@ static void S_SpatializeChannel( int *left_vol, int *right_vol, int master_vol,
SND_Spatialize SND_Spatialize
================= =================
*/ */
static void SND_Spatialize( channel_t *ch ) void SND_Spatialize( channel_t *ch )
{ {
vec3_t source_vec; vec3_t source_vec;
float dist, dot, gain = 1.0f; float dist, dot, gain = 1.0f;
@@ -648,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 // Init client entity mouth movement vars
SND_InitMouth( ent, chan ); 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;
}
}
} }
/* /*
@@ -953,7 +967,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
S_InitAmbientChannels S_InitAmbientChannels
=================== ===================
*/ */
static void S_InitAmbientChannels( void ) void S_InitAmbientChannels( void )
{ {
int ambient_channel; int ambient_channel;
channel_t *chan; channel_t *chan;
@@ -975,7 +989,7 @@ static void S_InitAmbientChannels( void )
S_UpdateAmbientSounds S_UpdateAmbientSounds
=================== ===================
*/ */
static void S_UpdateAmbientSounds( void ) void S_UpdateAmbientSounds( void )
{ {
mleaf_t *leaf; mleaf_t *leaf;
float vol; float vol;
@@ -1407,7 +1421,7 @@ static void S_FreeRawChannels( void )
S_ClearBuffer S_ClearBuffer
================== ==================
*/ */
static void S_ClearBuffer( void ) void S_ClearBuffer( void )
{ {
S_ClearRawChannels(); S_ClearRawChannels();
@@ -1506,7 +1520,7 @@ static int S_GetSoundtime( void )
} }
//============================================================================= //=============================================================================
static void S_UpdateChannels( void ) void S_UpdateChannels( void )
{ {
uint endtime; uint endtime;
int samps; int samps;
@@ -1695,7 +1709,7 @@ console functions
=============================================================================== ===============================================================================
*/ */
static void S_Play_f( void ) void S_Play_f( void )
{ {
if( Cmd_Argc() == 1 ) if( Cmd_Argc() == 1 )
{ {
@@ -1706,7 +1720,7 @@ static void S_Play_f( void )
S_StartLocalSound( Cmd_Argv( 1 ), VOL_NORM, false ); S_StartLocalSound( Cmd_Argv( 1 ), VOL_NORM, false );
} }
static void S_Play2_f( void ) void S_Play2_f( void )
{ {
int i = 1; int i = 1;
@@ -1723,7 +1737,7 @@ static void S_Play2_f( void )
} }
} }
static void S_PlayVol_f( void ) void S_PlayVol_f( void )
{ {
if( Cmd_Argc() == 1 ) if( Cmd_Argc() == 1 )
{ {
@@ -1749,7 +1763,7 @@ static void S_Say( const char *name, qboolean reliable )
S_StartLocalSound( sentence, 1.0f, reliable ); S_StartLocalSound( sentence, 1.0f, reliable );
} }
static void S_Say_f( void ) void S_Say_f( void )
{ {
if( Cmd_Argc() == 1 ) if( Cmd_Argc() == 1 )
{ {
@@ -1760,7 +1774,7 @@ static void S_Say_f( void )
S_Say( Cmd_Argv( 1 ), false ); S_Say( Cmd_Argv( 1 ), false );
} }
static void S_SayReliable_f( void ) void S_SayReliable_f( void )
{ {
if( Cmd_Argc() == 1 ) if( Cmd_Argc() == 1 )
{ {
@@ -1776,7 +1790,7 @@ static void S_SayReliable_f( void )
S_Music_f S_Music_f
================= =================
*/ */
static void S_Music_f( void ) void S_Music_f( void )
{ {
int c = Cmd_Argc(); int c = Cmd_Argc();
@@ -1840,7 +1854,7 @@ static void S_Music_f( void )
S_StopSound_f S_StopSound_f
================= =================
*/ */
static void S_StopSound_f( void ) void S_StopSound_f( void )
{ {
S_StopAllSounds( true ); S_StopAllSounds( true );
} }
@@ -1850,7 +1864,7 @@ static void S_StopSound_f( void )
S_SoundFade_f S_SoundFade_f
================= =================
*/ */
static void S_SoundFade_f( void ) void S_SoundFade_f( void )
{ {
int c = Cmd_Argc(); int c = Cmd_Argc();
float fadeTime = 5.0f; float fadeTime = 5.0f;
@@ -1884,7 +1898,7 @@ void S_SoundInfo_f( void )
S_VoiceRecordStart_f S_VoiceRecordStart_f
================= =================
*/ */
static void S_VoiceRecordStart_f( void ) void S_VoiceRecordStart_f( void )
{ {
if( cls.state != ca_active || cls.legacymode ) if( cls.state != ca_active || cls.legacymode )
return; return;
@@ -1897,7 +1911,7 @@ static void S_VoiceRecordStart_f( void )
S_VoiceRecordStop_f S_VoiceRecordStop_f
================= =================
*/ */
static void S_VoiceRecordStop_f( void ) void S_VoiceRecordStop_f( void )
{ {
if( cls.state != ca_active || !Voice_IsRecording() ) if( cls.state != ca_active || !Voice_IsRecording() )
return; return;

View File

@@ -58,7 +58,7 @@ S_TransferPaintBuffer
=================== ===================
*/ */
static void S_TransferPaintBuffer( int endtime ) void S_TransferPaintBuffer( int endtime )
{ {
int *snd_p, snd_linear_count; int *snd_p, snd_linear_count;
int lpos, lpaintedtime; int lpos, lpaintedtime;
@@ -201,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 *lscale, *rscale;
int i, data; int i, data;
@@ -217,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; int *lscale, *rscale;
uint left, right; uint left, right;
@@ -237,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 left, right;
int i, data; int i, data;
@@ -252,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; uint *data;
int left, right; int left, right;
@@ -273,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; int i, sampleIndex = 0;
uint sampleFrac = inputOffset; uint sampleFrac = inputOffset;
@@ -309,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; int i, sampleIndex = 0;
uint sampleFrac = inputOffset; uint sampleFrac = inputOffset;
@@ -335,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; int i, sampleIndex = 0;
uint sampleFrac = inputOffset; uint sampleFrac = inputOffset;
@@ -357,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; int i, sampleIndex = 0;
uint sampleFrac = inputOffset; uint sampleFrac = inputOffset;
@@ -379,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]; int pvol[CCHANVOLUMES];
paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr(); paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr();
@@ -496,7 +496,7 @@ int S_MixDataToDevice( channel_t *pChannel, int sampleCount, int outRate, int ou
return outOffset - startingOffset; return outOffset - startingOffset;
} }
static qboolean S_ShouldContinueMixing( channel_t *ch ) qboolean S_ShouldContinueMixing( channel_t *ch )
{ {
if( ch->isSentence ) if( ch->isSentence )
{ {
@@ -517,7 +517,7 @@ static qboolean S_ShouldContinueMixing( channel_t *ch )
// this routine will fill the paintbuffer to endtime. Otherwise, fewer samples are mixed. // this routine will fill the paintbuffer to endtime. Otherwise, fewer samples are mixed.
// if( endtime - paintedtime ) is not aligned on boundaries of 4, // if( endtime - paintedtime ) is not aligned on boundaries of 4,
// we'll miss data if outputRate < SOUND_DMA_SPEED! // 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; channel_t *ch;
wavdata_t *pSource; wavdata_t *pSource;
@@ -647,7 +647,7 @@ _inline portable_samplepair_t *S_GetNextpFilter( int i, portable_samplepair_t *p
// if NULL then perform no filtering. // if NULL then perform no filtering.
// count: how many samples to upsample. will become count*2 samples in buffer, in place. // 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. // implement cubic interpolation on 2x upsampled buffer. Effectively delays buffer contents by 2 samples.
@@ -740,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 // prevfilter: filter memory. NOTE: this must match the filtertype ie: filterlinear[] for FILTERTYPE_LINEAR
// if NULL then perform no filtering. // if NULL then perform no filtering.
// count: how many samples to upsample. will become count*2 samples in buffer, in place. // 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; int i, upCount = count<<1;
@@ -769,7 +769,7 @@ static void S_Interpolate2xLinear( portable_samplepair_t *pbuffer, portable_samp
// if NULL then perform no filtering. // if NULL then perform no filtering.
// cfltmem: max number of sample pairs filter can use // cfltmem: max number of sample pairs filter can use
// filtertype: FILTERTYPE_NONE, _LINEAR, _CUBIC etc. Must match prevfilter. // 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 upCount = count<<1;
int i, j; int i, j;
@@ -822,7 +822,7 @@ void MIX_ClearAllPaintBuffers( int SampleCount, qboolean clearFilters )
// mixes pbuf1 + pbuf2 into pbuf3, count samples // mixes pbuf1 + pbuf2 into pbuf3, count samples
// fgain is output gain 0-1.0 // fgain is output gain 0-1.0
// NOTE: pbuf3 may equal pbuf1 or pbuf2! // 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; portable_samplepair_t *pbuf1, *pbuf2, *pbuf3;
int i, gain; int i, gain;
@@ -855,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; portable_samplepair_t *pbuf;
paintbuffer_t *ppaint; paintbuffer_t *ppaint;
@@ -871,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(); paintbuffer_t *ppaint = MIX_GetCurrentPaintbufferPtr();
int ifilter = ppaint->ifilter; int ifilter = ppaint->ifilter;
@@ -884,7 +884,7 @@ static void S_MixUpsample( int sampleCount, int filtertype )
ppaint->ifilter++; ppaint->ifilter++;
} }
static void MIX_MixRawSamplesBuffer( int end ) void MIX_MixRawSamplesBuffer( int end )
{ {
portable_samplepair_t *pbuf, *roombuf, *streambuf; portable_samplepair_t *pbuf, *roombuf, *streambuf;
uint i, j, stop; uint i, j, stop;
@@ -928,7 +928,7 @@ static void MIX_MixRawSamplesBuffer( int end )
// IROOMBUFFER, IFACINGBUFFER, IFACINGAWAY // IROOMBUFFER, IFACINGBUFFER, IFACINGAWAY
// dsp fx are then applied to these buffers by the caller. // dsp fx are then applied to these buffers by the caller.
// caller also remixes all into final IPAINTBUFFER output. // 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 // 11khz sounds are mixed into 3 buffers based on distance from listener, and facing direction
// These buffers are facing, facingaway, room // These buffers are facing, facingaway, room
@@ -999,8 +999,7 @@ void MIX_PaintChannels( int endtime )
MIX_UpsampleAllPaintbuffers( end, count ); MIX_UpsampleAllPaintbuffers( end, count );
// process all sounds with DSP // process all sounds with DSP
if( cls.key_dest != key_menu ) DSP_Process( idsp_room, MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
DSP_Process( MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
// add music or soundtrack from movie (no dsp) // add music or soundtrack from movie (no dsp)
MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() ); MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() );

View File

@@ -96,7 +96,6 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int
// open stream // open stream
s_bgTrack.stream = FS_OpenStream( introTrack ); s_bgTrack.stream = FS_OpenStream( introTrack );
Q_strncpy( s_bgTrack.current, introTrack, sizeof( s_bgTrack.current )); Q_strncpy( s_bgTrack.current, introTrack, sizeof( s_bgTrack.current ));
memset( &musicfade, 0, sizeof( musicfade )); // clear any soundfade memset( &musicfade, 0, sizeof( musicfade )); // clear any soundfade
s_bgTrack.source = cls.key_dest; s_bgTrack.source = cls.key_dest;

View File

@@ -16,6 +16,204 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "sound.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 // Purpose: wrap the position wrt looping
// Input : samplePosition - absolute position // Input : samplePosition - absolute position
@@ -81,3 +279,28 @@ int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int s
return sampleCount; 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;
}

View File

@@ -16,128 +16,13 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "sound.h" #include "sound.h"
#include "const.h" #include "const.h"
#include "sequence.h"
#include <ctype.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 int cszrawsentences = 0;
static char *rgpszrawsentence[CVOXFILESENTENCEMAX]; static char *rgpszrawsentence[CVOXFILESENTENCEMAX];
static const char *voxperiod = "_period", *voxcomma = "_comma"; 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 // return number of samples mixed
int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset ) int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset )
{ {
@@ -194,7 +79,11 @@ void VOX_LoadWord( channel_t *ch )
if( end <= start ) end = 0; 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 ) void VOX_FreeWord( channel_t *ch )
@@ -276,12 +165,25 @@ static const char *VOX_LookupString( const char *pszin )
int i = -1, len; int i = -1, len;
const char *c; const char *c;
// check if we are an immediate sentence // check if we are a CSCZ or immediate sentence
if( *pszin == '#' ) if( *pszin == '#' )
{
// Q_atoi is too smart and allows negative values
// so check with Q_isdigit beforehand
if( Q_isdigit( pszin + 1 ))
{
sentenceEntry_s *sentenceEntry;
i = Q_atoi( pszin + 1 );
if(( sentenceEntry = Sequence_GetSentenceByIndex( i )))
return sentenceEntry->data;
return NULL;
}
else
{ {
// immediate sentence, probably coming from "speak" command // immediate sentence, probably coming from "speak" command
return pszin + 1; return pszin + 1;
} }
}
// check if we received an index // check if we received an index
if( Q_isdigit( pszin )) if( Q_isdigit( pszin ))

View File

@@ -219,6 +219,7 @@ extern dma_t dma;
extern convar_t s_musicvolume; extern convar_t s_musicvolume;
extern convar_t s_lerping; extern convar_t s_lerping;
extern convar_t *dsp_off;
extern convar_t s_test; // cvar to testify new effects extern convar_t s_test; // cvar to testify new effects
extern convar_t s_samplecount; extern convar_t s_samplecount;
extern convar_t snd_mute_losefocus; extern convar_t snd_mute_losefocus;
@@ -255,7 +256,8 @@ void S_InitSounds( void );
void SX_Init( void ); void SX_Init( void );
void SX_Free( void ); void SX_Free( void );
void CheckNewDspPresets( 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 ); void DSP_ClearState( void );
qboolean S_Init( void ); qboolean S_Init( void );
@@ -304,6 +306,8 @@ int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample );
int S_ZeroCrossingBefore( 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_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean use_loop );
int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount, 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 // s_vox.c

View File

@@ -35,7 +35,7 @@ static qboolean GAME_EXPORT VGUI_IsInGame( void );
static struct static struct
{ {
qboolean initialized; qboolean initialized;
vguiapi_t dllFuncs; vgui_support_interface_t dllFuncs;
VGUI_DefaultCursor cursor; VGUI_DefaultCursor cursor;
HINSTANCE hInstance; HINSTANCE hInstance;
@@ -44,32 +44,7 @@ static struct
} vgui = } vgui =
{ {
false, false,
{ { 0 }, // not initialized yet
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 -1
}; };
@@ -117,7 +92,37 @@ qboolean VGui_IsActive( void )
return vgui.initialized; return vgui.initialized;
} }
static void VGui_FillAPIFromRef( vguiapi_t *to, const ref_interface_t *from ) static vgui_support_api_t gEngfuncs =
{
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,
COM_LoadLibrary,
COM_FreeLibrary,
COM_GetProcAddress,
};
static void VGui_FillAPIFromRef( vgui_support_api_t *to, const ref_interface_t *from )
{ {
to->DrawInit = from->VGUI_DrawInit; to->DrawInit = from->VGUI_DrawInit;
to->DrawShutdown = from->VGUI_DrawShutdown; to->DrawShutdown = from->VGUI_DrawShutdown;
@@ -139,15 +144,11 @@ void VGui_RegisterCvars( void )
Cvar_RegisterVariable( &vgui_utf8 ); Cvar_RegisterVariable( &vgui_utf8 );
} }
qboolean VGui_LoadProgs( HINSTANCE hInstance ) static HINSTANCE VGui_LoadSupportLibrary( void )
{ {
void (*F)( vguiapi_t* ); string vguiloader;
qboolean client = hInstance != NULL; string vguilib;
HINSTANCE hInstance;
// not loading interface from client.dll, load vgui_support.dll instead
if( !client )
{
string vguiloader, vguilib;
// HACKHACK: try to load path from custom path // HACKHACK: try to load path from custom path
// to support having different versions of VGUI // to support having different versions of VGUI
@@ -161,35 +162,127 @@ qboolean VGui_LoadProgs( HINSTANCE hInstance )
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, sizeof( vguiloader )); Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, sizeof( vguiloader ));
} }
hInstance = vgui.hInstance = COM_LoadLibrary( vguiloader, false, false ); hInstance = COM_LoadLibrary( vguiloader, false, false );
if( !vgui.hInstance ) if( !hInstance )
{ {
if( FS_FileExists( vguiloader, false )) if( FS_FileExists( vguiloader, false ))
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() ); Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
else Con_Reportf( "vgui_support: not found\n" ); else Con_Reportf( "vgui_support: not found\n" );
return false;
}
} }
// try legacy API first return hInstance;
F = COM_GetProcAddress( hInstance, client ? "InitVGUISupportAPI" : "InitAPI" ); }
if( F ) static qboolean VGui_ProbeNewAPI( HINSTANCE hInstance,
vgui_support_interface_t *iface, const vgui_support_api_t *api )
{ {
VGui_FillAPIFromRef( &vgui.dllFuncs, &ref.dllFuncs ); const int version = VGUI_SUPPORT_API_VERSION;
F( &vgui.dllFuncs ); static vgui_support_api_t localapi;
VGUISUPPORTAPI F;
F = COM_GetProcAddress( hInstance, GET_VGUI_SUPPORT_API );
if( !F )
return false;
// keep local temporary copy, do not let vgui_support to mess up here
memcpy( &localapi, api, sizeof( localapi ));
if( F( version, iface, &localapi ) != version )
return false;
Con_Reportf( "vgui_support: initialized new API\n" );
return true;
}
static qboolean VGui_ProbeOldAPI( HINSTANCE hInstance,
vgui_support_interface_t *iface, const vgui_support_api_t *api,
qboolean client )
{
static legacy_vguiapi_t localapi;
LEGACY_VGUISUPPORTAPI F;
F = COM_GetProcAddress( hInstance, client ? LEGACY_CLIENT_GET_VGUI_SUPPORT_API : LEGACY_GET_VGUI_SUPPORT_API );
if( !F )
return false;
memset( &localapi, 0, sizeof( localapi ));
localapi.DrawInit = api->DrawInit;
localapi.DrawShutdown = api->DrawShutdown;
localapi.SetupDrawingText = api->SetupDrawingText;
localapi.SetupDrawingRect = api->SetupDrawingRect;
localapi.SetupDrawingImage = api->SetupDrawingImage;
localapi.BindTexture = api->BindTexture;
localapi.EnableTexture = api->EnableTexture;
localapi.CreateTexture = api->CreateTexture;
localapi.UploadTexture = api->UploadTexture;
localapi.UploadTextureBlock = api->UploadTextureBlock;
localapi.DrawQuad = api->DrawQuad;
localapi.GetTextureSizes = api->GetTextureSizes;
localapi.GenerateTexture = api->GenerateTexture;
localapi.EngineMalloc = api->EngineMalloc;
localapi.CursorSelect = api->CursorSelect;
localapi.GetColor = api->GetColor;
localapi.IsInGame = api->IsInGame;
localapi.EnableTextInput = api->EnableTextInput;
localapi.GetCursorPos = api->GetCursorPos;
localapi.ProcessUtfChar = api->ProcessUtfChar;
localapi.GetClipboardText = api->GetClipboardText;
localapi.SetClipboardText = api->SetClipboardText;
localapi.GetKeyModifiers = api->GetKeyModifiers;
F( &localapi );
localapi.initialized = true;
iface->Startup = localapi.Startup;
iface->Shutdown = localapi.Shutdown;
iface->GetPanel = localapi.GetPanel;
iface->Paint = localapi.Paint;
iface->Mouse = localapi.Mouse;
iface->Key = localapi.Key;
iface->MouseMove = localapi.MouseMove;
iface->TextInput = localapi.TextInput;
vgui.initialized = vgui.dllFuncs.initialized = true;
Con_Reportf( "vgui_support: initialized legacy API in %s module\n", client ? "client" : "support" ); Con_Reportf( "vgui_support: initialized legacy API in %s module\n", client ? "client" : "support" );
return true; return true;
} }
qboolean VGui_LoadProgs( HINSTANCE hInstance )
{
LEGACY_VGUISUPPORTAPI F;
qboolean client = hInstance != NULL;
// not loading interface from client.dll, load vgui_support.dll instead
if( !client )
{
hInstance = vgui.hInstance = VGui_LoadSupportLibrary();
if( !hInstance )
return false;
}
// prepare api funcs
VGui_FillAPIFromRef( &gEngfuncs, &ref.dllFuncs );
// try new API first
if( !VGui_ProbeNewAPI( vgui.hInstance, &vgui.dllFuncs, &gEngfuncs ))
{
// try legacy API next
if( !VGui_ProbeOldAPI( vgui.hInstance, &vgui.dllFuncs, &gEngfuncs, client ))
{
Con_Reportf( S_ERROR "Failed to find VGUI support API entry point in %s module\n", client ? "client" : "support" ); Con_Reportf( S_ERROR "Failed to find VGUI support API entry point in %s module\n", client ? "client" : "support" );
return false; return false;
} }
}
vgui.initialized = true;
return true;
}
/* /*
================ ================
@@ -197,7 +290,7 @@ VGui_Startup
================ ================
*/ */
void VGui_Startup( int width, int height ) void VGui_Startup( HINSTANCE clientInstance, int width, int height )
{ {
// vgui not initialized from both support and client modules, skip // vgui not initialized from both support and client modules, skip
if( !vgui.initialized ) if( !vgui.initialized )
@@ -212,11 +305,17 @@ void VGui_Startup( int width, int height )
else if( width <= 1280 ) width = 1280; else if( width <= 1280 ) width = 1280;
else if( width <= 1600 ) width = 1600; else if( width <= 1600 ) width = 1600;
if( !clientInstance )
{
if( vgui.dllFuncs.Startup ) if( vgui.dllFuncs.Startup )
vgui.dllFuncs.Startup( width, height ); vgui.dllFuncs.Startup( width, height );
} }
else
{
if( vgui.dllFuncs.ClientStartup )
vgui.dllFuncs.ClientStartup( clientInstance, width, height );
}
}
/* /*
================ ================

View File

@@ -21,7 +21,7 @@ GNU General Public License for more details.
// //
void VGui_RegisterCvars( void ); void VGui_RegisterCvars( void );
qboolean VGui_LoadProgs( HINSTANCE hInstance ); qboolean VGui_LoadProgs( HINSTANCE hInstance );
void VGui_Startup( int width, int height ); void VGui_Startup( HINSTANCE clientInstance, int width, int height );
void VGui_Shutdown( void ); void VGui_Shutdown( void );
void VGui_Paint( void ); void VGui_Paint( void );
void VGui_RunFrame( void ); void VGui_RunFrame( void );

View File

@@ -20,20 +20,34 @@ GNU General Public License for more details.
#include "vid_common.h" #include "vid_common.h"
#include "platform/platform.h" #include "platform/platform.h"
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" ); #define WINDOW_NAME XASH_ENGINE_NAME " Window" // Half-Life
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" ); convar_t *vid_fullscreen;
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" ); convar_t *vid_mode;
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" ); convar_t *vid_brightness;
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" ); convar_t *vid_gamma;
convar_t *vid_highdpi;
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_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; glwstate_t glw_state;
convar_t *window_xpos;
convar_t *window_ypos;
convar_t *vid_rotate;
convar_t *vid_scale;
/*
=================
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 VID_InitDefaultResolution
@@ -52,7 +66,7 @@ void VID_InitDefaultResolution( void )
R_SaveVideoMode R_SaveVideoMode
================= =================
*/ */
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized ) void R_SaveVideoMode( int w, int h, int render_w, int render_h )
{ {
if( !w || !h || !render_w || !render_h ) if( !w || !h || !render_w || !render_h )
{ {
@@ -65,7 +79,6 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximiz
Cvar_SetValue( "width", w ); Cvar_SetValue( "width", w );
Cvar_SetValue( "height", h ); Cvar_SetValue( "height", h );
Cvar_DirectSet( &vid_maximized, maximized ? "1" : "0" );
// immediately drop changed state or we may trigger // immediately drop changed state or we may trigger
// video subsystem to reapply settings // video subsystem to reapply settings
@@ -111,11 +124,11 @@ check vid modes and fullscreen
*/ */
void VID_CheckChanges( void ) void VID_CheckChanges( void )
{ {
if( FBitSet( cl_allow_levelshots.flags, FCVAR_CHANGED )) if( FBitSet( cl_allow_levelshots->flags, FCVAR_CHANGED ))
{ {
//GL_FreeTexture( cls.loadingBar ); //GL_FreeTexture( cls.loadingBar );
SCR_RegisterTextures(); // reload 'lambda' image SCR_RegisterTextures(); // reload 'lambda' image
ClearBits( cl_allow_levelshots.flags, FCVAR_CHANGED ); ClearBits( cl_allow_levelshots->flags, FCVAR_CHANGED );
} }
if( host.renderinfo_changed ) if( host.renderinfo_changed )
@@ -132,36 +145,6 @@ void VID_CheckChanges( void )
} }
} }
/*
===============
VID_SetDisplayTransform
notify ref dll about screen transformations
===============
*/
void VID_SetDisplayTransform( int *render_w, int *render_h )
{
uint rotate = vid_rotate.value;
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale.value, vid_scale.value ))
{
if( rotate & 1 )
{
int swap = *render_w;
*render_w = *render_h;
*render_h = swap;
}
*render_h /= vid_scale.value;
*render_w /= vid_scale.value;
}
else
{
Con_Printf( S_WARN "failed to setup screen transform\n" );
}
}
static void VID_Mode_f( void ) static void VID_Mode_f( void )
{ {
int w, h; int w, h;
@@ -194,28 +177,29 @@ static void VID_Mode_f( void )
return; return;
} }
R_ChangeDisplaySettings( w, h, bound( 0, vid_fullscreen.value, WINDOW_MODE_COUNT - 1 )); R_ChangeDisplaySettings( w, h, Cvar_VariableInteger( "fullscreen" ) );
} }
void VID_Init( void ) void VID_Init( void )
{ {
// system screen width and height (don't suppose for change from console at all) // system screen width and height (don't suppose for change from console at all)
Cvar_RegisterVariable( &window_width ); Cvar_Get( "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
Cvar_RegisterVariable( &window_height ); Cvar_Get( "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
Cvar_RegisterVariable( &vid_mode ); window_xpos = Cvar_Get( "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
Cvar_RegisterVariable( &vid_highdpi ); window_ypos = Cvar_Get( "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );
Cvar_RegisterVariable( &vid_rotate );
Cvar_RegisterVariable( &vid_scale ); vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
Cvar_RegisterVariable( &vid_fullscreen ); vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
Cvar_RegisterVariable( &vid_maximized ); vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
Cvar_RegisterVariable( &window_xpos ); vid_mode = Cvar_Get( "vid_mode", "0", FCVAR_RENDERINFO, "current video mode index (used just for storage)" );
Cvar_RegisterVariable( &window_ypos ); vid_highdpi = Cvar_Get( "vid_highdpi", "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
vid_rotate = Cvar_Get( "vid_rotate", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
vid_scale = Cvar_Get( "vid_scale", "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
// a1ba: planned to be named vid_mode for compability // a1ba: planned to be named vid_mode for compability
// but supported mode list is filled by backends, so numbers are not portable any more // 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" ); Cmd_AddRestrictedCommand( "vid_setmode", VID_Mode_f, "display video mode" );
V_Init(); // init gamma
R_Init(); // init renderer R_Init(); // init renderer
} }

View File

@@ -9,13 +9,6 @@ typedef struct vidmode_s
int height; int height;
} vidmode_t; } vidmode_t;
typedef enum window_mode_e
{
WINDOW_MODE_WINDOWED = 0,
WINDOW_MODE_FULLSCREEN,
WINDOW_MODE_BORDERLESS,
WINDOW_MODE_COUNT,
} window_mode_t;
typedef struct typedef struct
{ {
@@ -28,6 +21,8 @@ typedef struct
qboolean initialized; // OpenGL subsystem started qboolean initialized; // OpenGL subsystem started
qboolean extended; // extended context allows to GL_Debug qboolean extended; // extended context allows to GL_Debug
qboolean software; qboolean software;
} glwstate_t; } glwstate_t;
extern glwstate_t glw_state; extern glwstate_t glw_state;
@@ -35,16 +30,15 @@ extern glwstate_t glw_state;
#define VID_MIN_HEIGHT 200 #define VID_MIN_HEIGHT 200
#define VID_MIN_WIDTH 320 #define VID_MIN_WIDTH 320
extern convar_t vid_fullscreen; extern convar_t *vid_fullscreen;
extern convar_t vid_maximized; extern convar_t *vid_highdpi;
extern convar_t vid_highdpi; extern convar_t *vid_rotate;
extern convar_t window_xpos; extern convar_t *vid_scale;
extern convar_t window_ypos;
extern convar_t gl_msaa_samples;
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized ); extern convar_t *gl_msaa_samples;
void VID_SetDisplayTransform( int *render_w, int *render_h ); void R_SaveVideoMode( int w, int h, int render_w, int render_h );
void VID_CheckChanges( void ); void VID_CheckChanges( void );
const char *VID_GetModeString( int vid_mode ); const char *VID_GetModeString( int vid_mode );
void VID_StartupGamma( void );
#endif // VID_COMMON #endif // VID_COMMON

View File

@@ -428,9 +428,6 @@ void Voice_Disconnect( void )
voice.players_status[i].talking_ack = false; voice.players_status[i].talking_ack = false;
} }
} }
VoiceCapture_Shutdown();
voice.device_opened = false;
} }
/* /*
@@ -591,22 +588,21 @@ Voice_Init
Initialize the voice subsystem 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 ) if( !voice_enable.value )
return false; return false;
// reinitialize only if codec parameters are different
if( Q_strcmp( pszCodecName, voice.codec ) || voice.quality != quality )
{
Voice_Shutdown();
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC )) if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
{ {
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName ); Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
return false; return false;
} }
// reinitialize only if codec parameters are different
if( Q_strcmp( voice.codec, pszCodecName ) && voice.quality != quality )
Voice_Shutdown();
voice.autogain.block_size = 128; voice.autogain.block_size = 128;
if( !Voice_InitOpusDecoder( )) if( !Voice_InitOpusDecoder( ))
@@ -629,15 +625,9 @@ qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
} }
voice.quality = quality; voice.quality = quality;
}
if( !preinit ) if( !VoiceCapture_Init( ))
{
voice.device_opened = VoiceCapture_Init();
if( !voice.device_opened )
Con_Printf( S_WARN "No microphone is available.\n" ); Con_Printf( S_WARN "No microphone is available.\n" );
}
return true; return true;
} }

View File

@@ -53,7 +53,6 @@ typedef struct voice_state_s
qboolean initialized; qboolean initialized;
qboolean is_recording; qboolean is_recording;
qboolean device_opened;
double start_time; double start_time;
voice_status_t local; voice_status_t local;
@@ -93,7 +92,7 @@ extern voice_state_t voice;
void CL_AddVoiceToDatagram( void ); void CL_AddVoiceToDatagram( void );
void Voice_RegisterCvars( 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 ); void Voice_Idle( double frametime );
qboolean Voice_IsRecording( void ); qboolean Voice_IsRecording( void );
void Voice_RecordStop( void ); void Voice_RecordStop( void );

View File

@@ -17,6 +17,7 @@ GNU General Public License for more details.
#define VOX_H #define VOX_H
#define CVOXWORDMAX 64 #define CVOXWORDMAX 64
#define CVOXFILESENTENCEMAX 4096
#define SENTENCE_INDEX -99999 // unique sentence index #define SENTENCE_INDEX -99999 // unique sentence index

View File

@@ -52,7 +52,7 @@ CSCR_ExpectString
Return true if next token is pExpext and skip it 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 )); char *tmp = COM_ParseFile( ps->buf, ps->token, sizeof( ps->token ));
@@ -75,7 +75,7 @@ CSCR_ParseType
Determine script variable type Determine script variable type
=================== ===================
*/ */
static cvartype_t CSCR_ParseType( parserstate_t *ps ) cvartype_t CSCR_ParseType( parserstate_t *ps )
{ {
int i; int i;
@@ -96,7 +96,7 @@ static cvartype_t CSCR_ParseType( parserstate_t *ps )
CSCR_ParseSingleCvar CSCR_ParseSingleCvar
========================= =========================
*/ */
static qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result ) qboolean CSCR_ParseSingleCvar( parserstate_t *ps, scrvardef_t *result )
{ {
// read the name // read the name
ps->buf = COM_ParseFile( ps->buf, result->name, sizeof( result->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 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 )) if( !CSCR_ExpectString( ps, "VERSION", false, true ))
return false; return false;

View File

@@ -53,7 +53,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
Cbuf_Init Cbuf_Init
============ ============
*/ */
static void Cbuf_Init( void ) void Cbuf_Init( void )
{ {
cmd_text.data = cmd_text_buf; cmd_text.data = cmd_text_buf;
filteredcmd_text.data = filteredcmd_text_buf; filteredcmd_text.data = filteredcmd_text_buf;
@@ -79,7 +79,7 @@ void Cbuf_Clear( void )
Cbuf_GetSpace Cbuf_GetSpace
============ ============
*/ */
static void *Cbuf_GetSpace( cmdbuf_t *buf, int length ) void *Cbuf_GetSpace( cmdbuf_t *buf, int length )
{ {
void *data; void *data;
@@ -176,7 +176,7 @@ void Cbuf_InsertText( const char *text )
Cbuf_Execute 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 *text;
char line[MAX_CMD_LINE]; char line[MAX_CMD_LINE];
@@ -356,7 +356,7 @@ hl.exe -dev 3 +map c1a0d
hl.exe -nosound -game bshift hl.exe -nosound -game bshift
=============== ===============
*/ */
static void Cmd_StuffCmds_f( void ) void Cmd_StuffCmds_f( void )
{ {
host.stuffcmds_pending = true; 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" 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; cmd_wait = true;
} }
@@ -382,7 +382,7 @@ Cmd_Echo_f
Just prints the rest of the line to the console Just prints the rest of the line to the console
=============== ===============
*/ */
static void Cmd_Echo_f( void ) void Cmd_Echo_f( void )
{ {
int i; int i;
@@ -398,7 +398,7 @@ Cmd_Alias_f
Creates a new command that executes a command string (possibly ; seperated) 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; cmdalias_t *a;
char cmd[MAX_CMD_LINE]; char cmd[MAX_CMD_LINE];
@@ -529,6 +529,7 @@ typedef struct cmd_s
static int cmd_argc; static int cmd_argc;
static const char *cmd_args = NULL; static const char *cmd_args = NULL;
static char *cmd_argv[MAX_CMD_TOKENS]; 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 static cmd_t *cmd_functions; // possible commands to execute
/* /*
@@ -546,7 +547,7 @@ int GAME_EXPORT Cmd_Argc( void )
Cmd_Argv Cmd_Argv
============ ============
*/ */
const char *GAME_EXPORT Cmd_Argv( int arg ) const char *Cmd_Argv( int arg )
{ {
if((uint)arg >= cmd_argc ) if((uint)arg >= cmd_argc )
return ""; return "";
@@ -558,7 +559,7 @@ const char *GAME_EXPORT Cmd_Argv( int arg )
Cmd_Args Cmd_Args
============ ============
*/ */
const char *GAME_EXPORT Cmd_Args( void ) const char *Cmd_Args( void )
{ {
return cmd_args; return cmd_args;
} }
@@ -881,7 +882,7 @@ Cmd_If_f
Compare and et condition bit if true Compare and et condition bit if true
============ ============
*/ */
static void Cmd_If_f( void ) void Cmd_If_f( void )
{ {
// reset bit first // reset bit first
cmd_condition &= ~BIT( cmd_condlevel ); cmd_condition &= ~BIT( cmd_condlevel );
@@ -942,7 +943,7 @@ Cmd_Else_f
Invert condition bit Invert condition bit
============ ============
*/ */
static void Cmd_Else_f( void ) void Cmd_Else_f( void )
{ {
cmd_condition ^= BIT( cmd_condlevel ); cmd_condition ^= BIT( cmd_condlevel );
} }
@@ -995,7 +996,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
cmd_condlevel = 0; cmd_condlevel = 0;
// cvar value substitution // cvar value substitution
if( cmd_scripting.value && isPrivileged ) if( CVAR_TO_BOOL( cmd_scripting ) && isPrivileged )
{ {
while( *text ) while( *text )
{ {
@@ -1178,7 +1179,7 @@ void Cmd_ForwardToServer( void )
Cmd_List_f Cmd_List_f
============ ============
*/ */
static void Cmd_List_f( void ) void Cmd_List_f( void )
{ {
cmd_t *cmd; cmd_t *cmd;
int i = 0; int i = 0;
@@ -1356,7 +1357,7 @@ inserts escape sequences
void Cmd_Escape( char *newCommand, const char *oldCommand, int len ) void Cmd_Escape( char *newCommand, const char *oldCommand, int len )
{ {
int c; int c;
int scripting = cmd_scripting.value; int scripting = CVAR_TO_BOOL( cmd_scripting );
while( (c = *oldCommand++) && len > 1 ) while( (c = *oldCommand++) && len > 1 )
{ {

View File

@@ -17,24 +17,15 @@ GNU General Public License for more details.
#define COM_STRINGS_H #define COM_STRINGS_H
// default colored message headers // default colored message headers
#define S_BLACK "^0" #define S_NOTE "^2Note:^7 "
#define S_RED "^1" #define S_WARN "^3Warning:^7 "
#define S_GREEN "^2" #define S_ERROR "^1Error:^7 "
#define S_YELLOW "^3"
#define S_BLUE "^4"
#define S_CYAN "^5"
#define S_MAGENTA "^6"
#define S_DEFAULT "^7"
#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 "Usage: "
#define S_USAGE_INDENT "\t" #define S_USAGE_INDENT " "
#define S_OPENGL_NOTE S_GREEN "OpenGL Note: " S_DEFAULT #define S_OPENGL_NOTE "^2OpenGL Note:^7 "
#define S_OPENGL_WARN S_YELLOW "OpenGL Warning: " S_DEFAULT #define S_OPENGL_WARN "^3OpenGL Warning:^7 "
#define S_OPENGL_ERROR S_RED "OpenGL Error: " S_DEFAULT #define S_OPENGL_ERROR "^3OpenGL Error:^7 "
// end game final default message // end game final default message
#define DEFAULT_ENDGAME_MESSAGE "The End" #define DEFAULT_ENDGAME_MESSAGE "The End"

View File

@@ -22,6 +22,7 @@ GNU General Public License for more details.
#include "const.h" #include "const.h"
#include "client.h" #include "client.h"
#include "library.h" #include "library.h"
#include "sequence.h"
static const char *file_exts[] = static const char *file_exts[] =
{ {
@@ -103,7 +104,7 @@ static float fran1( void )
return temp; return temp;
} }
void GAME_EXPORT COM_SetRandomSeed( int lSeed ) void COM_SetRandomSeed( int lSeed )
{ {
if( lSeed ) idum = lSeed; if( lSeed ) idum = lSeed;
else idum = -time( NULL ); else idum = -time( NULL );
@@ -266,7 +267,7 @@ static void LZSS_BuildHash( lzss_state_t *state, const byte *source )
list->start = node; list->start = node;
} }
static byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_length, byte *pOutputBuf, uint *pOutputSize ) byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_length, byte *pOutputBuf, uint *pOutputSize )
{ {
byte *pStart = pOutputBuf; // allocate the output buffer, compressed buffer is expected to be less, caller will free byte *pStart = pOutputBuf; // allocate the output buffer, compressed buffer is expected to be less, caller will free
byte *pEnd = pStart + input_length - sizeof( lzss_header_t ) - 8; // prevent compression failure byte *pEnd = pStart + input_length - sizeof( lzss_header_t ) - 8; // prevent compression failure
@@ -531,6 +532,47 @@ int GAME_EXPORT COM_FileSize( const char *filename )
return FS_FileSize( filename, false ); 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 COM_TrimSpace
@@ -571,7 +613,7 @@ COM_Nibble
Returns the 4 bit nibble for a hex character Returns the 4 bit nibble for a hex character
================== ==================
*/ */
static byte COM_Nibble( char c ) byte COM_Nibble( char c )
{ {
if(( c >= '0' ) && ( c <= '9' )) if(( c >= '0' ) && ( c <= '9' ))
{ {
@@ -619,7 +661,7 @@ COM_MemFgets
============= =============
*/ */
char *GAME_EXPORT COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize ) char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize )
{ {
int i, last, stop; int i, last, stop;
@@ -673,7 +715,7 @@ Cache_Check
consistency check consistency check
==================== ====================
*/ */
void *GAME_EXPORT Cache_Check( poolhandle_t mempool, cache_user_t *c ) void *Cache_Check( poolhandle_t mempool, cache_user_t *c )
{ {
if( !c->data ) if( !c->data )
return NULL; return NULL;
@@ -693,7 +735,7 @@ COM_LoadFileForMe
byte* GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength ) byte* GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
{ {
string name; string name;
byte *pfile; byte *file, *pfile;
fs_offset_t iLength; fs_offset_t iLength;
if( !COM_CheckString( filename )) if( !COM_CheckString( filename ))
@@ -706,9 +748,21 @@ byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
Q_strncpy( name, filename, sizeof( name )); Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name ); COM_FixSlashes( name );
pfile = g_fsapi.LoadFileMalloc( name, &iLength, false ); pfile = FS_LoadFile( name, &iLength, false );
if( pLength ) *pLength = (int)iLength; 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; return pfile;
} }
@@ -718,7 +772,7 @@ COM_LoadFile
============= =============
*/ */
byte *GAME_EXPORT COM_LoadFile( const char *filename, int usehunk, int *pLength ) byte *COM_LoadFile( const char *filename, int usehunk, int *pLength )
{ {
return COM_LoadFileForMe( filename, pLength ); return COM_LoadFileForMe( filename, pLength );
} }
@@ -804,6 +858,59 @@ void GAME_EXPORT pfnGetModelBounds( model_t *mod, float *mins, float *maxs )
} }
} }
/*
=============
pfnCvar_RegisterServerVariable
standard path to register game variable
=============
*/
void GAME_EXPORT pfnCvar_RegisterServerVariable( cvar_t *variable )
{
if( variable != NULL )
SetBits( variable->flags, FCVAR_EXTDLL );
Cvar_RegisterVariable( (convar_t *)variable );
}
/*
=============
pfnCvar_RegisterEngineVariable
use with precaution: this cvar will NOT unlinked
after game.dll is unloaded
=============
*/
void GAME_EXPORT pfnCvar_RegisterEngineVariable( cvar_t *variable )
{
Cvar_RegisterVariable( (convar_t *)variable );
}
/*
=============
pfnCvar_RegisterVariable
=============
*/
cvar_t *pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
{
// a1ba: try to mitigate outdated client.dll vulnerabilities
if( !Q_stricmp( szName, "motdfile" ))
flags |= FCVAR_PRIVILEGED;
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
}
/*
=============
pfnCvar_RegisterVariable
=============
*/
cvar_t *pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags )
{
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_GAMEUIDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_GAMEUIDLL ));
}
/* /*
============= =============
pfnCVarGetPointer pfnCVarGetPointer
@@ -811,11 +918,23 @@ pfnCVarGetPointer
can return NULL can return NULL
============= =============
*/ */
cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName ) cvar_t *pfnCVarGetPointer( const char *szVarName )
{ {
return (cvar_t *)Cvar_FindVar( 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 COM_CompareFileTime
@@ -931,6 +1050,21 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
return true; 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 ) char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
{ {
size_t size; size_t size;
@@ -966,7 +1100,7 @@ void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
{ {
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName ); Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );
return NULL; return Sequence_Get( fileName, entryName );
} }
/* /*
@@ -980,7 +1114,7 @@ void *GAME_EXPORT pfnSequencePickSentence( const char *groupName, int pickMethod
{ {
Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod ); Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod );
return NULL; return Sequence_PickSentence( groupName, pickMethod, picked );
} }
@@ -991,7 +1125,30 @@ pfnIsCareerMatch
used by CS:CZ (client stub) used by CS:CZ (client stub)
============= =============
*/ */
int GAME_EXPORT pfnIsCareerMatch( void ) int GAME_EXPORT GAME_EXPORT pfnIsCareerMatch( void )
{
return 0;
}
/*
=============
pfnRegisterTutorMessageShown
only exists in PlayStation version
=============
*/
void GAME_EXPORT pfnRegisterTutorMessageShown( int mid )
{
}
/*
=============
pfnGetTimesTutorMessageShown
only exists in PlayStation version
=============
*/
int GAME_EXPORT pfnGetTimesTutorMessageShown( int mid )
{ {
return 0; return 0;
} }

View File

@@ -144,7 +144,7 @@ typedef enum
#define GameState (&host.game) #define GameState (&host.game)
#define FORCE_DRAW_VERSION_TIME 5.0 // draw version for 5 seconds #define FORCE_DRAW_VERSION_TIME 5.0f // draw version for 5 seconds
#ifdef _DEBUG #ifdef _DEBUG
void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage ); void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage );
@@ -153,14 +153,16 @@ void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile,
#define Assert( f ) #define Assert( f )
#endif #endif
extern convar_t gl_vsync; extern convar_t *gl_vsync;
extern convar_t scr_loading; extern convar_t *scr_loading;
extern convar_t scr_download; extern convar_t *scr_download;
extern convar_t cmd_scripting; extern convar_t *cmd_scripting;
extern convar_t cl_allow_levelshots; extern convar_t *sv_maxclients;
extern convar_t *cl_allow_levelshots;
extern convar_t host_developer; extern convar_t host_developer;
extern convar_t host_limitlocal; extern convar_t *host_limitlocal;
extern convar_t host_maxfps; extern convar_t *host_framerate;
extern convar_t *host_maxfps;
extern convar_t sys_timescale; extern convar_t sys_timescale;
extern convar_t cl_filterstuffcmd; extern convar_t cl_filterstuffcmd;
extern convar_t rcon_password; extern convar_t rcon_password;
@@ -271,6 +273,40 @@ typedef struct
double forcedEnd; double forcedEnd;
} soundlist_t; } soundlist_t;
typedef struct
{
char model[MAX_QPATH]; // curstate.modelindex = SV_ModelIndex
vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin.
short clientIndex;
float fadeSpeed;
float bounceFactor;
byte hitSound;
qboolean high_priority;
float x, y, z;
int flags;
float time;
// base state
vec3_t velocity; // baseline.origin
vec3_t avelocity; // baseline.angles
int fadeamount; // baseline.renderamt
float sparklife; // baseline.framerate
float thinkTime; // baseline.scale
// current state
vec3_t origin; // entity.origin
vec3_t angles; // entity.angles
float renderamt; // curstate.renderamt
color24 rendercolor; // curstate.rendercolor
int rendermode; // curstate.rendermode
int renderfx; // curstate.renderfx
float framerate; // curstate.framerate
float frame; // curstate.frame
byte body; // curstate.body
byte skin; // curstate.skin
float scale; // curstate.scale
} tentlist_t;
typedef enum bugcomp_e typedef enum bugcomp_e
{ {
// default mode, we assume that user dlls are not relying on engine bugs // default mode, we assume that user dlls are not relying on engine bugs
@@ -302,12 +338,8 @@ typedef struct host_parm_s
int argc; int argc;
char **argv; char **argv;
// ==== shared through RefAPI's ref_host_t
double realtime; // host.curtime double realtime; // host.curtime
double frametime; // time between engine frames double frametime; // time between engine frames
uint features; // custom features that enables by mod-maker request
// ==== shared through RefAPI's ref_host_t
double realframetime; // for some system events, e.g. console animations double realframetime; // for some system events, e.g. console animations
uint framecount; // global framecount uint framecount; // global framecount
@@ -328,7 +360,8 @@ typedef struct host_parm_s
qboolean change_game; // initialize when game is changed qboolean change_game; // initialize when game is changed
qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!) qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!)
qboolean shutdown_issued; // engine is shutting down qboolean shutdown_issued; // engine is shutting down
double force_draw_version_time; qboolean force_draw_version; // used when fraps is loaded
float force_draw_version_time;
qboolean apply_game_config; // when true apply only to game cvars and ignore all other commands 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 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 config_executed; // a bit who indicated was config.cfg already executed e.g. from valve.rc
@@ -348,6 +381,8 @@ typedef struct host_parm_s
poolhandle_t imagepool; // imagelib mempool poolhandle_t imagepool; // imagelib mempool
poolhandle_t soundpool; // soundlib mempool poolhandle_t soundpool; // soundlib mempool
uint features; // custom features that enables by mod-maker request
// for IN_MouseMove() easy access // for IN_MouseMove() easy access
int window_center_x; int window_center_x;
int window_center_y; int window_center_y;
@@ -383,11 +418,11 @@ typedef void (*xcommand_t)( void );
qboolean FS_LoadProgs( void ); qboolean FS_LoadProgs( void );
void FS_Init( void ); void FS_Init( void );
void FS_Shutdown( void ); void FS_Shutdown( void );
void *FS_GetNativeObject( const char *obj );
// //
// cmd.c // cmd.c
// //
void Cbuf_Init( void );
void Cbuf_Clear( void ); void Cbuf_Clear( void );
void Cbuf_AddText( const char *text ); void Cbuf_AddText( const char *text );
void Cbuf_AddTextf( const char *text, ... ) _format( 1 ); void Cbuf_AddTextf( const char *text, ... ) _format( 1 );
@@ -411,6 +446,9 @@ void Cmd_RemoveCommand( const char *cmd_name );
qboolean Cmd_Exists( const char *cmd_name ); qboolean Cmd_Exists( const char *cmd_name );
void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback ); void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback );
int Cmd_ListMaps( search_t *t , char *lastmapname, size_t len ); 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_TokenizeString( const char *text );
void Cmd_ExecuteString( const char *text ); void Cmd_ExecuteString( const char *text );
void Cmd_ForwardToServer( void ); void Cmd_ForwardToServer( void );
@@ -420,8 +458,8 @@ void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
// zone.c // zone.c
// //
void Memory_Init( void ); 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_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 ) ALLOC_CHECK( 2 ); 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 ); 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_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline ); void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
@@ -457,12 +495,13 @@ void FS_FreeImage( rgbdata_t *pack );
extern const bpc_desc_t PFDesc[]; // image get pixelformat extern const bpc_desc_t PFDesc[]; // image get pixelformat
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float reserved ); 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_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 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 ); qboolean Image_CustomPalette( void );
void Image_ClearForceFlags( void ); void Image_ClearForceFlags( void );
void Image_SetMDLPointer( byte *p ); void Image_SetMDLPointer( byte *p );
void Image_CheckPaletteQ1( void ); void Image_CheckPaletteQ1( void );
/* /*
======================================================================== ========================================================================
@@ -538,6 +577,7 @@ qboolean Host_IsQuakeCompatible( void );
void EXPORT Host_Shutdown( void ); void EXPORT Host_Shutdown( void );
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ); int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
int Host_CompareFileTime( int ft1, int ft2 ); 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_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
void Host_AbortCurrentFrame( void ) NORETURN; void Host_AbortCurrentFrame( void ) NORETURN;
void Host_WriteServerConfig( const char *name ); void Host_WriteServerConfig( const char *name );
@@ -548,8 +588,9 @@ qboolean Host_IsLocalGame( void );
qboolean Host_IsLocalClient( void ); qboolean Host_IsLocalClient( void );
void Host_ShutdownServer( void ); void Host_ShutdownServer( void );
void Host_Error( const char *error, ... ) _format( 1 ); void Host_Error( const char *error, ... ) _format( 1 );
void Host_ValidateEngineFeatures( uint32_t features ); void Host_PrintEngineFeatures( void );
void Host_Frame( float time ); void Host_Frame( float time );
void Host_InitDecals( void );
void Host_Credits( void ); void Host_Credits( void );
// //
@@ -588,11 +629,16 @@ qboolean SV_Active( void );
============================================================== ==============================================================
*/ */
void pfnCvar_RegisterServerVariable( cvar_t *variable );
void pfnCvar_RegisterEngineVariable( cvar_t *variable );
cvar_t *pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags );
cvar_t *pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags );
char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize ); char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput ); void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
int COM_SaveFile( const char *filename, const void *data, int len ); int COM_SaveFile( const char *filename, const void *data, int len );
byte* COM_LoadFileForMe( const char *filename, int *pLength ); byte* COM_LoadFileForMe( const char *filename, int *pLength );
qboolean COM_IsSafeFileToDownload( const char *filename ); qboolean COM_IsSafeFileToDownload( const char *filename );
const char *COM_GetResourceTypeName( resourcetype_t restype );
cvar_t *pfnCVarGetPointer( const char *szVarName ); cvar_t *pfnCVarGetPointer( const char *szVarName );
int pfnDrawConsoleString( int x, int y, char *string ); int pfnDrawConsoleString( int x, int y, char *string );
void pfnDrawSetTextColor( float r, float g, float b ); void pfnDrawSetTextColor( float r, float g, float b );
@@ -600,8 +646,10 @@ void pfnDrawConsoleStringLen( const char *pText, int *length, int *height );
void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c ); void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c );
void COM_TrimSpace( const char *source, char *dest ); void COM_TrimSpace( const char *source, char *dest );
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs ); void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
void pfnCVarDirectSet( cvar_t *var, const char *szValue );
int COM_CheckParm( char *parm, char **ppnext ); int COM_CheckParm( char *parm, char **ppnext );
void pfnGetGameDir( char *szGetGameDir ); void pfnGetGameDir( char *szGetGameDir );
int pfnDecalIndex( const char *m );
int pfnGetModelType( model_t *mod ); int pfnGetModelType( model_t *mod );
int pfnIsMapValid( char *filename ); int pfnIsMapValid( char *filename );
void Con_Reportf( const char *szFmt, ... ) _format( 1 ); void Con_Reportf( const char *szFmt, ... ) _format( 1 );
@@ -621,6 +669,8 @@ void *pfnSequencePickSentence( const char *groupName, int pickMethod, int *picke
int pfnIsCareerMatch( void ); int pfnIsCareerMatch( void );
// Decay engfuncs (stubs) // Decay engfuncs (stubs)
int pfnGetTimesTutorMessageShown( int mid );
void pfnRegisterTutorMessageShown( int mid );
void pfnConstructTutorMessageDecayBuffer( int *buffer, int buflen ); void pfnConstructTutorMessageDecayBuffer( int *buffer, int buflen );
void pfnProcessTutorMessageDecayBuffer( int *buffer, int bufferLength ); void pfnProcessTutorMessageDecayBuffer( int *buffer, int bufferLength );
void pfnResetTutorMessageDecayData( void ); void pfnResetTutorMessageDecayData( void );
@@ -641,6 +691,7 @@ void pfnResetTutorMessageDecayData( void );
// //
// con_utils.c // con_utils.c
// //
qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize );
void Con_CompleteCommand( field_t *field ); void Con_CompleteCommand( field_t *field );
void Cmd_AutoComplete( char *complete_string ); void Cmd_AutoComplete( char *complete_string );
void Cmd_AutoCompleteClear( void ); void Cmd_AutoCompleteClear( void );
@@ -696,15 +747,25 @@ void CL_LegacyUpdateInfo( void );
void CL_CharEvent( int key ); void CL_CharEvent( int key );
qboolean CL_DisableVisibility( void ); qboolean CL_DisableVisibility( void );
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength ); 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_GetFirstFunctionHandle( void );
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd ); struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
struct cmdalias_s *Cmd_AliasGetList( void ); struct cmdalias_s *Cmd_AliasGetList( void );
const char *Cmd_GetName( struct cmd_s *cmd ); 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_StartMusic( const char *curtrack, const char *looptrack, int position );
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 Log_Printf( const char *fmt, ... ) _format( 1 );
void SV_BroadcastCommand( 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 ); 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 ); void CL_ClearStaticEntities( void );
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, 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_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
void CL_HudMessage( const char *pMessage ); void CL_HudMessage( const char *pMessage );
const char *CL_MsgInfo( int cmd ); const char *CL_MsgInfo( int cmd );
@@ -713,14 +774,17 @@ void SV_DrawOrthoTriangles( void );
double CL_GetDemoFramerate( void ); double CL_GetDemoFramerate( void );
qboolean UI_CreditsActive( void ); qboolean UI_CreditsActive( void );
void CL_StopPlayback( void ); void CL_StopPlayback( void );
void CL_ExtraUpdate( void );
int CL_GetMaxClients( void ); int CL_GetMaxClients( void );
int SV_GetMaxClients( void ); int SV_GetMaxClients( void );
qboolean CL_IsRecordDemo( void ); qboolean CL_IsRecordDemo( void );
qboolean CL_IsTimeDemo( void ); qboolean CL_IsTimeDemo( void );
qboolean CL_IsPlaybackDemo( void ); qboolean CL_IsPlaybackDemo( void );
qboolean SV_Initialized( void ); qboolean SV_Initialized( void );
qboolean CL_LoadProgs( const char *name );
void CL_ProcessFile( qboolean successfully_received, const char *filename ); void CL_ProcessFile( qboolean successfully_received, const char *filename );
int SV_GetSaveComment( const char *savename, char *comment ); 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 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 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 ); void SV_SysError( const char *error_string );
@@ -728,10 +792,14 @@ void SV_ShutdownGame( void );
void SV_ExecLoadLevel( void ); void SV_ExecLoadLevel( void );
void SV_ExecLoadGame( void ); void SV_ExecLoadGame( void );
void SV_ExecChangeLevel( void ); void SV_ExecChangeLevel( void );
void SV_InitGameProgs( void );
void SV_FreeGameProgs( void );
void CL_WriteMessageHistory( void ); void CL_WriteMessageHistory( void );
void CL_SendCmd( void );
void CL_Disconnect( void ); void CL_Disconnect( void );
void CL_ClearEdicts( void ); void CL_ClearEdicts( void );
void CL_Crashed( void ); void CL_Crashed( void );
qboolean CL_NextDemo( void );
char *SV_Serverinfo( void ); char *SV_Serverinfo( void );
void CL_Drop( void ); void CL_Drop( void );
void Con_Init( void ); void Con_Init( void );
@@ -756,6 +824,7 @@ qboolean Info_SetValueForStarKey( char *s, const char *key, const char *value, i
qboolean Info_IsValid( const char *s ); qboolean Info_IsValid( const char *s );
void Info_WriteVars( file_t *f ); void Info_WriteVars( file_t *f );
void Info_Print( const char *s ); void Info_Print( const char *s );
void Cmd_WriteVariables( file_t *f );
int Cmd_CheckMapsList( int fRefresh ); int Cmd_CheckMapsList( int fRefresh );
void COM_SetRandomSeed( int lSeed ); void COM_SetRandomSeed( int lSeed );
int COM_RandomLong( int lMin, int lMax ); int COM_RandomLong( int lMin, int lMax );
@@ -770,14 +839,13 @@ void VID_Init( void );
void UI_SetActiveMenu( qboolean fActive ); void UI_SetActiveMenu( qboolean fActive );
void UI_ShowConnectionWarning( void ); void UI_ShowConnectionWarning( void );
void Cmd_Null_f( 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 ); qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles ); void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename ); int COM_FileSize( const char *filename );
void COM_FreeFile( void *buffer ); void COM_FreeFile( void *buffer );
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare ); int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
char *va( const char *format, ... ) _format( 1 ); char *va( const char *format, ... ) _format( 1 );
qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer );
// soundlib shared exports // soundlib shared exports
qboolean S_Init( void ); qboolean S_Init( void );
@@ -788,14 +856,8 @@ void S_StopBackgroundTrack( void );
void S_StopAllSounds( qboolean ambient ); void S_StopAllSounds( qboolean ambient );
// gamma routines // gamma routines
void BuildGammaTable( float gamma, float brightness );
byte LightToTexGamma( byte b ); 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 // identification.c
@@ -816,34 +878,6 @@ void NET_MasterClear( void );
void NET_MasterShutdown( void ); void NET_MasterShutdown( void );
qboolean NET_GetMaster( netadr_t from, uint *challenge, double *last_heartbeat ); 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 #ifdef REF_DLL
#error "common.h in ref_dll" #error "common.h in ref_dll"
#endif #endif

View File

@@ -18,7 +18,7 @@ GNU General Public License for more details.
#include "const.h" #include "const.h"
#include "kbutton.h" #include "kbutton.h"
extern convar_t con_gamemaps; extern convar_t *con_gamemaps;
#define CON_MAXCMDS 4096 // auto-complete intermediate list #define CON_MAXCMDS 4096 // auto-complete intermediate list
@@ -76,7 +76,7 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len )
compiler[0] = '\0'; compiler[0] = '\0';
generator[0] = '\0'; generator[0] = '\0';
f = FS_Open( t->filenames[i], "rb", con_gamemaps.value ); f = FS_Open( t->filenames[i], "rb", con_gamemaps->value );
if( f ) if( f )
{ {
@@ -184,13 +184,13 @@ Cmd_GetMapList
Prints or complete map filename 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; search_t *t;
string matchbuf; string matchbuf;
int i, nummaps; int i, nummaps;
t = FS_Search( va( "maps/%s*.bsp", s ), true, con_gamemaps.value ); t = FS_Search( va( "maps/%s*.bsp", s ), true, con_gamemaps->value );
if( !t ) return false; if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf )); COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
@@ -220,7 +220,7 @@ Cmd_GetDemoList
Prints or complete demo filename 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; search_t *t;
string matchbuf; string matchbuf;
@@ -267,7 +267,7 @@ Cmd_GetMovieList
Prints or complete movie filename 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; search_t *t;
string matchbuf; string matchbuf;
@@ -314,7 +314,7 @@ Cmd_GetMusicList
Prints or complete background track filename 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; search_t *t;
string matchbuf; string matchbuf;
@@ -362,7 +362,7 @@ Cmd_GetSavesList
Prints or complete savegame filename 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; search_t *t;
string matchbuf; string matchbuf;
@@ -409,7 +409,7 @@ Cmd_GetConfigList
Prints or complete .cfg filename 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; search_t *t;
string matchbuf; string matchbuf;
@@ -456,7 +456,7 @@ Cmd_GetSoundList
Prints or complete sound filename 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; search_t *t;
string matchbuf; string matchbuf;
@@ -508,7 +508,7 @@ Cmd_GetItemsList
Prints or complete item classname (weapons only) 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; search_t *t;
string matchbuf; string matchbuf;
@@ -555,7 +555,7 @@ Cmd_GetKeysList
Autocomplete for bind command 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; size_t i, numkeys;
string keys[256]; string keys[256];
@@ -636,7 +636,7 @@ Cmd_GetCommandsList
Autocomplete for bind command 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; size_t i;
string matchbuf; string matchbuf;
@@ -701,7 +701,7 @@ Cmd_GetCustomList
Prints or complete .HPK filenames 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; search_t *t;
string matchbuf; string matchbuf;
@@ -747,13 +747,17 @@ Cmd_GetGameList
Prints or complete gamedir name 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; int i, numgamedirs;
string gamedirs[MAX_MODS]; string gamedirs[MAX_MODS];
string matchbuf; string matchbuf;
int len; int len;
// stand-alone games doesn't have cmd "game"
if( !Cmd_Exists( "game" ))
return false;
// compare gamelist with current keyword // compare gamelist with current keyword
len = Q_strlen( s ); len = Q_strlen( s );
@@ -796,7 +800,7 @@ Cmd_GetCDList
Prints or complete CD command name 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; int i, numcdcommands;
string cdcommands[8]; string cdcommands[8];
@@ -850,7 +854,7 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
return true; return true;
} }
static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
{ {
qboolean use_filter = false; qboolean use_filter = false;
byte buf[MAX_SYSPATH]; byte buf[MAX_SYSPATH];
@@ -1057,7 +1061,7 @@ Autocomplete filename
for various cmds 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; autocomplete_list_t *list;
@@ -1341,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 ); 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 ); Cvar_LookupVars( FCVAR_GLCONFIG, NULL, f, (setpair_t)Cmd_WriteOpenGLCvar );
} }
#if !XASH_DEDICATED #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; string backup, newcfg;
@@ -1424,6 +1428,8 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name ); Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name );
SV_InitGameProgs(); // collect user variables
// FIXME: move this out until menu parser is done // FIXME: move this out until menu parser is done
CSCR_LoadDefaultCVars( "settings.scr" ); CSCR_LoadDefaultCVars( "settings.scr" );
@@ -1440,6 +1446,8 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
Host_FinalizeConfig( f, name ); Host_FinalizeConfig( f, name );
} }
else Con_DPrintf( S_ERROR "Couldn't write %s.\n", name ); else Con_DPrintf( S_ERROR "Couldn't write %s.\n", name );
SV_FreeGameProgs(); // release progs with all variables
} }
/* /*

View File

@@ -320,9 +320,7 @@ void Sys_RestoreCrashHandler( void )
#elif XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX #elif XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX
// Posix signal handler // Posix signal handler
#ifndef XASH_OPENBSD
#include <ucontext.h> #include <ucontext.h>
#endif
#include <signal.h> #include <signal.h>
#include <sys/mman.h> #include <sys/mman.h>
#include "library.h" #include "library.h"
@@ -336,6 +334,24 @@ void Sys_RestoreCrashHandler( void )
static struct sigaction oldFilter; static struct sigaction oldFilter;
#ifdef XASH_DYNAMIC_DLADDR
static int d_dladdr( void *sym, Dl_info *info )
{
static int (*dladdr_real) ( void *sym, Dl_info *info );
if( !dladdr_real )
dladdr_real = dlsym( (void*)(size_t)(-1), "dladdr" );
memset( info, 0, sizeof( *info ) );
if( !dladdr_real )
return -1;
return dladdr_real( sym, info );
}
#define dladdr d_dladdr
#endif
static int Sys_PrintFrame( char *buf, int len, int i, void *addr ) static int Sys_PrintFrame( char *buf, int len, int i, void *addr )
{ {
Dl_info dlinfo; Dl_info dlinfo;
@@ -372,9 +388,9 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
bp = (void**)ucontext->uc_mcontext.mc_rbp; bp = (void**)ucontext->uc_mcontext.mc_rbp;
sp = (void**)ucontext->uc_mcontext.mc_rsp; sp = (void**)ucontext->uc_mcontext.mc_rsp;
#elif XASH_NETBSD #elif XASH_NETBSD
pc = (void*)ucontext->uc_mcontext.__gregs[_REG_RIP]; pc = (void*)ucontext->uc_mcontext.__gregs[REG_RIP];
bp = (void**)ucontext->uc_mcontext.__gregs[_REG_RBP]; bp = (void**)ucontext->uc_mcontext.__gregs[REG_RBP];
sp = (void**)ucontext->uc_mcontext.__gregs[_REG_RSP]; sp = (void**)ucontext->uc_mcontext.__gregs[REG_RSP];
#elif XASH_OPENBSD #elif XASH_OPENBSD
pc = (void*)ucontext->sc_rip; pc = (void*)ucontext->sc_rip;
bp = (void**)ucontext->sc_rbp; bp = (void**)ucontext->sc_rbp;
@@ -390,9 +406,9 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
bp = (void**)ucontext->uc_mcontext.mc_ebp; bp = (void**)ucontext->uc_mcontext.mc_ebp;
sp = (void**)ucontext->uc_mcontext.mc_esp; sp = (void**)ucontext->uc_mcontext.mc_esp;
#elif XASH_NETBSD #elif XASH_NETBSD
pc = (void*)ucontext->uc_mcontext.__gregs[_REG_EIP]; pc = (void*)ucontext->uc_mcontext.__gregs[REG_EIP];
bp = (void**)ucontext->uc_mcontext.__gregs[_REG_EBP]; bp = (void**)ucontext->uc_mcontext.__gregs[REG_EBP];
sp = (void**)ucontext->uc_mcontext.__gregs[_REG_ESP]; sp = (void**)ucontext->uc_mcontext.__gregs[REG_ESP];
#elif XASH_OPENBSD #elif XASH_OPENBSD
pc = (void*)ucontext->sc_eip; pc = (void*)ucontext->sc_eip;
bp = (void**)ucontext->sc_ebp; bp = (void**)ucontext->sc_ebp;
@@ -490,7 +506,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
#ifdef XASH_SDL #ifdef XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif #endif
Platform_MessageBox( "Xash Error", message, false ); MSGBOX( message );
// log saved, now we can try to save configs and close log correctly, it may crash // log saved, now we can try to save configs and close log correctly, it may crash
if( host.type == HOST_NORMAL ) if( host.type == HOST_NORMAL )

View File

@@ -19,7 +19,7 @@ GNU General Public License for more details.
#include "eiface.h" // ARRAYSIZE #include "eiface.h" // ARRAYSIZE
convar_t *cvar_vars = NULL; // head of list convar_t *cvar_vars = NULL; // head of list
CVAR_DEFINE_AUTO( cmd_scripting, "0", FCVAR_ARCHIVE|FCVAR_PRIVILEGED, "enable simple condition checking and variable operations" ); convar_t *cmd_scripting;
#ifdef HACKS_RELATED_HLMODS #ifdef HACKS_RELATED_HLMODS
typedef struct cvar_filter_quirks_s typedef struct cvar_filter_quirks_s
@@ -195,7 +195,7 @@ Cvar_ValidateString
deal with userinfo etc 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; const char *pszValue;
static char szNew[MAX_STRING]; static char szNew[MAX_STRING];
@@ -211,7 +211,7 @@ static const char *Cvar_ValidateString( convar_t *var, const char *value )
int len = 0; int len = 0;
// step through the string, only copying back in characters that are printable // step through the string, only copying back in characters that are printable
while( *pszValue && len < ( MAX_STRING - 1 )) while( *pszValue && len < MAX_STRING )
{ {
if( ((byte)*pszValue) < 32 ) if( ((byte)*pszValue) < 32 )
{ {
@@ -278,7 +278,7 @@ Cvar_UnlinkVar
unlink the variable 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; int count = 0;
convar_t **prev; convar_t **prev;
@@ -563,27 +563,6 @@ void Cvar_RegisterVariable( convar_t *var )
#endif #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 Cvar_Set2
@@ -654,10 +633,23 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
if( !force ) if( !force )
{ {
if( !Cvar_CanSet( var )) if( FBitSet( var->flags, FCVAR_READ_ONLY ))
{
Con_Printf( "%s is read-only.\n", var->name );
return var; 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 ); pszValue = Cvar_ValidateString( var, value );
// nothing to change // nothing to change
@@ -685,25 +677,38 @@ Cvar_DirectSet
way to change value for many cvars 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; const char *pszValue;
if( unlikely( !var )) return; // ??? if( !var ) return; // ???
// lookup for registration // lookup for registration
if( unlikely( CVAR_CHECK_SENTINEL( var ) || ( var->next == NULL && !FBitSet( var->flags, FCVAR_EXTENDED|FCVAR_ALLOCATED )))) if( CVAR_CHECK_SENTINEL( var ) || ( var->next == NULL && !FBitSet( var->flags, FCVAR_EXTENDED|FCVAR_ALLOCATED )))
{ {
// need to registering cvar fisrt // need to registering cvar fisrt
Cvar_RegisterVariable( var ); // ok, register it Cvar_RegisterVariable( var ); // ok, register it
}
// lookup for registration again // lookup for registration again
if( var != Cvar_FindVar( var->name )) if( var != Cvar_FindVar( var->name ))
return; // how this possible? return; // how this possible?
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
{
Con_Printf( "%s is read-only.\n", var->name );
return;
} }
if( !Cvar_CanSet( var )) if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
{
Con_Printf( "%s is cheat protected.\n", var->name );
return; 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 // check value
if( !value ) if( !value )
@@ -736,24 +741,6 @@ void GAME_EXPORT Cvar_DirectSet( convar_t *var, const char *value )
Cvar_Changed( var ); 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 Cvar_FullSet
@@ -1091,7 +1078,7 @@ Cvar_Toggle_f
Toggles a cvar for easy single key binding Toggles a cvar for easy single key binding
============ ============
*/ */
static void Cvar_Toggle_f( void ) void Cvar_Toggle_f( void )
{ {
int v; int v;
@@ -1114,7 +1101,7 @@ Allows setting and defining of arbitrary cvars from console, even if they
weren't declared in C code. weren't declared in C code.
============ ============
*/ */
static void Cvar_Set_f( void ) void Cvar_Set_f( void )
{ {
int i, c, l = 0, len; int i, c, l = 0, len;
char combined[MAX_CMD_TOKENS]; char combined[MAX_CMD_TOKENS];
@@ -1147,8 +1134,10 @@ Cvar_SetGL_f
As Cvar_Set, but also flags it as glconfig 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 ) if( Cmd_Argc() != 3 )
{ {
Con_Printf( S_USAGE "setgl <variable> <value>\n" ); Con_Printf( S_USAGE "setgl <variable> <value>\n" );
@@ -1163,7 +1152,7 @@ static void Cvar_SetGL_f( void )
Cvar_Reset_f Cvar_Reset_f
============ ============
*/ */
static void Cvar_Reset_f( void ) void Cvar_Reset_f( void )
{ {
if( Cmd_Argc() != 2 ) if( Cmd_Argc() != 2 )
{ {
@@ -1179,7 +1168,7 @@ static void Cvar_Reset_f( void )
Cvar_List_f Cvar_List_f
============ ============
*/ */
static void Cvar_List_f( void ) void Cvar_List_f( void )
{ {
convar_t *var; convar_t *var;
const char *match = NULL; const char *match = NULL;
@@ -1251,7 +1240,7 @@ void Cvar_Init( void )
{ {
cvar_vars = NULL; cvar_vars = NULL;
cvar_active_filter_quirks = NULL; cvar_active_filter_quirks = NULL;
Cvar_RegisterVariable( &cmd_scripting ); cmd_scripting = Cvar_Get( "cmd_scripting", "0", FCVAR_ARCHIVE|FCVAR_PRIVILEGED, "enable simple condition checking and variable operations" );
Cvar_RegisterVariable( &host_developer ); // early registering for dev Cvar_RegisterVariable( &host_developer ); // early registering for dev
Cvar_RegisterVariable( &cl_filterstuffcmd ); Cvar_RegisterVariable( &cl_filterstuffcmd );
Cmd_AddRestrictedCommand( "setgl", Cvar_SetGL_f, "change the value of a opengl variable" ); // OBSOLETE Cmd_AddRestrictedCommand( "setgl", Cvar_SetGL_f, "change the value of a opengl variable" ); // OBSOLETE

View File

@@ -56,7 +56,8 @@ typedef struct convar_s
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) \ #define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) \
CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc ) CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )
#ifndef REF_DLL #define CVAR_TO_BOOL( x ) ((x) && ((x)->value != 0.0f) ? true : false )
cvar_t *Cvar_GetList( void ); cvar_t *Cvar_GetList( void );
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 ) #define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group ); convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
@@ -66,7 +67,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_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
void Cvar_FullSet( const char *var_name, const char *value, int flags ); void Cvar_FullSet( const char *var_name, const char *value, int flags );
void Cvar_DirectSet( convar_t *var, const char *value ); 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_Set( const char *var_name, const char *value );
void Cvar_SetValue( const char *var_name, float value ); void Cvar_SetValue( const char *var_name, float value );
const char *Cvar_BuildAutoDescription( const char *szName, int flags ); const char *Cvar_BuildAutoDescription( const char *szName, int flags );
@@ -81,6 +81,5 @@ qboolean Cvar_CommandWithPrivilegeCheck( convar_t *v, qboolean isPrivileged );
void Cvar_Init( void ); void Cvar_Init( void );
void Cvar_PostFSInit( void ); void Cvar_PostFSInit( void );
void Cvar_Unlink( int group ); void Cvar_Unlink( int group );
#endif // REF_DLL
#endif//CVAR_H #endif//CVAR_H

View File

@@ -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) void GAME_EXPORT S_StopSound(int entnum, int channel, const char *soundname)
{ {
@@ -209,6 +218,11 @@ void GAME_EXPORT Con_NXPrintf( struct con_nprint_s *info, const char *fmt, ...
} }
const byte *GL_TextureData( unsigned int texnum )
{
return NULL;
}
void SCR_CheckStartupVids( void ) void SCR_CheckStartupVids( void )
{ {
@@ -238,14 +252,4 @@ void CL_HudMessage( const char *pMessage )
} }
byte TextureToGamma( byte b )
{
return b;
}
byte LightToTexGamma( byte b )
{
return b;
}
#endif // XASH_DEDICATED #endif // XASH_DEDICATED

View File

@@ -18,22 +18,12 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "library.h" #include "library.h"
#include "platform/platform.h"
fs_api_t g_fsapi; fs_api_t g_fsapi;
fs_globals_t *FI; fs_globals_t *FI;
static pfnCreateInterface_t fs_pfnCreateInterface;
static HINSTANCE fs_hInstance; static HINSTANCE fs_hInstance;
void *FS_GetNativeObject( const char *obj )
{
if( fs_pfnCreateInterface )
return fs_pfnCreateInterface( obj, NULL );
return NULL;
}
static void FS_Rescan_f( void ) static void FS_Rescan_f( void )
{ {
FS_Rescan(); FS_Rescan();
@@ -61,8 +51,6 @@ static fs_interface_t fs_memfuncs =
_Mem_Alloc, _Mem_Alloc,
_Mem_Realloc, _Mem_Realloc,
_Mem_Free, _Mem_Free,
Sys_GetNativeObject,
}; };
static void FS_UnloadProgs( void ) static void FS_UnloadProgs( void )
@@ -107,13 +95,6 @@ qboolean FS_LoadProgs( void )
return false; return false;
} }
if( !( fs_pfnCreateInterface = (pfnCreateInterface_t)COM_GetProcAddress( fs_hInstance, "CreateInterface" )))
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't find CreateInterface entry point in %s\n", name );
return false;
}
Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" ); Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
return true; return true;

78
engine/common/gamma.c Normal file
View File

@@ -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];
}

View File

@@ -33,7 +33,6 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "base_cmd.h" #include "base_cmd.h"
#include "client.h" #include "client.h"
#include "server.h"
#include "netchan.h" #include "netchan.h"
#include "protocol.h" #include "protocol.h"
#include "mod_local.h" #include "mod_local.h"
@@ -52,20 +51,20 @@ struct tests_stats_s tests_stats;
#endif #endif
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" ); CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" ); CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" );
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" ); CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" ); convar_t *host_serverstate;
static CVAR_DEFINE_AUTO( host_gameloaded, "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" ); convar_t *host_gameloaded;
static CVAR_DEFINE_AUTO( host_clientloaded, "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" ); convar_t *host_clientloaded;
CVAR_DEFINE_AUTO( host_limitlocal, "0", 0, "apply cl_cmdrate and rate to loopback connection" ); convar_t *host_limitlocal;
CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" ); convar_t *host_maxfps;
static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" ); convar_t *host_framerate;
static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" ); convar_t *host_sleeptime;
static CVAR_DEFINE_AUTO( host_sleeptime_debug, "0", 0, "print sleeps between frames" ); convar_t *con_gamemaps;
CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" ); convar_t *build, *ver;
static void Sys_PrintUsage( void ) void Sys_PrintUsage( void )
{ {
string version_str; string version_str;
const char *usage_str; const char *usage_str;
@@ -109,7 +108,6 @@ static void Sys_PrintUsage( void )
O("-clockwindow <cw>", "adjust clockwindow used to ignore client commands to prevent speed hacks") O("-clockwindow <cw>", "adjust clockwindow used to ignore client commands to prevent speed hacks")
"\nGame options:\n" "\nGame options:\n"
O("-game <directory>", "set game directory to start engine with")
O("-dll <path> ", "override server DLL path") O("-dll <path> ", "override server DLL path")
#if !XASH_DEDICATED #if !XASH_DEDICATED
O("-clientlib <path>", "override client DLL path") O("-clientlib <path>", "override client DLL path")
@@ -118,7 +116,6 @@ static void Sys_PrintUsage( void )
O("-oldfont ", "enable unused Quake font in Half-Life") O("-oldfont ", "enable unused Quake font in Half-Life")
O("-width <n> ", "set window width") O("-width <n> ", "set window width")
O("-height <n> ", "set window height") O("-height <n> ", "set window height")
O("-borderless ", "run engine in fullscreen borderless mode")
O("-fullscreen ", "run engine in fullscreen mode") O("-fullscreen ", "run engine in fullscreen mode")
O("-windowed ", "run engine in windowed mode") O("-windowed ", "run engine in windowed mode")
O("-ref <name> ", "use selected renderer dll") O("-ref <name> ", "use selected renderer dll")
@@ -130,7 +127,6 @@ static void Sys_PrintUsage( void )
O("-noenginejoy ", "disable engine builtin joystick support") O("-noenginejoy ", "disable engine builtin joystick support")
O("-noenginemouse ", "disable engine builtin mouse support") O("-noenginemouse ", "disable engine builtin mouse support")
O("-nosound ", "disable sound output") O("-nosound ", "disable sound output")
O("-timedemo ", "run timedemo and exit")
#endif #endif
"\nPlatform-specific options:\n" "\nPlatform-specific options:\n"
@@ -141,7 +137,7 @@ static void Sys_PrintUsage( void )
O("-sdl_joy_old_api ","use SDL legacy joystick API") O("-sdl_joy_old_api ","use SDL legacy joystick API")
O("-sdl_renderer <n>","use alternative SDL_Renderer for software") O("-sdl_renderer <n>","use alternative SDL_Renderer for software")
#endif // XASH_SDL #endif // XASH_SDL
#if XASH_ANDROID && !XASH_SDL #if XASH_ANDROID
O("-nativeegl ","use native egl implementation. Use if screen does not update or black") O("-nativeegl ","use native egl implementation. Use if screen does not update or black")
#endif // XASH_ANDROID #endif // XASH_ANDROID
#if XASH_DOS #if XASH_DOS
@@ -191,66 +187,22 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures Host_PrintEngineFeatures
================ ================
*/ */
static void Host_PrintEngineFeatures( int features ) void Host_PrintEngineFeatures( void )
{ {
struct if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
{ Con_Reportf( "^3EXT:^7 big world support enabled\n" );
uint32_t mask;
const char *msg;
} features_str[] =
{
{ ENGINE_WRITE_LARGE_COORD, "Big World Support" },
{ ENGINE_QUAKE_COMPATIBLE, "Quake Compatibility" },
{ ENGINE_LOAD_DELUXEDATA, "Deluxemap Support" },
{ ENGINE_PHYSICS_PUSHER_EXT, "Improved MOVETYPE_PUSH" },
{ ENGINE_LARGE_LIGHTMAPS, "Large Lightmaps" },
{ ENGINE_COMPENSATE_QUAKE_BUG, "Stupid Quake Bug Compensation" },
{ ENGINE_IMPROVED_LINETRACE, "Improved Trace Line" },
{ ENGINE_COMPUTE_STUDIO_LERP, "Studio MOVETYPE_STEP Lerping" },
{ ENGINE_LINEAR_GAMMA_SPACE, "Linear Gamma Space" },
{ ENGINE_STEP_POSHISTORY_LERP, "MOVETYPE_STEP Position History Based Lerping" },
};
int i;
for( i = 0; i < ARRAYSIZE( features_str ); i++ ) if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ))
{ Con_Reportf( "^3EXT:^7 deluxemap support enabled\n" );
if( FBitSet( features, features_str[i].mask ))
Con_Reportf( "^3EXT:^7 %s is enabled\n", features_str[i].msg );
}
}
/* if( FBitSet( host.features, ENGINE_PHYSICS_PUSHER_EXT ))
============== Con_Reportf( "^3EXT:^7 Improved MOVETYPE_PUSH is used\n" );
Host_ValidateEngineFeatures
validate features bits and set host.features if( FBitSet( host.features, ENGINE_LARGE_LIGHTMAPS ))
============== Con_Reportf( "^3EXT:^7 Large lightmaps enabled\n" );
*/
void Host_ValidateEngineFeatures( uint32_t features )
{
uint32_t mask = ENGINE_FEATURES_MASK;
#if !HOST_DEDICATED if( FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
if( !Host_IsDedicated( ) && cls.legacymode ) Con_Reportf( "^3EXT:^7 Compensate quake bug enabled\n" );
mask = ENGINE_LEGACY_FEATURES_MASK;
#endif
// don't allow unsupported bits
features &= mask;
// force bits for some games
if( !Q_stricmp( GI->gamefolder, "cstrike" ) || !Q_stricmp( GI->gamefolder, "czero" ))
SetBits( features, ENGINE_STEP_POSHISTORY_LERP );
// print requested first
Host_PrintEngineFeatures( features );
// now warn about incompatible bits
if( FBitSet( features, ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ) == ( ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ))
Con_Printf( S_WARN "%s: incompatible ENGINE_STEP_POSHISTORY_LERP and ENGINE_COMPUTE_STUDIO_LERP are enabled!\n", __func__ );
// finally set global variable
host.features = features;
} }
/* /*
@@ -326,30 +278,30 @@ static int Host_CalcSleep( void )
#ifndef XASH_DEDICATED #ifndef XASH_DEDICATED
// never sleep in timedemo for benchmarking purposes // never sleep in timedemo for benchmarking purposes
// also don't sleep with vsync for less lag // also don't sleep with vsync for less lag
if( CL_IsTimeDemo( ) || gl_vsync.value ) if( CL_IsTimeDemo( ) || CVAR_TO_BOOL( gl_vsync ))
return 0; return 0;
#endif #endif
if( Host_IsDedicated() ) if( Host_IsDedicated() )
{ {
// let the dedicated server some sleep // let the dedicated server some sleep
return host_sleeptime.value; return host_sleeptime->value;
} }
switch( host.status ) switch( host.status )
{ {
case HOST_NOFOCUS: case HOST_NOFOCUS:
if( SV_Active() && CL_IsInGame()) if( SV_Active() && CL_IsInGame())
return host_sleeptime.value; return host_sleeptime->value;
// fallthrough // fallthrough
case HOST_SLEEP: case HOST_SLEEP:
return 20; return 20;
} }
return host_sleeptime.value; return host_sleeptime->value;
} }
static void Host_NewInstance( const char *name, const char *finalmsg ) void Host_NewInstance( const char *name, const char *finalmsg )
{ {
if( !pChangeGame ) return; if( !pChangeGame ) return;
@@ -367,7 +319,7 @@ Host_ChangeGame_f
Change game modification Change game modification
================= =================
*/ */
static void Host_ChangeGame_f( void ) void Host_ChangeGame_f( void )
{ {
int i; int i;
@@ -406,7 +358,7 @@ static void Host_ChangeGame_f( void )
Host_Exec_f Host_Exec_f
=============== ===============
*/ */
static void Host_Exec_f( void ) void Host_Exec_f( void )
{ {
string cfgpath; string cfgpath;
byte *f; byte *f;
@@ -492,7 +444,7 @@ static void Host_Exec_f( void )
Host_MemStats_f Host_MemStats_f
=============== ===============
*/ */
static void Host_MemStats_f( void ) void Host_MemStats_f( void )
{ {
switch( Cmd_Argc( )) switch( Cmd_Argc( ))
{ {
@@ -510,7 +462,7 @@ static void Host_MemStats_f( void )
} }
} }
static void Host_Minimize_f( void ) void Host_Minimize_f( void )
{ {
#ifdef XASH_SDL #ifdef XASH_SDL
if( host.hWnd ) SDL_MinimizeWindow( host.hWnd ); if( host.hWnd ) SDL_MinimizeWindow( host.hWnd );
@@ -549,7 +501,7 @@ qboolean Host_IsLocalClient( void )
Host_RegisterDecal Host_RegisterDecal
================= =================
*/ */
static qboolean Host_RegisterDecal( const char *name, int *count ) qboolean Host_RegisterDecal( const char *name, int *count )
{ {
char shortname[MAX_QPATH]; char shortname[MAX_QPATH];
int i; int i;
@@ -583,7 +535,7 @@ static qboolean Host_RegisterDecal( const char *name, int *count )
Host_InitDecals Host_InitDecals
================= =================
*/ */
static void Host_InitDecals( void ) void Host_InitDecals( void )
{ {
int i, num_decals = 0; int i, num_decals = 0;
search_t *t; search_t *t;
@@ -614,7 +566,7 @@ Host_GetCommands
Add them exactly as if they had been typed at the console Add them exactly as if they had been typed at the console
=================== ===================
*/ */
static void Host_GetCommands( void ) void Host_GetCommands( void )
{ {
char *cmd; char *cmd;
@@ -632,7 +584,7 @@ Host_CalcFPS
compute actual FPS for various modes compute actual FPS for various modes
=================== ===================
*/ */
static double Host_CalcFPS( void ) double Host_CalcFPS( void )
{ {
double fps = 0.0; double fps = 0.0;
@@ -647,14 +599,14 @@ static double Host_CalcFPS( void )
} }
else if( Host_IsLocalGame( )) else if( Host_IsLocalGame( ))
{ {
if( !gl_vsync.value ) if( !CVAR_TO_BOOL( gl_vsync ))
fps = host_maxfps.value; fps = host_maxfps->value;
} }
else else
{ {
if( !gl_vsync.value ) if( !CVAR_TO_BOOL( gl_vsync ))
{ {
fps = host_maxfps.value; fps = host_maxfps->value;
if( fps == 0.0 ) fps = MAX_FPS; if( fps == 0.0 ) fps = MAX_FPS;
fps = bound( MIN_FPS, fps, MAX_FPS ); fps = bound( MIN_FPS, fps, MAX_FPS );
} }
@@ -664,15 +616,27 @@ static double Host_CalcFPS( void )
return fps; return fps;
} }
static qboolean Host_Autosleep( double dt, double scale ) /*
{ ===================
double targetframetime, fps; Host_FilterTime
int sleep;
Returns false if the time is too short to run a frame
===================
*/
qboolean Host_FilterTime( float time )
{
static double oldtime;
double fps, scale = sys_timescale.value;
host.realtime += time * scale;
fps = Host_CalcFPS(); fps = Host_CalcFPS();
if( fps <= 0 ) // clamp the fps in multiplayer games
return true; if( fps != 0.0 )
{
static int sleeps;
double targetframetime;
int sleeptime = Host_CalcSleep();
// limit fps to withing tolerable range // limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS ); fps = bound( MIN_FPS, fps, MAX_FPS );
@@ -681,94 +645,44 @@ static qboolean Host_Autosleep( double dt, double scale )
targetframetime = ( 1.0 / ( fps + 1.0 )); targetframetime = ( 1.0 / ( fps + 1.0 ));
else targetframetime = ( 1.0 / fps ); else targetframetime = ( 1.0 / fps );
sleep = Host_CalcSleep(); if(( host.realtime - oldtime ) < targetframetime * scale )
if( sleep == 0 ) // no sleeps between frames, much simpler code
{ {
if( dt < targetframetime * scale ) if( sleeptime > 0 && sleeps > 0 )
{
Sys_Sleep( sleeptime );
sleeps--;
}
return false; return false;
} }
if( sleeptime > 0 && sleeps <= 0 )
{
if( host.status == HOST_FRAME )
{
// give few sleeps this frame with small margin
double targetsleeptime = targetframetime - host.pureframetime * 2;
// don't sleep if we can't keep up with the framerate
if( targetsleeptime > 0 )
sleeps = targetsleeptime / ( sleeptime * 0.001 );
else sleeps = 0;
}
else else
{ {
static double timewindow; // allocate a time window for sleeps // always sleep at least once in minimized/nofocus state
static int counter; // for debug sleeps = 1;
static double realsleeptime;
const double sleeptime = sleep * 0.001;
if( dt < targetframetime * scale )
{
// if we have allocated time window, try to sleep
if( timewindow > realsleeptime )
{
// Sys_Sleep isn't guaranteed to sleep an exact amount of milliseconds
// so we measure the real sleep time and use it to decrease the window
double t1 = Sys_DoubleTime(), t2;
Sys_Sleep( sleep ); // in msec!
t2 = Sys_DoubleTime();
realsleeptime = t2 - t1;
timewindow -= realsleeptime;
if( host_sleeptime_debug.value )
{
counter++;
Con_NPrintf( counter, "%d: %.4f %.4f", counter, timewindow, realsleeptime );
}
}
return false;
}
// if we exhausted this time window, allocate a new one after new frame
if( timewindow <= realsleeptime )
{
double targetsleeptime = targetframetime - host.pureframetime * 2;
if( targetsleeptime > 0 )
timewindow = targetsleeptime;
else timewindow = 0;
realsleeptime = sleeptime; // reset in case CPU was too busy
if( host_sleeptime_debug.value )
{
counter = 0;
Con_NPrintf( 0, "tgt = %.4f, pft = %.4f, wnd = %.4f", targetframetime, host.pureframetime, timewindow );
} }
} }
} }
return true;
}
/*
===================
Host_FilterTime
Returns false if the time is too short to run a frame
===================
*/
static qboolean Host_FilterTime( float time )
{
static double oldtime;
double dt;
double scale = sys_timescale.value;
host.realtime += time * scale;
dt = host.realtime - oldtime;
// clamp the fps in multiplayer games
if( !Host_Autosleep( dt, scale ))
return false;
host.frametime = host.realtime - oldtime; host.frametime = host.realtime - oldtime;
host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME ); host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
oldtime = host.realtime; oldtime = host.realtime;
// NOTE: allow only in singleplayer while demos are not active // NOTE: allow only in singleplayer while demos are not active
if( host_framerate.value > 0.0f && Host_IsLocalGame() && !CL_IsPlaybackDemo() && !CL_IsRecordDemo( )) if( host_framerate->value > 0.0f && Host_IsLocalGame() && !CL_IsPlaybackDemo() && !CL_IsRecordDemo( ))
host.frametime = bound( MIN_FRAMETIME, host_framerate.value * scale, MAX_FRAMETIME ); host.frametime = bound( MIN_FRAMETIME, host_framerate->value * scale, MAX_FRAMETIME );
else host.frametime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME ); else host.frametime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
return true; return true;
@@ -840,7 +754,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
Key_SetKeyDest( key_console ); Key_SetKeyDest( key_console );
Con_Printf( "Host_Error: %s", hosterror1 ); Con_Printf( "Host_Error: %s", hosterror1 );
} }
else Platform_MessageBox( "Host Error", hosterror1, true ); else MSGBOX2( hosterror1 );
} }
// host is shutting down. don't invoke infinite loop // host is shutting down. don't invoke infinite loop
@@ -874,7 +788,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
Host_AbortCurrentFrame(); Host_AbortCurrentFrame();
} }
static void Host_Error_f( void ) void Host_Error_f( void )
{ {
const char *error = Cmd_Argv( 1 ); const char *error = Cmd_Argv( 1 );
@@ -882,7 +796,7 @@ static void Host_Error_f( void )
Host_Error( "%s\n", error ); Host_Error( "%s\n", error );
} }
static void Sys_Error_f( void ) void Sys_Error_f( void )
{ {
const char *error = Cmd_Argv( 1 ); const char *error = Cmd_Argv( 1 );
@@ -905,7 +819,7 @@ static void Host_Crash_f( void )
Host_Userconfigd_f Host_Userconfigd_f
================= =================
*/ */
static void Host_Userconfigd_f( void ) void Host_Userconfigd_f( void )
{ {
search_t *t; search_t *t;
int i; int i;
@@ -949,13 +863,13 @@ static void Host_RunTests( int stage )
Host_InitCommon Host_InitCommon
================= =================
*/ */
static void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bChangeGame ) void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bChangeGame )
{ {
char dev_level[4]; char dev_level[4];
int developer = DEFAULT_DEV; int developer = DEFAULT_DEV;
const char *baseDir; const char *baseDir;
char ticrate[16]; char ticrate[16];
int len, i; int len;
// some commands may turn engine into infinite loop, // some commands may turn engine into infinite loop,
// e.g. xash.exe +game xash -game xash // e.g. xash.exe +game xash -game xash
@@ -1030,7 +944,7 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
progname++; progname++;
Q_strncpy( SI.exeName, progname, sizeof( SI.exeName )); Q_strncpy( SI.exeName, progname, sizeof( SI.exeName ));
Q_strncpy( SI.basedirName, progname, sizeof( SI.basedirName )); Q_strncpy( SI.basedirName, progname, sizeof( SI.exeName ));
if( Host_IsDedicated() ) if( Host_IsDedicated() )
{ {
@@ -1102,9 +1016,8 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
else else
{ {
#if TARGET_OS_IOS #if TARGET_OS_IOS
const char *IOS_GetDocsDir();
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) ); Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) );
#elif XASH_ANDROID && XASH_SDL
Q_strncpy( host.rootdir, SDL_AndroidGetExternalStoragePath(), sizeof( host.rootdir ));
#elif XASH_PSVITA #elif XASH_PSVITA
if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir ) ) ) if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir ) ) )
{ {
@@ -1112,21 +1025,12 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
host.rootdir[0] = 0; host.rootdir[0] = 0;
} }
#elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2 #elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2
char *szBasePath = SDL_GetBasePath(); char *szBasePath;
if( szBasePath )
{ if( !( szBasePath = SDL_GetBasePath() ) )
Sys_Error( "couldn't determine current directory: %s", SDL_GetError() );
Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir )); Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir ));
SDL_free( szBasePath ); SDL_free( szBasePath );
}
else
{
#if XASH_POSIX || XASH_WIN32
if( !getcwd( host.rootdir, sizeof( host.rootdir )))
Sys_Error( "couldn't determine current directory: %s, getcwd: %s", SDL_GetError(), strerror( errno ));
#else
Sys_Error( "couldn't determine current directory: %s", SDL_GetError() );
#endif
}
#else #else
if( !getcwd( host.rootdir, sizeof( host.rootdir ))) if( !getcwd( host.rootdir, sizeof( host.rootdir )))
{ {
@@ -1173,9 +1077,10 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
FS_LoadProgs(); FS_LoadProgs();
// TODO: this function will cause engine to stop in case of fail if( FS_SetCurrentDirectory( host.rootdir ) != 0 )
// when it will have an option to return string error, restore Sys_Error Con_Reportf( "%s is working directory now\n", host.rootdir );
FS_SetCurrentDirectory( host.rootdir ); else
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
FS_Init(); FS_Init();
@@ -1202,25 +1107,12 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
FS_LoadGameInfo( NULL ); FS_LoadGameInfo( NULL );
Cvar_PostFSInit(); Cvar_PostFSInit();
if( FS_FileExists( va( "%s.rc", SI.basedirName ), false ))
Q_strncpy( SI.rcName, SI.basedirName, sizeof( SI.rcName )); // e.g. valve.rc
else Q_strncpy( SI.rcName, SI.exeName, sizeof( SI.rcName )); // e.g. quake.rc
Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder )); Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));
for( i = 0; i < 3; i++ )
{
const char *rcName;
switch( i )
{
case 0: rcName = SI.basedirName; break; // e.g. valve.rc
case 1: rcName = SI.exeName; break; // e.g. quake.rc
case 2: rcName = host.gamefolder; break; // e.g. game.rc (ran from default launcher)
}
if( FS_FileExists( va( "%s.rc", rcName ), false ))
{
Q_strncpy( SI.rcName, rcName, sizeof( SI.rcName ));
break;
}
}
Image_CheckPaletteQ1 (); Image_CheckPaletteQ1 ();
Host_InitDecals (); // reload decals Host_InitDecals (); // reload decals
@@ -1241,7 +1133,7 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
Key_Init(); Key_Init();
} }
static void Host_FreeCommon( void ) void Host_FreeCommon( void )
{ {
Image_Shutdown(); Image_Shutdown();
Sound_Shutdown(); Sound_Shutdown();
@@ -1258,7 +1150,6 @@ Host_Main
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func )
{ {
static double oldtime, newtime; static double oldtime, newtime;
string demoname;
host.starttime = Sys_DoubleTime(); host.starttime = Sys_DoubleTime();
@@ -1274,19 +1165,18 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cmd_AddRestrictedCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons"); Cmd_AddRestrictedCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons");
} }
Cvar_RegisterVariable( &host_serverstate ); host_serverstate = Cvar_Get( "host_serverstate", "0", FCVAR_READ_ONLY, "displays current server state" );
Cvar_RegisterVariable( &host_maxfps ); host_maxfps = Cvar_Get( "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
Cvar_RegisterVariable( &host_framerate ); host_framerate = Cvar_Get( "host_framerate", "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
Cvar_RegisterVariable( &host_sleeptime ); host_sleeptime = Cvar_Get( "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
Cvar_RegisterVariable( &host_sleeptime_debug ); host_gameloaded = Cvar_Get( "host_gameloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" );
Cvar_RegisterVariable( &host_gameloaded ); host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
Cvar_RegisterVariable( &host_clientloaded ); host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" );
Cvar_RegisterVariable( &host_limitlocal ); con_gamemaps = Cvar_Get( "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
Cvar_RegisterVariable( &con_gamemaps );
Cvar_RegisterVariable( &sys_timescale ); Cvar_RegisterVariable( &sys_timescale );
Cvar_Getf( "buildnum", FCVAR_READ_ONLY, "returns a current build number", "%i", Q_buildnum_compat()); build = Cvar_Getf( "buildnum", FCVAR_READ_ONLY, "returns a current build number", "%i", Q_buildnum_compat());
Cvar_Getf( "ver", FCVAR_READ_ONLY, "shows an engine version", "%i/%s (hw build %i)", PROTOCOL_VERSION, XASH_COMPAT_VERSION, Q_buildnum_compat()); ver = Cvar_Getf( "ver", FCVAR_READ_ONLY, "shows an engine version", "%i/%s (hw build %i)", PROTOCOL_VERSION, XASH_COMPAT_VERSION, Q_buildnum_compat());
Cvar_Getf( "host_ver", FCVAR_READ_ONLY, "detailed info about this build", "%i " XASH_VERSION " %s %s %s", Q_buildnum(), Q_buildos(), Q_buildarch(), Q_buildcommit()); Cvar_Getf( "host_ver", FCVAR_READ_ONLY, "detailed info about this build", "%i " XASH_VERSION " %s %s %s", Q_buildnum(), Q_buildos(), Q_buildarch(), Q_buildcommit());
Cvar_Getf( "host_lowmemorymode", FCVAR_READ_ONLY, "indicates if engine compiled for low RAM consumption (0 - normal, 1 - low engine limits, 2 - low protocol limits)", "%i", XASH_LOW_MEMORY ); Cvar_Getf( "host_lowmemorymode", FCVAR_READ_ONLY, "indicates if engine compiled for low RAM consumption (0 - normal, 1 - low engine limits, 2 - low protocol limits)", "%i", XASH_LOW_MEMORY );
@@ -1311,7 +1201,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
HTTP_Init(); HTTP_Init();
ID_Init(); ID_Init();
SoundList_Init();
if( Host_IsDedicated() ) if( Host_IsDedicated() )
{ {
@@ -1357,9 +1246,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline) Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline)
SCR_CheckStartupVids(); // must be last SCR_CheckStartupVids(); // must be last
if( Sys_GetParmFromCmdLine( "-timedemo", demoname ))
Cbuf_AddTextf( "timedemo %s\n", demoname );
oldtime = Sys_DoubleTime() - 0.1; oldtime = Sys_DoubleTime() - 0.1;
if( Host_IsDedicated( )) if( Host_IsDedicated( ))
@@ -1396,8 +1282,6 @@ Host_Shutdown
*/ */
void EXPORT Host_Shutdown( void ) void EXPORT Host_Shutdown( void )
{ {
qboolean error = host.status == HOST_ERR_FATAL;
if( host.shutdown_issued ) return; if( host.shutdown_issued ) return;
host.shutdown_issued = true; host.shutdown_issued = true;
@@ -1405,16 +1289,14 @@ void EXPORT Host_Shutdown( void )
if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg )); if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
#if !XASH_DEDICATED #if !XASH_DEDICATED
if( host.type == HOST_NORMAL && !error ) if( host.type == HOST_NORMAL )
Host_WriteConfig(); Host_WriteConfig();
#endif #endif
SV_Shutdown( "Server shutdown\n" ); SV_Shutdown( "Server shutdown\n" );
SV_UnloadProgs();
SV_ShutdownFilter(); SV_ShutdownFilter();
CL_Shutdown(); CL_Shutdown();
SoundList_Shutdown();
Mod_Shutdown(); Mod_Shutdown();
NET_Shutdown(); NET_Shutdown();
HTTP_Shutdown(); HTTP_Shutdown();

Some files were not shown because too many files have changed in this diff Show More