mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 11:35:05 +08:00
Compare commits
6 Commits
continuous
...
new_vgui_s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa90a4aaa2 | ||
|
|
50dbfb3747 | ||
|
|
41e51c530a | ||
|
|
05b32e4caf | ||
|
|
7e6b5253b2 | ||
|
|
3629448f0c |
22
.cirrus.yml
22
.cirrus.yml
@@ -1,10 +1,10 @@
|
||||
task:
|
||||
name: freebsd-12-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-4
|
||||
image_family: freebsd-12-3
|
||||
setup_script:
|
||||
- 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
|
||||
@@ -13,10 +13,10 @@ task:
|
||||
task:
|
||||
name: freebsd-13-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-2
|
||||
image_family: freebsd-13-1
|
||||
setup_script:
|
||||
- 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
|
||||
@@ -28,19 +28,7 @@ task:
|
||||
image_family: freebsd-14-0-snap
|
||||
setup_script:
|
||||
- pkg update
|
||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||
- git submodule update --init --recursive
|
||||
test_script:
|
||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
||||
- ./scripts/cirrus/build_freebsd.sh full
|
||||
|
||||
task:
|
||||
name: freebsd-15-amd64
|
||||
freebsd_instance:
|
||||
image_family: freebsd-15-0-snap
|
||||
setup_script:
|
||||
- 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
|
||||
|
||||
10
.github/workflows/c-cpp.yml
vendored
10
.github/workflows/c-cpp.yml
vendored
@@ -13,8 +13,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Linux build specifically want oldest Ubuntu as possible
|
||||
# to be crossdistribution compatible, otherwise use ubuntu-latest
|
||||
- os: ubuntu-20.04
|
||||
targetos: linux
|
||||
targetarch: amd64
|
||||
@@ -36,10 +34,10 @@ jobs:
|
||||
# targetos: motomagx
|
||||
# targetarch: armv6
|
||||
|
||||
- os: ubuntu-latest
|
||||
- os: ubuntu-20.04
|
||||
targetos: nswitch
|
||||
targetarch: arm64
|
||||
- os: ubuntu-latest
|
||||
- os: ubuntu-20.04
|
||||
targetos: psvita
|
||||
targetarch: armv7hf
|
||||
- os: windows-latest
|
||||
@@ -49,7 +47,7 @@ jobs:
|
||||
targetos: win32
|
||||
targetarch: i386
|
||||
env:
|
||||
SDL_VERSION: 2.28.1
|
||||
SDL_VERSION: 2.26.2
|
||||
GH_CPU_ARCH: ${{ matrix.targetarch }}
|
||||
ANDROID_SDK_TOOLS_VER: 4333796
|
||||
steps:
|
||||
@@ -82,7 +80,7 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build flatpak (Compat.i386)
|
||||
uses: FWGS/flatpak-github-actions/flatpak-builder@v6.1
|
||||
uses: FWGS/flatpak-github-actions/flatpak-builder@v5
|
||||
with:
|
||||
bundle: ${{ matrix.app }}.flatpak
|
||||
manifest-path: scripts/flatpak/${{ matrix.app }}.yml
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -60,7 +60,6 @@ Makefile.dep
|
||||
ALL_BUILD.*
|
||||
INSTALL.*
|
||||
ZERO_CHECK.*
|
||||
CMakeLists.txt
|
||||
|
||||
# Visual Studio
|
||||
*.obj
|
||||
@@ -334,6 +333,3 @@ __pycache__
|
||||
.history/*
|
||||
.cache/*
|
||||
enc_temp_folder/
|
||||
|
||||
# KDevelop4
|
||||
*.kdev4
|
||||
|
||||
2
3rdparty/gl-wes-v2
vendored
2
3rdparty/gl-wes-v2
vendored
Submodule 3rdparty/gl-wes-v2 updated: 7ba4631bf5...0be6803f81
2
3rdparty/gl4es/gl4es
vendored
2
3rdparty/gl4es/gl4es
vendored
Submodule 3rdparty/gl4es/gl4es updated: 5226f5f937...277be116c1
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: b4bb815420...262128c0d1
2
3rdparty/nanogl
vendored
2
3rdparty/nanogl
vendored
Submodule 3rdparty/nanogl updated: 6b6a947ee0...5f2892a37e
2
3rdparty/vgui_support
vendored
2
3rdparty/vgui_support
vendored
Submodule 3rdparty/vgui_support updated: f85d64c149...27fbcbf2bf
@@ -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`
|
||||
@@ -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` | |
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Mirrored on github - https://github.com/JoelTroch/am_src_rebirth
|
||||
Mirrored on github - https://github.com/nekonomicon/BattleGrounds
|
||||
|
||||
## 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
|
||||
|
||||
@@ -85,9 +85,6 @@ Official gitlab repository - https://gitlab.com/Sockman/hltopdown
|
||||
## Half-Life: Update
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
Download page on official site - http://www.thothie.com/ww/
|
||||
|
||||
## XashXT
|
||||
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
|
||||
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
|
||||
|
||||
## 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
|
||||
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
|
||||
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
|
||||
|
||||
## 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
|
||||
|
||||
@@ -243,17 +229,12 @@ Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_lif
|
||||
## Escape from the Darkness
|
||||
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
|
||||
|
||||
## 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
|
||||
Reverse-engineered code, branch **eftd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/eftd
|
||||
|
||||
## Half-Life: Blue Shift
|
||||
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
|
||||
Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/induction
|
||||
@@ -261,12 +242,12 @@ Branch **induction** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/
|
||||
## Half-Life: Opposing Force
|
||||
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
|
||||
|
||||
## 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
|
||||
Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/hl_urbicide
|
||||
@@ -274,7 +255,7 @@ Branch **hl_urbicide** in hlsdk-portable - https://github.com/FWGS/hlsdk-portabl
|
||||
## Half-Life: 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
|
||||
Branch **half-secret** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/half-secret
|
||||
@@ -287,18 +268,18 @@ Branch **noffice** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tr
|
||||
## Poke 646
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
Branch **sewer_beta** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/sewer_beta
|
||||
@@ -309,12 +290,12 @@ Reverse-engineered code by Velaron - https://github.com/Velaron/tf15-client
|
||||
## The Gate
|
||||
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
|
||||
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
|
||||
|
||||
@@ -357,22 +338,16 @@ Branch **half-screwed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portab
|
||||
Port to Linux - https://github.com/fmoraw/NS
|
||||
|
||||
## 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
|
||||
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
|
||||
|
||||
## The Wastes
|
||||
Version 1.5: Port to Linux - https://git.mentality.rip/a1batross/halflife-thewastes-sdk
|
||||
|
||||
## Threewave CTF
|
||||
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
|
||||
Branch **zombie-x** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/zombie-x
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
For porting guidelines, look engine-porting-guide.md.
|
||||
For porting guidelines, look here(TODO!)
|
||||
|
||||
Status:
|
||||
* **Supported**: active, was confirmed to be fully functional.
|
||||
* **Supported**: active, confirmed to be fully functional.
|
||||
* **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
|
||||
* **Not maintained**: lack of human resources
|
||||
* **Not merged**: was done in third-party fork, real status unknown
|
||||
* **Deprecated**: not supported anymore
|
||||
|
||||
Table is sorted by status and platform.
|
||||
Table is sorted by status.
|
||||
|
||||
| Platform | Status | Maintainer | Note
|
||||
| -------- | ------ | ---------- | ----
|
||||
| Android | Supported | @Velaron |
|
||||
| Windows | Supported | @a1batross, @SNMetamorph |
|
||||
| *BSD | Supported | @nekonomicon |
|
||||
| DOS4GW | Supported | @mittorn |
|
||||
| GNU/Linux | Supported | @a1batross, @mittorn |
|
||||
| Haiku | Supported | not maintained | Was added by #478 and #483
|
||||
| macOS | Supported | @sofakng |
|
||||
| GNU/Linux(x86, amd64, arm) | Supported | @a1batross, @mittorn |
|
||||
| Android | Supported | @a1batross, @mittorn |
|
||||
| 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 |
|
||||
| Switch | Supported | @fgsfdsfgs |
|
||||
| Windows | Supported | @a1batross, @SNMetamorph |
|
||||
| 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)
|
||||
| Wii | In progress | Collaborative effort | [GitHub Repository](https://github.com/saucesaft/xash3d-wii)
|
||||
| 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)
|
||||
| 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
|
||||
|
||||
41
Documentation/vgui2-support.md
Normal file
41
Documentation/vgui2-support.md
Normal 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.
|
||||
42
README.md
42
README.md
@@ -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
|
||||
[](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [](http://fwgsdiscord.mentality.rip/) \
|
||||
[](https://github.com/FWGS/xash3d-fwgs/releases/latest) [](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
|
||||
[](https://github.com/FWGS/xash3d-fwgs/releases/latest) [](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.
|
||||
|
||||
## Donate
|
||||
[](Documentation/donate.md) \
|
||||
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).
|
||||
```
|
||||
Xash3D is a game engine, aimed to provide compatibility with Half-Life Engine,
|
||||
as well as to give game developers well known workflow and extend it.
|
||||
Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine
|
||||
```
|
||||
|
||||
## Fork features
|
||||
* Steam Half-Life (HLSDK 2.4) support.
|
||||
* Crossplatform and modern compilers support: supports Windows, Linux, BSD & Android on x86 & ARM and [many more](Documentation/ports.md).
|
||||
* Better multiplayer support: multiple master servers, headless dedicated server, voice chat and IPv6 support.
|
||||
* Multiple renderers support: OpenGL, GLESv1, GLESv2 and Software.
|
||||
* Advanced virtual filesystem: `.pk3` and `.pk3dir` support, compatibility with GoldSrc FS module, fast case-insensitivity emulation for crossplatform.
|
||||
* Mobility API: better game integration on mobile devices (vibration, touch controls)
|
||||
* Different input methods: touch and gamepad in addition to mouse & keyboard.
|
||||
* HLSDK 2.4 support.
|
||||
* Crossplatform: supported x86 and ARM on Windows/Linux/BSD/Android. ([see docs for more info](Documentation/ports.md))
|
||||
* Modern compilers support: say no more to MSVC6.
|
||||
* Better multiplayer support: multiple master servers, headless dedicated server.
|
||||
* Mobility API: allows better game integration on mobile devices(vibration, touch controls)
|
||||
* Different input methods: touch, gamepad and classic mouse & keyboard.
|
||||
* TrueType font rendering, as a part of mainui_cpp.
|
||||
* External VGUI support module.
|
||||
* PNG & KTX2 image format support.
|
||||
* [A set of small improvements](Documentation/), without broken compatibility.
|
||||
* Multiple renderers support: OpenGL, GLESv1, GLESv2, Software.
|
||||
* Voice support.
|
||||
* 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
|
||||
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.
|
||||
|
||||
@@ -18,17 +18,21 @@ GNU General Public License for more details.
|
||||
// video backends (XASH_VIDEO)
|
||||
#define VIDEO_NULL 0
|
||||
#define VIDEO_SDL 1
|
||||
#define VIDEO_ANDROID 2
|
||||
#define VIDEO_FBDEV 3
|
||||
#define VIDEO_DOS 4
|
||||
|
||||
|
||||
// audio backends (XASH_SOUND)
|
||||
#define SOUND_NULL 0
|
||||
#define SOUND_SDL 1
|
||||
#define SOUND_OPENSLES 2
|
||||
#define SOUND_ALSA 3
|
||||
|
||||
// input (XASH_INPUT)
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_SDL 1
|
||||
#define INPUT_ANDROID 2
|
||||
#define INPUT_EVDEV 3
|
||||
|
||||
// timer (XASH_TIMER)
|
||||
@@ -41,13 +45,16 @@ GNU General Public License for more details.
|
||||
// messageboxes (XASH_MESSAGEBOX)
|
||||
#define MSGBOX_STDERR 0
|
||||
#define MSGBOX_SDL 1
|
||||
#define MSGBOX_ANDROID 2
|
||||
#define MSGBOX_WIN32 3
|
||||
#define MSGBOX_NSWITCH 4
|
||||
|
||||
|
||||
// library loading (XASH_LIB)
|
||||
#define LIB_NULL 0
|
||||
#define LIB_POSIX 1
|
||||
#define LIB_WIN32 2
|
||||
#define LIB_STATIC 3
|
||||
|
||||
|
||||
#endif /* BACKENDS_H */
|
||||
|
||||
@@ -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 ImageCompressed( type ) \
|
||||
( 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 )
|
||||
#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)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -38,15 +25,9 @@ typedef enum
|
||||
PF_DXT3, // s3tc DXT3/BC2 format
|
||||
PF_DXT5, // s3tc DXT5/BC3 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_UNSIGNED, // bptc BC6H unsigned FP16 format
|
||||
PF_BC7_UNORM, // bptc BC7 format
|
||||
PF_BC7_SRGB,
|
||||
PF_KTX2_RAW, // Raw KTX2 data, used for yet unsupported KTX2 subformats
|
||||
PF_BC7, // bptc BC7 format
|
||||
PF_TOTALCOUNT, // must be last
|
||||
} pixformat_t;
|
||||
|
||||
@@ -69,7 +50,6 @@ typedef enum
|
||||
IL_LOAD_DECAL = BIT(5), // special mode for load gradient decals
|
||||
IL_OVERVIEW = BIT(6), // overview required some unque operations
|
||||
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;
|
||||
|
||||
// goes into rgbdata_t->encode
|
||||
|
||||
@@ -52,6 +52,26 @@ SETUP BACKENDS DEFINITIONS
|
||||
#endif
|
||||
#endif // XASH_MESSAGEBOX
|
||||
#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
|
||||
// we are building for Linux without SDL2, can draw only to framebuffer yet
|
||||
#ifndef XASH_VIDEO
|
||||
@@ -151,8 +171,6 @@ Default build-depended cvar and constant values
|
||||
#define DEFAULT_MODE_WIDTH 960
|
||||
#define DEFAULT_MODE_HEIGHT 544
|
||||
#define DEFAULT_ALLOWCONSOLE 1
|
||||
#elif XASH_ANDROID
|
||||
#define DEFAULT_TOUCH_ENABLE "1"
|
||||
#elif XASH_MOBILE_PLATFORM
|
||||
#define DEFAULT_TOUCH_ENABLE "1"
|
||||
#define DEFAULT_M_IGNORE "1"
|
||||
@@ -186,11 +204,7 @@ Default build-depended cvar and constant values
|
||||
#endif // DEFAULT_ALLOWCONSOLE
|
||||
|
||||
#ifndef DEFAULT_FULLSCREEN
|
||||
#define DEFAULT_FULLSCREEN "1" // must be a string
|
||||
#define DEFAULT_FULLSCREEN 1
|
||||
#endif // DEFAULT_FULLSCREEN
|
||||
|
||||
#ifndef DEFAULT_MAX_EDICTS
|
||||
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
|
||||
#endif // DEFAULT_MAX_EDICTS
|
||||
|
||||
#endif // DEFAULTS_H
|
||||
|
||||
@@ -19,8 +19,6 @@ GNU General Public License for more details.
|
||||
#define GFL_NOMODELS (1<<0)
|
||||
#define GFL_NOSKILLS (1<<1)
|
||||
#define GFL_RENDER_PICBUTTON_TEXT (1<<2)
|
||||
#define GFL_HD_BACKGROUND (1<<3)
|
||||
#define GFL_ANIMATED_TITLE (1<<4)
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
@@ -229,7 +229,7 @@ typedef struct render_api_s
|
||||
void (*R_Reserved0)( void );
|
||||
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
|
||||
// engine utils (not related with render API but placed here)
|
||||
|
||||
@@ -57,7 +57,6 @@ typedef uint64_t longtime_t;
|
||||
#define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions
|
||||
|
||||
#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
|
||||
@@ -87,22 +86,16 @@ typedef uint64_t longtime_t;
|
||||
#endif
|
||||
#define _format(x) __attribute__((format(printf, x, x+1)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NONNULL __attribute__((nonnull))
|
||||
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define EXPORT __declspec( dllexport )
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#define ALLOC_CHECK(x)
|
||||
#else
|
||||
#define EXPORT
|
||||
#define GAME_EXPORT
|
||||
#define _format(x)
|
||||
#define NORETURN
|
||||
#define NONNULL
|
||||
#define ALLOC_CHECK(x)
|
||||
#endif
|
||||
|
||||
#if ( __GNUC__ >= 3 )
|
||||
@@ -184,7 +177,6 @@ typedef struct dll_info_s
|
||||
} dll_info_t;
|
||||
|
||||
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
|
||||
// the server to all connected clients.
|
||||
|
||||
206
contrib/mittorn/Makefile.linux
Normal file
206
contrib/mittorn/Makefile.linux
Normal 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
269
contrib/mittorn/README.md
Normal 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
7
contrib/mittorn/setup.sh
Executable 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
73
contrib/mittorn/wscript
Normal 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
|
||||
)
|
||||
@@ -85,12 +85,6 @@ void CL_PlayCDTrack_f( void )
|
||||
paused = 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" ))
|
||||
{
|
||||
if( Q_isdigit( pszTrack ))
|
||||
@@ -102,12 +96,6 @@ void CL_PlayCDTrack_f( void )
|
||||
paused = false;
|
||||
looped = true;
|
||||
}
|
||||
else if( !Q_stricmp( command, "loopfile" ))
|
||||
{
|
||||
S_StartBackgroundTrack( pszTrack, pszTrack, 0, true );
|
||||
paused = false;
|
||||
looped = true;
|
||||
}
|
||||
else if( !Q_stricmp( command, "pause" ))
|
||||
{
|
||||
S_StreamSetPause( true );
|
||||
@@ -218,7 +206,7 @@ void CL_ScreenShot_f( void )
|
||||
if( !CL_ScreenshotGetName( i, checkname, sizeof( checkname )))
|
||||
return; // no namespace
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
if( !FS_FileExists( checkname, false ))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -258,7 +246,7 @@ void CL_SnapShot_f( void )
|
||||
if( !CL_SnapshotGetName( i, checkname, sizeof( checkname )))
|
||||
return; // no namespace
|
||||
|
||||
if( !FS_FileExists( checkname, true ))
|
||||
if( !FS_FileExists( checkname, false ))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -372,7 +372,7 @@ void CL_WriteDemoHeader( const char *name )
|
||||
demo.header.id = IDEMOHEADER;
|
||||
demo.header.dem_protocol = DEMO_PROTOCOL;
|
||||
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
|
||||
demo.header.host_fps = bound( MIN_FPS, host_maxfps.value, 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.comment, clgame.maptitle, sizeof( demo.header.comment ));
|
||||
Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir ));
|
||||
@@ -648,13 +648,11 @@ void CL_DemoStartPlayback( int mode )
|
||||
{
|
||||
if( cls.changedemo )
|
||||
{
|
||||
int maxclients = cl.maxclients;
|
||||
|
||||
S_StopAllSounds( true );
|
||||
SCR_BeginLoadingPlaque( false );
|
||||
|
||||
CL_ClearState( );
|
||||
CL_InitEdicts( maxclients ); // re-arrange edicts
|
||||
CL_ClearState ();
|
||||
CL_InitEdicts (); // re-arrange edicts
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -700,7 +698,7 @@ void CL_DemoAborted( void )
|
||||
cls.demofile = NULL;
|
||||
cls.demonum = -1;
|
||||
|
||||
Cvar_DirectSet( &v_dark, "0" );
|
||||
Cvar_SetValue( "v_dark", 0.0f );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -718,7 +716,7 @@ void CL_DemoCompleted( void )
|
||||
if( !CL_NextDemo() && !cls.changedemo )
|
||||
UI_SetActiveMenu( true );
|
||||
|
||||
Cvar_DirectSet( &v_dark, "0" );
|
||||
Cvar_SetValue( "v_dark", 0.0f );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1124,10 +1122,7 @@ void CL_FinishTimeDemo( void )
|
||||
time = host.realtime - cls.td_starttime;
|
||||
if( !time ) time = 1.0;
|
||||
|
||||
Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time );
|
||||
|
||||
if( Sys_CheckParm( "-timedemo" ))
|
||||
CL_Quit_f();
|
||||
Con_Printf( "%i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1311,7 +1306,7 @@ void CL_CheckStartupDemos( void )
|
||||
}
|
||||
|
||||
// run demos loop in background mode
|
||||
Cvar_DirectSet( &v_dark, "1" );
|
||||
Cvar_SetValue( "v_dark", 1.0f );
|
||||
cls.demos_pending = false;
|
||||
cls.demonum = 0;
|
||||
CL_NextDemo ();
|
||||
@@ -1327,11 +1322,11 @@ static void CL_DemoGetName( int lastnum, char *filename, size_t size )
|
||||
if( lastnum < 0 || lastnum > 9999 )
|
||||
{
|
||||
// bound
|
||||
Q_strncpy( filename, "demo9999", size );
|
||||
Q_strncpy( filename, "demo9999.dem", size );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( filename, size, "demo%04d", lastnum );
|
||||
Q_snprintf( filename, size, "demo%04d.dem", lastnum );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1386,9 +1381,7 @@ void CL_Record_f( void )
|
||||
for( n = 0; n < 10000; n++ )
|
||||
{
|
||||
CL_DemoGetName( n, demoname, sizeof( demoname ));
|
||||
Q_snprintf( demopath, sizeof( demopath ), "%s.dem", demoname );
|
||||
|
||||
if( !FS_FileExists( demopath, true ))
|
||||
if( !FS_FileExists( demoname, true ))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1475,7 +1468,7 @@ void CL_PlayDemo_f( void )
|
||||
{
|
||||
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' )
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "r_efx.h"
|
||||
#include "cl_tent.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 gSparkRamp[9] = { 0xfe, 0xfd, 0xfc, 0x6f, 0x6e, 0x6d, 0x6c, 0x67, 0x60 };
|
||||
|
||||
static CVAR_DEFINE_AUTO( tracerspeed, "6000", 0, "tracer speed" );
|
||||
static CVAR_DEFINE_AUTO( tracerlength, "0.8", 0, "tracer length factor" );
|
||||
static CVAR_DEFINE_AUTO( traceroffset, "30", 0, "tracer starting offset" );
|
||||
convar_t *tracerspeed;
|
||||
convar_t *tracerlength;
|
||||
convar_t *traceroffset;
|
||||
|
||||
particle_t *cl_active_particles;
|
||||
particle_t *cl_active_tracers;
|
||||
@@ -100,9 +100,9 @@ void CL_InitParticles( void )
|
||||
cl_avelocities[i][2] = COM_RandomFloat( 0.0f, 2.55f );
|
||||
}
|
||||
|
||||
Cvar_RegisterVariable( &tracerspeed );
|
||||
Cvar_RegisterVariable( &tracerlength );
|
||||
Cvar_RegisterVariable( &traceroffset );
|
||||
tracerspeed = Cvar_Get( "tracerspeed", "6000", 0, "tracer speed" );
|
||||
tracerlength = Cvar_Get( "tracerlength", "0.8", 0, "tracer length factor" );
|
||||
traceroffset = Cvar_Get( "traceroffset", "30", 0, "tracer starting offset" );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -171,7 +171,7 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float )
|
||||
{
|
||||
particle_t *p;
|
||||
|
||||
if( !cl_draw_particles.value )
|
||||
if( !cl_draw_particles->value )
|
||||
return NULL;
|
||||
|
||||
// never alloc particles when we not in game
|
||||
@@ -222,7 +222,7 @@ particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
|
||||
{
|
||||
particle_t *p;
|
||||
|
||||
if( !cl_draw_tracers.value )
|
||||
if( !cl_draw_tracers->value )
|
||||
return NULL;
|
||||
|
||||
// never alloc particles when we not in game
|
||||
@@ -249,7 +249,7 @@ particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
|
||||
VectorCopy( org, p->org );
|
||||
VectorCopy( vel, p->vel );
|
||||
p->die = cl.time + life;
|
||||
p->ramp = tracerlength.value;
|
||||
p->ramp = tracerlength->value;
|
||||
p->color = 4; // select custom color
|
||||
p->packedColor = 255; // alpha
|
||||
|
||||
@@ -1236,15 +1236,12 @@ R_BloodStream
|
||||
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;
|
||||
int i, j;
|
||||
float arc;
|
||||
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++ )
|
||||
{
|
||||
@@ -1807,14 +1804,14 @@ void GAME_EXPORT R_TracerEffect( const vec3_t start, const vec3_t end )
|
||||
float len, speed;
|
||||
float offset;
|
||||
|
||||
speed = Q_max( tracerspeed.value, 3.0f );
|
||||
speed = Q_max( tracerspeed->value, 3.0f );
|
||||
|
||||
VectorSubtract( end, start, dir );
|
||||
len = VectorLength( dir );
|
||||
if( len == 0.0f ) return;
|
||||
|
||||
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 );
|
||||
VectorAdd( start, vel, pos );
|
||||
VectorScale( dir, speed, vel );
|
||||
@@ -2070,16 +2067,16 @@ void CL_FreeDeadBeams( void )
|
||||
void CL_DrawEFX( float time, qboolean fTrans )
|
||||
{
|
||||
CL_FreeDeadBeams();
|
||||
if( cl_draw_beams.value )
|
||||
if( CVAR_TO_BOOL( cl_draw_beams ))
|
||||
ref.dllFuncs.CL_DrawBeams( fTrans, cl_active_beams );
|
||||
|
||||
if( fTrans )
|
||||
{
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void CL_DescribeEvent( event_info_t *ei, int slot )
|
||||
con_nprint_t info;
|
||||
string origin_str = { 0 }; //, angles_str = { 0 };
|
||||
|
||||
if( !cl_showevents.value )
|
||||
if( !cl_showevents->value )
|
||||
return;
|
||||
|
||||
info.time_to_live = 1.0f;
|
||||
@@ -225,18 +225,6 @@ qboolean CL_FireEvent( event_info_t *ei, int slot )
|
||||
|
||||
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 )
|
||||
{
|
||||
CL_DescribeEvent( ei, slot );
|
||||
@@ -244,6 +232,7 @@ qboolean CL_FireEvent( event_info_t *ei, int slot )
|
||||
return true;
|
||||
}
|
||||
|
||||
name = cl.event_precache[ei->index];
|
||||
Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ some ents will be ignore lerping
|
||||
*/
|
||||
qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
|
||||
{
|
||||
if( cl_nointerp.value > 0.f )
|
||||
if( cl_nointerp->value > 0.f )
|
||||
return true;
|
||||
|
||||
if( e->model && e->model->type == mod_alias )
|
||||
@@ -464,13 +464,13 @@ int CL_InterpolateModel( cl_entity_t *e )
|
||||
if( cl.maxclients <= 1 )
|
||||
return 1;
|
||||
|
||||
if( e->model->type == mod_brush && !cl_bmodelinterp.value )
|
||||
if( e->model->type == mod_brush && !cl_bmodelinterp->value )
|
||||
return 1;
|
||||
|
||||
if( cl.local.moving && cl.local.onground == e->index )
|
||||
return 1;
|
||||
|
||||
t = cl.time - cl_interp.value;
|
||||
t = cl.time - cl_interp->value;
|
||||
CL_FindInterpolationUpdates( e, t, &ph0, &ph1 );
|
||||
|
||||
if( ph0 == NULL || ph1 == NULL )
|
||||
@@ -537,7 +537,7 @@ void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||
if( !ent->player )
|
||||
return;
|
||||
|
||||
if( cl_nointerp.value > 0.f )
|
||||
if( cl_nointerp->value > 0.f )
|
||||
{
|
||||
VectorCopy( ent->curstate.angles, ent->angles );
|
||||
VectorCopy( ent->curstate.origin, ent->origin );
|
||||
@@ -555,7 +555,7 @@ void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||
return;
|
||||
}
|
||||
|
||||
targettime = cl.time - cl_interp.value;
|
||||
targettime = cl.time - cl_interp->value;
|
||||
CL_PureOrigin( ent, targettime, origin, angles );
|
||||
|
||||
VectorCopy( angles, ent->angles );
|
||||
|
||||
@@ -154,7 +154,7 @@ CL_CreatePlaylist
|
||||
Create a default valve playlist
|
||||
====================
|
||||
*/
|
||||
static void CL_CreatePlaylist( const char *filename )
|
||||
void CL_CreatePlaylist( const char *filename )
|
||||
{
|
||||
file_t *f;
|
||||
|
||||
@@ -458,7 +458,7 @@ void CL_DrawCenterPrint( void )
|
||||
if( !clgame.centerPrint.time )
|
||||
return;
|
||||
|
||||
if(( cl.time - clgame.centerPrint.time ) >= scr_centertime.value )
|
||||
if(( cl.time - clgame.centerPrint.time ) >= scr_centertime->value )
|
||||
{
|
||||
// time expired
|
||||
clgame.centerPrint.time = 0.0f;
|
||||
@@ -665,12 +665,12 @@ void CL_ParseTextMessage( sizebuf_t *msg )
|
||||
text->g2 = MSG_ReadByte( msg );
|
||||
text->b2 = MSG_ReadByte( msg );
|
||||
text->a2 = MSG_ReadByte( msg );
|
||||
text->fadein = (float)(MSG_ReadWord( msg ) / 256.0f );
|
||||
text->fadeout = (float)(MSG_ReadWord( msg ) / 256.0f );
|
||||
text->holdtime = (float)(MSG_ReadWord( msg ) / 256.0f );
|
||||
text->fadein = (float)(MSG_ReadShort( msg ) / 256.0f );
|
||||
text->fadeout = (float)(MSG_ReadShort( msg ) / 256.0f );
|
||||
text->holdtime = (float)(MSG_ReadShort( msg ) / 256.0f );
|
||||
|
||||
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;
|
||||
|
||||
// to prevent grab too long messages
|
||||
@@ -914,7 +914,7 @@ void CL_DrawCrosshair( void )
|
||||
int x, y, width, height;
|
||||
float xscale, yscale;
|
||||
|
||||
if( !clgame.ds.pCrosshair || !cl_crosshair.value )
|
||||
if( !clgame.ds.pCrosshair || !cl_crosshair->value )
|
||||
return;
|
||||
|
||||
// any camera on or client is died
|
||||
@@ -1088,13 +1088,13 @@ void CL_ClearWorld( void )
|
||||
clgame.numStatics = 0;
|
||||
}
|
||||
|
||||
void CL_InitEdicts( int maxclients )
|
||||
void CL_InitEdicts( void )
|
||||
{
|
||||
Assert( clgame.entities == NULL );
|
||||
|
||||
if( !clgame.mempool ) return; // Host_Error without client
|
||||
#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
|
||||
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 );
|
||||
@@ -1109,12 +1109,12 @@ void CL_InitEdicts( int maxclients )
|
||||
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
|
||||
}
|
||||
|
||||
ref.dllFuncs.R_ProcessEntData( true, clgame.entities, clgame.maxEntities );
|
||||
ref.dllFuncs.R_ProcessEntData( true );
|
||||
}
|
||||
|
||||
void CL_FreeEdicts( void )
|
||||
{
|
||||
ref.dllFuncs.R_ProcessEntData( false, NULL, 0 );
|
||||
ref.dllFuncs.R_ProcessEntData( false );
|
||||
|
||||
if( clgame.entities )
|
||||
Mem_Free( clgame.entities );
|
||||
@@ -1140,7 +1140,7 @@ void CL_ClearEdicts( void )
|
||||
|
||||
// in case we stopped with error
|
||||
clgame.maxEntities = 2;
|
||||
CL_InitEdicts( cl.maxclients );
|
||||
CL_InitEdicts();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1235,7 +1235,11 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
model_t *mod;
|
||||
int i, start;
|
||||
int i;
|
||||
|
||||
// use high indices for client sprites
|
||||
// for GoldSrc bug-compatibility
|
||||
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
|
||||
|
||||
if( !COM_CheckString( filename ))
|
||||
{
|
||||
@@ -1246,7 +1250,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
Q_strncpy( name, filename, sizeof( name ));
|
||||
COM_FixSlashes( name );
|
||||
|
||||
for( i = 0, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
|
||||
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
{
|
||||
if( !Q_stricmp( mod->name, name ))
|
||||
{
|
||||
@@ -1263,15 +1267,8 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
}
|
||||
|
||||
// find a free model slot spot
|
||||
// use low indices only for HUD sprites
|
||||
// for GoldSrc bug compatibility
|
||||
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
|
||||
|
||||
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
{
|
||||
if( !mod->name[0] )
|
||||
break; // this is a valid spot
|
||||
}
|
||||
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
if( !mod->name[0] ) break; // this is a valid spot
|
||||
|
||||
if( i == MAX_CLIENT_SPRITES / 2 )
|
||||
{
|
||||
@@ -1323,7 +1320,6 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
|
||||
=========
|
||||
pfnSPR_Load
|
||||
|
||||
function exported for support GoldSrc Monitor utility
|
||||
=========
|
||||
*/
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
|
||||
@@ -1342,7 +1338,7 @@ CL_GetSpritePointer
|
||||
|
||||
=============
|
||||
*/
|
||||
static const model_t *CL_GetSpritePointer( HSPRITE hSprite )
|
||||
const model_t *CL_GetSpritePointer( HSPRITE hSprite )
|
||||
{
|
||||
model_t *mod;
|
||||
int index = hSprite - 1;
|
||||
@@ -1372,7 +1368,6 @@ static const model_t *CL_GetSpritePointer( HSPRITE hSprite )
|
||||
=========
|
||||
pfnSPR_Frames
|
||||
|
||||
function exported for support GoldSrc Monitor utility
|
||||
=========
|
||||
*/
|
||||
int EXPORT pfnSPR_Frames( HSPRITE hPic )
|
||||
@@ -1635,14 +1630,14 @@ get actual screen info
|
||||
*/
|
||||
int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
|
||||
{
|
||||
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 );
|
||||
SCR_LoadCreditsFont();
|
||||
|
||||
ClearBits( hud_fontscale.flags, FCVAR_CHANGED );
|
||||
ClearBits( hud_fontscale->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
// setup screen info
|
||||
@@ -1690,22 +1685,6 @@ static void GAME_EXPORT pfnSetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g,
|
||||
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
|
||||
@@ -1910,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 };
|
||||
int flags = FONT_DRAW_HUD;
|
||||
|
||||
if( hud_utf8.value )
|
||||
if( hud_utf8->value )
|
||||
flags |= FONT_DRAW_UTF8;
|
||||
|
||||
return CL_DrawCharacter( x, y, number, color, &cls.creditsFont, flags );
|
||||
@@ -1925,7 +1904,7 @@ drawing string like a console 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;
|
||||
Vector4Copy( clgame.ds.textColor, color );
|
||||
Vector4Set( clgame.ds.textColor, 255, 255, 255, 255 );
|
||||
@@ -1958,7 +1937,7 @@ compute string length in screen pixels
|
||||
*/
|
||||
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;
|
||||
CL_DrawStringLen( font, pText, length, NULL, FONT_DRAW_UTF8 | FONT_DRAW_HUD );
|
||||
@@ -2006,7 +1985,7 @@ static int GAME_EXPORT pfnGetWindowCenterX( void )
|
||||
{
|
||||
int x = 0;
|
||||
#if XASH_WIN32
|
||||
if( m_ignore.value )
|
||||
if( m_ignore->value )
|
||||
{
|
||||
POINT pos;
|
||||
GetCursorPos( &pos );
|
||||
@@ -2031,7 +2010,7 @@ static int GAME_EXPORT pfnGetWindowCenterY( void )
|
||||
{
|
||||
int y = 0;
|
||||
#if XASH_WIN32
|
||||
if( m_ignore.value )
|
||||
if( m_ignore->value )
|
||||
{
|
||||
POINT pos;
|
||||
GetCursorPos( &pos );
|
||||
@@ -2143,7 +2122,7 @@ pfnCalcShake
|
||||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT pfnCalcShake( void )
|
||||
void GAME_EXPORT pfnCalcShake( void )
|
||||
{
|
||||
screen_shake_t *const shake = &clgame.shake;
|
||||
float frametime, fraction, freq;
|
||||
@@ -2199,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 )
|
||||
VectorMA( origin, factor, clgame.shake.applied_offset, origin );
|
||||
@@ -2327,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 );
|
||||
}
|
||||
@@ -2338,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];
|
||||
static float lasttimewarn;
|
||||
@@ -2375,7 +2354,7 @@ pfnIsLocal
|
||||
|
||||
=============
|
||||
*/
|
||||
static int GAME_EXPORT pfnIsLocal( int playernum )
|
||||
int GAME_EXPORT pfnIsLocal( int playernum )
|
||||
{
|
||||
if( playernum == cl.playernum )
|
||||
return true;
|
||||
@@ -2388,7 +2367,7 @@ pfnLocalPlayerDucking
|
||||
|
||||
=============
|
||||
*/
|
||||
static int GAME_EXPORT pfnLocalPlayerDucking( void )
|
||||
int GAME_EXPORT pfnLocalPlayerDucking( void )
|
||||
{
|
||||
return (cl.local.usehull == 1) ? true : false;
|
||||
}
|
||||
@@ -2399,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 );
|
||||
}
|
||||
@@ -2410,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 )
|
||||
{
|
||||
@@ -2425,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( pTrace->ent >= 0 && pTrace->ent < clgame.pmove->numphysent )
|
||||
@@ -2460,7 +2439,7 @@ pfnGetVisent
|
||||
|
||||
=============
|
||||
*/
|
||||
static physent_t *pfnGetVisent( int idx )
|
||||
physent_t *pfnGetVisent( int idx )
|
||||
{
|
||||
if( idx >= 0 && idx < clgame.pmove->numvisent )
|
||||
{
|
||||
@@ -2476,7 +2455,7 @@ pfnSetTraceHull
|
||||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT CL_SetTraceHull( int hull )
|
||||
void GAME_EXPORT CL_SetTraceHull( int hull )
|
||||
{
|
||||
clgame.pmove->usehull = bound( 0, hull, 3 );
|
||||
}
|
||||
@@ -2487,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;
|
||||
*tr = PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, ignore_pe, NULL );
|
||||
@@ -2499,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;
|
||||
*tr = PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, -1, pfnIgnore );
|
||||
@@ -2544,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 );
|
||||
}
|
||||
@@ -2569,7 +2548,7 @@ model_t *CL_LoadModel( const char *modelname, int *index )
|
||||
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;
|
||||
|
||||
@@ -2586,7 +2565,7 @@ pfnGetGameDirectory
|
||||
|
||||
=============
|
||||
*/
|
||||
static const char *pfnGetGameDirectory( void )
|
||||
const char *pfnGetGameDirectory( void )
|
||||
{
|
||||
static char szGetGameDir[MAX_SYSPATH];
|
||||
|
||||
@@ -2600,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 ));
|
||||
}
|
||||
@@ -2631,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;
|
||||
}
|
||||
@@ -2653,7 +2632,7 @@ pfnLoadMapSprite
|
||||
|
||||
=============
|
||||
*/
|
||||
static model_t *pfnLoadMapSprite( const char *filename )
|
||||
model_t *pfnLoadMapSprite( const char *filename )
|
||||
{
|
||||
model_t *mod;
|
||||
|
||||
@@ -2671,7 +2650,7 @@ PlayerInfo_ValueForKey
|
||||
|
||||
=============
|
||||
*/
|
||||
static const char *PlayerInfo_ValueForKey( int playerNum, const char *key )
|
||||
const char *PlayerInfo_ValueForKey( int playerNum, const char *key )
|
||||
{
|
||||
// find the player
|
||||
if(( playerNum > cl.maxclients ) || ( playerNum < 1 ))
|
||||
@@ -2689,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;
|
||||
|
||||
@@ -2715,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 )
|
||||
return false;
|
||||
@@ -2735,7 +2714,7 @@ pfnGetTrackerIDForPlayer
|
||||
obsolete, unused
|
||||
=============
|
||||
*/
|
||||
static int GAME_EXPORT pfnGetTrackerIDForPlayer( int playerSlot )
|
||||
int GAME_EXPORT pfnGetTrackerIDForPlayer( int playerSlot )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -2747,7 +2726,7 @@ pfnGetPlayerForTrackerID
|
||||
obsolete, unused
|
||||
=============
|
||||
*/
|
||||
static int GAME_EXPORT pfnGetPlayerForTrackerID( int trackerID )
|
||||
int GAME_EXPORT pfnGetPlayerForTrackerID( int trackerID )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -2758,7 +2737,7 @@ pfnServerCmdUnreliable
|
||||
|
||||
=============
|
||||
*/
|
||||
static int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString )
|
||||
int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString )
|
||||
{
|
||||
if( !COM_CheckString( szCmdString ))
|
||||
return 0;
|
||||
@@ -2775,7 +2754,7 @@ pfnGetMousePos
|
||||
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt )
|
||||
void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt )
|
||||
{
|
||||
if( !ppt )
|
||||
return;
|
||||
@@ -2790,7 +2769,7 @@ pfnSetMouseEnable
|
||||
legacy of dinput code
|
||||
=============
|
||||
*/
|
||||
static void GAME_EXPORT pfnSetMouseEnable( qboolean fEnable )
|
||||
void GAME_EXPORT pfnSetMouseEnable( qboolean fEnable )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2909,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 };
|
||||
int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF;
|
||||
|
||||
if( hud_utf8.value )
|
||||
if( hud_utf8->value )
|
||||
SetBits( flags, FONT_DRAW_UTF8 );
|
||||
|
||||
return CL_DrawString( x, y, str, color, &cls.creditsFont, flags );
|
||||
@@ -2927,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 width;
|
||||
|
||||
if( hud_utf8.value )
|
||||
if( hud_utf8->value )
|
||||
SetBits( flags, FONT_DRAW_UTF8 );
|
||||
|
||||
CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags );
|
||||
@@ -3004,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;
|
||||
|
||||
@@ -3066,7 +3045,7 @@ pfnParseFile
|
||||
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 );
|
||||
}
|
||||
@@ -3287,7 +3266,7 @@ NetAPI_InitNetworking
|
||||
|
||||
=================
|
||||
*/
|
||||
static void GAME_EXPORT NetAPI_InitNetworking( void )
|
||||
void GAME_EXPORT NetAPI_InitNetworking( void )
|
||||
{
|
||||
NET_Config( true, false ); // allow remote
|
||||
}
|
||||
@@ -3298,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;
|
||||
int packet_loss = 0;
|
||||
@@ -3317,7 +3296,7 @@ static void GAME_EXPORT NetAPI_Status( net_status_t *status )
|
||||
status->remote_address = cls.netchan.remote_address;
|
||||
status->packet_loss = packet_loss;
|
||||
status->local_address = net_local;
|
||||
status->rate = rate.value;
|
||||
status->rate = rate->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3326,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;
|
||||
string req;
|
||||
@@ -3341,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 )
|
||||
return; // IPX no longer support
|
||||
|
||||
if( request == NETAPI_REQUEST_SERVERLIST )
|
||||
return; // no support for server list requests
|
||||
|
||||
// find a free request
|
||||
for( i = 0; i < MAX_REQUESTS; i++ )
|
||||
{
|
||||
@@ -3380,9 +3356,28 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
|
||||
nr->resp.remote_address = *remote_address;
|
||||
nr->flags = flags;
|
||||
|
||||
// local servers request
|
||||
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req );
|
||||
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
|
||||
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3391,7 +3386,7 @@ NetAPI_CancelRequest
|
||||
|
||||
=================
|
||||
*/
|
||||
static void GAME_EXPORT NetAPI_CancelRequest( int context )
|
||||
void GAME_EXPORT NetAPI_CancelRequest( int context )
|
||||
{
|
||||
net_request_t *nr;
|
||||
int i;
|
||||
@@ -3410,6 +3405,13 @@ static void GAME_EXPORT NetAPI_CancelRequest( int context )
|
||||
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 ));
|
||||
break;
|
||||
}
|
||||
@@ -3438,6 +3440,8 @@ void GAME_EXPORT NetAPI_CancelAllRequests( void )
|
||||
}
|
||||
|
||||
memset( clgame.net_requests, 0, sizeof( clgame.net_requests ));
|
||||
clgame.request_type = NET_REQUEST_CANCEL;
|
||||
clgame.master_request = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3446,7 +3450,7 @@ NetAPI_AdrToString
|
||||
|
||||
=================
|
||||
*/
|
||||
static const char *NetAPI_AdrToString( netadr_t *a )
|
||||
const char *NetAPI_AdrToString( netadr_t *a )
|
||||
{
|
||||
return NET_AdrToString( *a );
|
||||
}
|
||||
@@ -3457,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 );
|
||||
}
|
||||
@@ -3468,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 );
|
||||
}
|
||||
@@ -3479,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 );
|
||||
}
|
||||
@@ -3490,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 );
|
||||
}
|
||||
@@ -3501,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;
|
||||
Info_SetValueForStarKey( s, key, value, maxsize );
|
||||
@@ -3521,7 +3525,7 @@ Voice_StartVoiceTweakMode
|
||||
|
||||
=================
|
||||
*/
|
||||
static int GAME_EXPORT Voice_StartVoiceTweakMode( void )
|
||||
int GAME_EXPORT Voice_StartVoiceTweakMode( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -3532,7 +3536,7 @@ Voice_EndVoiceTweakMode
|
||||
|
||||
=================
|
||||
*/
|
||||
static void GAME_EXPORT Voice_EndVoiceTweakMode( void )
|
||||
void GAME_EXPORT Voice_EndVoiceTweakMode( void )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3542,7 +3546,7 @@ Voice_SetControlFloat
|
||||
|
||||
=================
|
||||
*/
|
||||
static void GAME_EXPORT Voice_SetControlFloat( VoiceTweakControl iControl, float value )
|
||||
void GAME_EXPORT Voice_SetControlFloat( VoiceTweakControl iControl, float value )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3552,7 +3556,7 @@ Voice_GetControlFloat
|
||||
|
||||
=================
|
||||
*/
|
||||
static float GAME_EXPORT Voice_GetControlFloat( VoiceTweakControl iControl )
|
||||
float GAME_EXPORT Voice_GetControlFloat( VoiceTweakControl iControl )
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
@@ -3870,13 +3874,13 @@ void CL_UnloadProgs( void )
|
||||
Cvar_FullSet( "cl_background", "0", FCVAR_READ_ONLY );
|
||||
Cvar_FullSet( "host_clientloaded", "0", FCVAR_READ_ONLY );
|
||||
|
||||
Cvar_Unlink( FCVAR_CLIENTDLL );
|
||||
Cmd_Unlink( CMD_CLIENTDLL );
|
||||
|
||||
COM_FreeLibrary( clgame.hInstance );
|
||||
Mem_FreePool( &cls.mempool );
|
||||
Mem_FreePool( &clgame.mempool );
|
||||
memset( &clgame, 0, sizeof( clgame ));
|
||||
|
||||
Cvar_Unlink( FCVAR_CLIENTDLL );
|
||||
Cmd_Unlink( CMD_CLIENTDLL );
|
||||
}
|
||||
|
||||
qboolean CL_LoadProgs( const char *name )
|
||||
@@ -3918,7 +3922,7 @@ qboolean CL_LoadProgs( const char *name )
|
||||
// during LoadLibrary
|
||||
if( !GI->internal_vgui_support && VGui_LoadProgs( NULL ))
|
||||
{
|
||||
VGui_Startup( refState.width, refState.height );
|
||||
VGui_Startup( NULL, refState.width, refState.height );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3934,7 +3938,8 @@ qboolean CL_LoadProgs( const char *name )
|
||||
// delayed vgui initialization for internal support
|
||||
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
|
||||
@@ -4017,6 +4022,9 @@ qboolean CL_LoadProgs( const char *name )
|
||||
return false;
|
||||
}
|
||||
|
||||
// try to load VGUI2
|
||||
VGui_Startup( clgame.hInstance, refState.width, refState.height );
|
||||
|
||||
Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY );
|
||||
|
||||
clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts();
|
||||
@@ -4034,7 +4042,7 @@ qboolean CL_LoadProgs( const char *name )
|
||||
if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
|
||||
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
|
||||
|
||||
// initialize game
|
||||
|
||||
@@ -414,15 +414,11 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
|
||||
out->gamemode = in->gamemode;
|
||||
|
||||
if( in->nomodels )
|
||||
SetBits( out->flags, GFL_NOMODELS );
|
||||
out->flags |= GFL_NOMODELS;
|
||||
if( in->noskills )
|
||||
SetBits( out->flags, GFL_NOSKILLS );
|
||||
out->flags |= GFL_NOSKILLS;
|
||||
if( in->render_picbutton_text )
|
||||
SetBits( 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 );
|
||||
out->flags |= GFL_RENDER_PICBUTTON_TEXT;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
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
|
||||
@@ -986,21 +971,28 @@ pfnCheckGameDll
|
||||
*/
|
||||
int GAME_EXPORT pfnCheckGameDll( void )
|
||||
{
|
||||
#ifdef XASH_INTERNAL_GAMELIBS
|
||||
return true;
|
||||
#else
|
||||
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 )
|
||||
return true;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
Con_Reportf( S_WARN "Could not load server library: %s\n", COM_GetLibraryError() );
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1226,12 +1218,12 @@ void UI_UnloadProgs( void )
|
||||
|
||||
Cvar_FullSet( "host_gameuiloaded", "0", FCVAR_READ_ONLY );
|
||||
|
||||
Cvar_Unlink( FCVAR_GAMEUIDLL );
|
||||
Cmd_Unlink( CMD_GAMEUIDLL );
|
||||
|
||||
COM_FreeLibrary( gameui.hInstance );
|
||||
Mem_FreePool( &gameui.mempool );
|
||||
memset( &gameui, 0, sizeof( gameui ));
|
||||
|
||||
Cvar_Unlink( FCVAR_GAMEUIDLL );
|
||||
Cmd_Unlink( CMD_GAMEUIDLL );
|
||||
}
|
||||
|
||||
qboolean UI_LoadProgs( void )
|
||||
|
||||
@@ -23,6 +23,7 @@ GNU General Public License for more details.
|
||||
#include "library.h"
|
||||
#include "vid_common.h"
|
||||
#include "pm_local.h"
|
||||
#include "sequence.h"
|
||||
|
||||
#define MAX_TOTAL_CMDS 32
|
||||
#define MAX_CMD_BUFFER 8000
|
||||
@@ -34,65 +35,62 @@ GNU General Public License for more details.
|
||||
CVAR_DEFINE_AUTO( mp_decals, "300", FCVAR_ARCHIVE, "decals limit in multiplayer" );
|
||||
CVAR_DEFINE_AUTO( dev_overview, "0", 0, "draw level in overview-mode" );
|
||||
CVAR_DEFINE_AUTO( cl_resend, "6.0", 0, "time to resend connect" );
|
||||
CVAR_DEFINE( cl_allow_download, "cl_allowdownload", "1", FCVAR_ARCHIVE, "allow to downloading resources from the server" );
|
||||
CVAR_DEFINE_AUTO( cl_allow_download, "1", FCVAR_ARCHIVE, "allow to downloading resources from the server" );
|
||||
CVAR_DEFINE_AUTO( cl_allow_upload, "1", FCVAR_ARCHIVE, "allow to uploading resources to the server" );
|
||||
CVAR_DEFINE_AUTO( cl_download_ingame, "1", FCVAR_ARCHIVE, "allow to downloading resources while client is active" );
|
||||
CVAR_DEFINE_AUTO( cl_logofile, "lambda", FCVAR_ARCHIVE, "player logo name" );
|
||||
CVAR_DEFINE_AUTO( cl_logocolor, "orange", FCVAR_ARCHIVE, "player logo color" );
|
||||
CVAR_DEFINE_AUTO( cl_logoext, "bmp", FCVAR_ARCHIVE, "temporary cvar to tell engine which logo must be packed" );
|
||||
CVAR_DEFINE_AUTO( cl_test_bandwidth, "1", FCVAR_ARCHIVE, "test network bandwith before connection" );
|
||||
convar_t *rcon_address;
|
||||
convar_t *cl_timeout;
|
||||
convar_t *cl_nopred;
|
||||
convar_t *cl_nodelta;
|
||||
convar_t *cl_crosshair;
|
||||
convar_t *cl_cmdbackup;
|
||||
convar_t *cl_showerror;
|
||||
convar_t *cl_bmodelinterp;
|
||||
convar_t *cl_draw_particles;
|
||||
convar_t *cl_draw_tracers;
|
||||
convar_t *cl_lightstyle_lerping;
|
||||
convar_t *cl_idealpitchscale;
|
||||
convar_t *cl_nosmooth;
|
||||
convar_t *cl_smoothtime;
|
||||
convar_t *cl_clockreset;
|
||||
convar_t *cl_fixtimerate;
|
||||
convar_t *hud_fontscale;
|
||||
convar_t *hud_scale;
|
||||
convar_t *cl_solid_players;
|
||||
convar_t *cl_draw_beams;
|
||||
convar_t *cl_updaterate;
|
||||
convar_t *cl_showevents;
|
||||
convar_t *cl_cmdrate;
|
||||
convar_t *cl_interp;
|
||||
convar_t *cl_nointerp;
|
||||
convar_t *cl_dlmax;
|
||||
convar_t *cl_upmax;
|
||||
|
||||
CVAR_DEFINE( cl_draw_particles, "r_drawparticles", "1", FCVAR_CHEAT, "render particles" );
|
||||
CVAR_DEFINE( cl_draw_tracers, "r_drawtracers", "1", FCVAR_CHEAT, "render tracers" );
|
||||
CVAR_DEFINE( cl_draw_beams, "r_drawbeams", "1", FCVAR_CHEAT, "render beams" );
|
||||
|
||||
static CVAR_DEFINE_AUTO( rcon_address, "", FCVAR_PRIVILEGED, "remote control address" );
|
||||
CVAR_DEFINE_AUTO( cl_timeout, "60", 0, "connect timeout (in-seconds)" );
|
||||
CVAR_DEFINE_AUTO( cl_nopred, "0", FCVAR_ARCHIVE|FCVAR_USERINFO, "disable client movement prediction" );
|
||||
CVAR_DEFINE_AUTO( cl_nodelta, "0", 0, "disable delta-compression for server messages" );
|
||||
CVAR_DEFINE( cl_crosshair, "crosshair", "1", FCVAR_ARCHIVE, "show weapon chrosshair" );
|
||||
static CVAR_DEFINE_AUTO( cl_cmdbackup, "10", FCVAR_ARCHIVE, "how many additional history commands are sent" );
|
||||
CVAR_DEFINE_AUTO( cl_showerror, "0", FCVAR_ARCHIVE, "show prediction error" );
|
||||
CVAR_DEFINE_AUTO( cl_bmodelinterp, "1", FCVAR_ARCHIVE, "enable bmodel interpolation" );
|
||||
CVAR_DEFINE_AUTO( cl_lightstyle_lerping, "0", FCVAR_ARCHIVE, "enables animated light lerping (perfomance option)" );
|
||||
CVAR_DEFINE_AUTO( cl_idealpitchscale, "0.8", 0, "how much to look up/down slopes and stairs when not using freelook" );
|
||||
CVAR_DEFINE_AUTO( cl_nosmooth, "0", FCVAR_ARCHIVE, "disable smooth up stair climbing" );
|
||||
CVAR_DEFINE_AUTO( cl_smoothtime, "0.1", FCVAR_ARCHIVE, "time to smooth up" );
|
||||
CVAR_DEFINE_AUTO( cl_clockreset, "0.1", FCVAR_ARCHIVE, "frametime delta maximum value before reset" );
|
||||
CVAR_DEFINE_AUTO( cl_fixtimerate, "7.5", FCVAR_ARCHIVE, "time in msec to client clock adjusting" );
|
||||
CVAR_DEFINE_AUTO( hud_fontscale, "1.0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud font texture" );
|
||||
CVAR_DEFINE_AUTO( hud_scale, "0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud at current resolution" );
|
||||
CVAR_DEFINE_AUTO( cl_solid_players, "1", 0, "Make all players not solid (can't traceline them)" );
|
||||
CVAR_DEFINE_AUTO( cl_updaterate, "20", FCVAR_USERINFO|FCVAR_ARCHIVE, "refresh rate of server messages" );
|
||||
CVAR_DEFINE_AUTO( cl_showevents, "0", FCVAR_ARCHIVE, "show events playback" );
|
||||
CVAR_DEFINE_AUTO( cl_cmdrate, "60", FCVAR_ARCHIVE, "Max number of command packets sent to server per second" );
|
||||
CVAR_DEFINE( cl_interp, "ex_interp", "0.1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "Interpolate object positions starting this many seconds in past" );
|
||||
CVAR_DEFINE_AUTO( cl_nointerp, "0", FCVAR_CLIENTDLL, "disable interpolation of entities and players" );
|
||||
static CVAR_DEFINE_AUTO( cl_dlmax, "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "max allowed outcoming fragment size" );
|
||||
static CVAR_DEFINE_AUTO( cl_upmax, "1200", FCVAR_ARCHIVE, "max allowed incoming fragment size" );
|
||||
|
||||
CVAR_DEFINE_AUTO( cl_lw, "1", FCVAR_ARCHIVE|FCVAR_USERINFO, "enable client weapon predicting" );
|
||||
CVAR_DEFINE_AUTO( cl_charset, "utf-8", FCVAR_ARCHIVE, "1-byte charset to use (iconv style)" );
|
||||
CVAR_DEFINE_AUTO( cl_trace_messages, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable message names tracing (good for developers)");
|
||||
CVAR_DEFINE_AUTO( cl_trace_events, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable events tracing (good for developers)");
|
||||
static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" );
|
||||
CVAR_DEFINE_AUTO( hud_utf8, "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" );
|
||||
CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is visible" );
|
||||
convar_t *cl_lw;
|
||||
convar_t *cl_charset;
|
||||
convar_t *cl_trace_messages;
|
||||
convar_t *cl_nat;
|
||||
convar_t *hud_utf8;
|
||||
convar_t *ui_renderworld;
|
||||
|
||||
//
|
||||
// userinfo
|
||||
//
|
||||
static CVAR_DEFINE_AUTO( name, "player", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_PRINTABLEONLY|FCVAR_FILTERABLE, "player name" );
|
||||
static CVAR_DEFINE_AUTO( model, "", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player model ('player' is a singleplayer model)" );
|
||||
static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player top color" );
|
||||
static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player bottom color" );
|
||||
CVAR_DEFINE_AUTO( rate, "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
|
||||
convar_t *name;
|
||||
convar_t *model;
|
||||
convar_t *topcolor;
|
||||
convar_t *bottomcolor;
|
||||
convar_t *rate;
|
||||
|
||||
client_t cl;
|
||||
client_static_t cls;
|
||||
clgame_static_t clgame;
|
||||
|
||||
static void CL_SendMasterServerScanRequest( void );
|
||||
void CL_InternetServers_f( void );
|
||||
|
||||
//======================================================================
|
||||
int GAME_EXPORT CL_Active( void )
|
||||
@@ -205,7 +203,7 @@ int CL_GetFragmentSize( void *unused, fragsize_t mode )
|
||||
if( Netchan_IsLocal( &cls.netchan ))
|
||||
return FRAGMENT_LOCAL_SIZE;
|
||||
|
||||
return cl_upmax.value;
|
||||
return cl_upmax->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -232,6 +230,9 @@ void CL_SignonReply( void )
|
||||
if( cl.proxy_redirect && !cls.spectator )
|
||||
CL_Disconnect();
|
||||
cl.proxy_redirect = false;
|
||||
|
||||
if( cls.demoplayback )
|
||||
Sequence_OnLevelLoad( clgame.mapname );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -261,10 +262,10 @@ static float CL_LerpPoint( void )
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
if( cl_interp.value <= 0.001 )
|
||||
if( cl_interp->value <= 0.001 )
|
||||
return 1.0f;
|
||||
|
||||
frac = ( cl.time - cl.mtime[0] ) / cl_interp.value;
|
||||
frac = ( cl.time - cl.mtime[0] ) / cl_interp->value;
|
||||
|
||||
return frac;
|
||||
}
|
||||
@@ -311,13 +312,13 @@ void CL_ComputeClientInterpolationAmount( usercmd_t *cmd )
|
||||
float max_interp = MAX_EX_INTERP;
|
||||
float interpolation_time;
|
||||
|
||||
if( cl_updaterate.value < MIN_UPDATERATE )
|
||||
if( cl_updaterate->value < MIN_UPDATERATE )
|
||||
{
|
||||
Con_Printf( "cl_updaterate minimum is %f, resetting to default (20)\n", MIN_UPDATERATE );
|
||||
Cvar_Reset( "cl_updaterate" );
|
||||
}
|
||||
|
||||
if( cl_updaterate.value > MAX_UPDATERATE )
|
||||
if( cl_updaterate->value > MAX_UPDATERATE )
|
||||
{
|
||||
Con_Printf( "cl_updaterate clamped at maximum (%f)\n", MAX_UPDATERATE );
|
||||
Cvar_SetValue( "cl_updaterate", MAX_UPDATERATE );
|
||||
@@ -326,15 +327,15 @@ void CL_ComputeClientInterpolationAmount( usercmd_t *cmd )
|
||||
if( cls.spectator )
|
||||
max_interp = 0.2f;
|
||||
|
||||
min_interp = 1.0f / cl_updaterate.value;
|
||||
interpolation_time = cl_interp.value * 1000.0;
|
||||
min_interp = 1.0f / cl_updaterate->value;
|
||||
interpolation_time = cl_interp->value * 1000.0;
|
||||
|
||||
if( (cl_interp.value + epsilon) < min_interp )
|
||||
if( (cl_interp->value + epsilon) < min_interp )
|
||||
{
|
||||
Con_Printf( "ex_interp forced up to %.1f msec\n", min_interp * 1000.f );
|
||||
Cvar_SetValue( "ex_interp", min_interp );
|
||||
}
|
||||
else if( (cl_interp.value - epsilon) > max_interp )
|
||||
else if( (cl_interp->value - epsilon) > max_interp )
|
||||
{
|
||||
Con_Printf( "ex_interp forced down to %.1f msec\n", max_interp * 1000.f );
|
||||
Cvar_SetValue( "ex_interp", max_interp );
|
||||
@@ -479,7 +480,7 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
|
||||
int changed;
|
||||
int pressed, released;
|
||||
|
||||
if( !r_showtextures.value || CL_IsDevOverviewMode( ))
|
||||
if( !gl_showtextures->value || CL_IsDevOverviewMode( ))
|
||||
return false;
|
||||
|
||||
changed = (oldbuttons ^ cmd->buttons);
|
||||
@@ -487,9 +488,9 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
|
||||
released = changed & (~cmd->buttons);
|
||||
|
||||
if( released & ( IN_RIGHT|IN_MOVERIGHT ))
|
||||
Cvar_SetValue( "r_showtextures", r_showtextures.value + 1 );
|
||||
Cvar_SetValue( "r_showtextures", gl_showtextures->value + 1 );
|
||||
if( released & ( IN_LEFT|IN_MOVELEFT ))
|
||||
Cvar_SetValue( "r_showtextures", Q_max( 1, r_showtextures.value - 1 ));
|
||||
Cvar_SetValue( "r_showtextures", Q_max( 1, gl_showtextures->value - 1 ));
|
||||
oldbuttons = cmd->buttons;
|
||||
|
||||
return true;
|
||||
@@ -510,7 +511,7 @@ qboolean CL_ProcessOverviewCmds( usercmd_t *cmd )
|
||||
float step = (2.0f / size) * host.realframetime;
|
||||
float step2 = step * 100.0f * (2.0f / ov->flZoom);
|
||||
|
||||
if( !CL_IsDevOverviewMode() || r_showtextures.value )
|
||||
if( !CL_IsDevOverviewMode() || gl_showtextures->value )
|
||||
return false;
|
||||
|
||||
if( ov->flZoom < 0.0f ) sign = -1;
|
||||
@@ -706,24 +707,24 @@ void CL_WritePacket( void )
|
||||
MSG_Init( &buf, "ClientData", data, sizeof( data ));
|
||||
|
||||
// Determine number of backup commands to send along
|
||||
numbackup = bound( 0, cl_cmdbackup.value, cls.legacymode ? MAX_LEGACY_BACKUP_CMDS : MAX_BACKUP_COMMANDS );
|
||||
numbackup = bound( 0, cl_cmdbackup->value, cls.legacymode ? MAX_LEGACY_BACKUP_CMDS : MAX_BACKUP_COMMANDS );
|
||||
if( cls.state == ca_connected ) numbackup = 0;
|
||||
|
||||
// clamp cmdrate
|
||||
if( cl_cmdrate.value < 10.0f )
|
||||
if( cl_cmdrate->value < 10.0f )
|
||||
{
|
||||
Cvar_DirectSet( &cl_cmdrate, "10" );
|
||||
Cvar_SetValue( "cl_cmdrate", 10.0f );
|
||||
}
|
||||
else if( cl_cmdrate.value > 100.0f )
|
||||
else if( cl_cmdrate->value > 100.0f )
|
||||
{
|
||||
Cvar_DirectSet( &cl_cmdrate, "100" );
|
||||
Cvar_SetValue( "cl_cmdrate", 100.0f );
|
||||
}
|
||||
|
||||
// Check to see if we can actually send this command
|
||||
|
||||
// In single player, send commands as fast as possible
|
||||
// Otherwise, only send when ready and when not choking bandwidth
|
||||
if( cl.maxclients == 1 || ( NET_IsLocalAddress( cls.netchan.remote_address ) && !host_limitlocal.value ))
|
||||
if( cl.maxclients == 1 || ( NET_IsLocalAddress( cls.netchan.remote_address ) && !host_limitlocal->value ))
|
||||
send_command = true;
|
||||
|
||||
if(( host.realtime >= cls.nextcmdtime ) && Netchan_CanPacket( &cls.netchan, true ))
|
||||
@@ -747,20 +748,20 @@ void CL_WritePacket( void )
|
||||
if(( host.realtime - cls.netchan.last_received ) > CONNECTION_PROBLEM_TIME )
|
||||
{
|
||||
Con_NPrintf( 1, "^3Warning:^1 Connection Problem^7\n" );
|
||||
Con_NPrintf( 2, "^1Auto-disconnect in %.1f seconds^7", cl_timeout.value - ( host.realtime - cls.netchan.last_received ));
|
||||
Con_NPrintf( 2, "^1Auto-disconnect in %.1f seconds^7", cl_timeout->value - ( host.realtime - cls.netchan.last_received ));
|
||||
cl.validsequence = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( cl_nodelta.value )
|
||||
if( cl_nodelta->value )
|
||||
cl.validsequence = 0;
|
||||
|
||||
if( send_command )
|
||||
{
|
||||
int outgoing_sequence;
|
||||
|
||||
if( cl_cmdrate.value > 0 ) // clamped between 10 and 100 fps
|
||||
cls.nextcmdtime = host.realtime + bound( 0.1f, ( 1.0f / cl_cmdrate.value ), 0.01f );
|
||||
if( cl_cmdrate->value > 0 ) // clamped between 10 and 100 fps
|
||||
cls.nextcmdtime = host.realtime + bound( 0.1f, ( 1.0f / cl_cmdrate->value ), 0.01f );
|
||||
else cls.nextcmdtime = host.realtime; // always able to send right away
|
||||
|
||||
if( cls.lastoutgoingcommand == -1 )
|
||||
@@ -1032,10 +1033,10 @@ void CL_SendConnectPacket( void )
|
||||
if( cls.legacymode )
|
||||
{
|
||||
// set related userinfo keys
|
||||
if( cl_dlmax.value >= 40000 || cl_dlmax.value < 100 )
|
||||
if( cl_dlmax->value >= 40000 || cl_dlmax->value < 100 )
|
||||
Info_SetValueForKey( cls.userinfo, "cl_maxpacket", "1400", sizeof( cls.userinfo ) );
|
||||
else
|
||||
Info_SetValueForKey( cls.userinfo, "cl_maxpacket", cl_dlmax.string, sizeof( cls.userinfo ) );
|
||||
Info_SetValueForKey( cls.userinfo, "cl_maxpacket", cl_dlmax->string, sizeof( cls.userinfo ) );
|
||||
|
||||
if( !*Info_ValueForKey( cls.userinfo,"cl_maxpayload") )
|
||||
Info_SetValueForKey( cls.userinfo, "cl_maxpayload", "1000", sizeof( cls.userinfo ) );
|
||||
@@ -1050,7 +1051,7 @@ void CL_SendConnectPacket( void )
|
||||
{
|
||||
int extensions = NET_EXT_SPLITSIZE;
|
||||
|
||||
if( cl_dlmax.value > FRAGMENT_MAX_SIZE || cl_dlmax.value < FRAGMENT_MIN_SIZE )
|
||||
if( cl_dlmax->value > FRAGMENT_MAX_SIZE || cl_dlmax->value < FRAGMENT_MIN_SIZE )
|
||||
Cvar_SetValue( "cl_dlmax", FRAGMENT_DEFAULT_SIZE );
|
||||
|
||||
Info_RemoveKey( cls.userinfo, "cl_maxpacket" );
|
||||
@@ -1081,7 +1082,7 @@ void CL_CheckForResend( void )
|
||||
qboolean bandwidthTest;
|
||||
|
||||
if( cls.internetservers_wait )
|
||||
CL_SendMasterServerScanRequest();
|
||||
CL_InternetServers_f();
|
||||
|
||||
// if the local server is running and we aren't then connect
|
||||
if( cls.state == ca_disconnected && SV_Active( ))
|
||||
@@ -1245,7 +1246,7 @@ void CL_Connect_f( void )
|
||||
|
||||
// if running a local server, kill it and reissue
|
||||
if( SV_Active( )) Host_ShutdownServer();
|
||||
NET_Config( true, !cl_nat.value ); // allow remote
|
||||
NET_Config( true, !CVAR_TO_BOOL( cl_nat )); // allow remote
|
||||
|
||||
Con_Printf( "server %s\n", server );
|
||||
CL_Disconnect();
|
||||
@@ -1310,13 +1311,13 @@ void CL_Rcon_f( void )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !COM_CheckString( rcon_address.string ))
|
||||
if( !COM_CheckString( rcon_address->string ))
|
||||
{
|
||||
Con_Printf( "You must either be connected or set the 'rcon_address' cvar to issue rcon commands\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
NET_StringToAdr( rcon_address.string, &to );
|
||||
NET_StringToAdr( rcon_address->string, &to );
|
||||
if( to.port == 0 ) to.port = MSG_BigShort( PORT_SERVER );
|
||||
}
|
||||
|
||||
@@ -1409,12 +1410,12 @@ int CL_GetSplitSize( void )
|
||||
if( !(cls.extensions & NET_EXT_SPLITSIZE) )
|
||||
return 1400;
|
||||
|
||||
splitsize = cl_dlmax.value;
|
||||
splitsize = cl_dlmax->value;
|
||||
|
||||
if( splitsize < FRAGMENT_MIN_SIZE || splitsize > FRAGMENT_MAX_SIZE )
|
||||
Cvar_SetValue( "cl_dlmax", FRAGMENT_DEFAULT_SIZE );
|
||||
|
||||
return cl_dlmax.value;
|
||||
return cl_dlmax->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1438,7 +1439,7 @@ void CL_Reconnect( qboolean setup_netchan )
|
||||
{
|
||||
// only enable incoming split for legacy mode
|
||||
cls.netchan.split = true;
|
||||
Con_Reportf( "^2NET_EXT_SPLIT enabled^7 (packet sizes is %d/%d)\n", (int)cl_dlmax.value, 65536 );
|
||||
Con_Reportf( "^2NET_EXT_SPLIT enabled^7 (packet sizes is %d/%d)\n", (int)cl_dlmax->value, 65536 );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1447,7 +1448,7 @@ void CL_Reconnect( qboolean setup_netchan )
|
||||
|
||||
if( cls.extensions & NET_EXT_SPLITSIZE )
|
||||
{
|
||||
Con_Reportf( "^2NET_EXT_SPLITSIZE enabled^7 (packet size is %d)\n", (int)cl_dlmax.value );
|
||||
Con_Reportf( "^2NET_EXT_SPLITSIZE enabled^7 (packet size is %d)\n", (int)cl_dlmax->value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1555,8 +1556,6 @@ void CL_LocalServers_f( void )
|
||||
{
|
||||
netadr_t adr;
|
||||
|
||||
memset( &adr, 0, sizeof( adr ));
|
||||
|
||||
Con_Printf( "Scanning for servers on the local network area...\n" );
|
||||
NET_Config( true, true ); // allow remote
|
||||
|
||||
@@ -1574,10 +1573,10 @@ void CL_LocalServers_f( void )
|
||||
CL_BuildMasterServerScanRequest
|
||||
=================
|
||||
*/
|
||||
static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, uint32_t *key, qboolean nat, const char *filter )
|
||||
size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat )
|
||||
{
|
||||
size_t remaining;
|
||||
char *info, temp[32];
|
||||
char *info;
|
||||
|
||||
if( unlikely( size < sizeof( MS_SCAN_REQUEST )))
|
||||
return 0;
|
||||
@@ -1587,34 +1586,15 @@ static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, u
|
||||
info = buf + sizeof( MS_SCAN_REQUEST ) - 1;
|
||||
remaining = size - sizeof( MS_SCAN_REQUEST );
|
||||
|
||||
Q_strncpy( info, filter, remaining );
|
||||
info[0] = 0;
|
||||
|
||||
*key = COM_RandomLong( 0, 0x7FFFFFFF );
|
||||
|
||||
#ifndef XASH_ALL_SERVERS
|
||||
Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining );
|
||||
#endif
|
||||
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version
|
||||
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );
|
||||
|
||||
Q_snprintf( temp, sizeof( temp ), "%x", *key );
|
||||
Info_SetValueForKey( info, "key", temp, remaining );
|
||||
|
||||
return sizeof( MS_SCAN_REQUEST ) + Q_strlen( info );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_SendMasterServerScanRequest
|
||||
=================
|
||||
*/
|
||||
static void CL_SendMasterServerScanRequest( void )
|
||||
{
|
||||
cls.internetservers_wait = NET_SendToMasters( NS_CLIENT,
|
||||
cls.internetservers_query_len, cls.internetservers_query );
|
||||
cls.internetservers_pending = true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_InternetServers_f
|
||||
@@ -1622,24 +1602,26 @@ CL_InternetServers_f
|
||||
*/
|
||||
void CL_InternetServers_f( void )
|
||||
{
|
||||
qboolean nat = cl_nat.value != 0.0f;
|
||||
uint32_t key;
|
||||
char fullquery[512];
|
||||
size_t len;
|
||||
qboolean nat = cl_nat->value != 0.0f;
|
||||
|
||||
if( Cmd_Argc( ) > 2 || ( Cmd_Argc( ) == 2 && !Info_IsValid( Cmd_Argv( 1 ))))
|
||||
{
|
||||
Con_Printf( S_USAGE "internetservers [filter]\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
cls.internetservers_query_len = CL_BuildMasterServerScanRequest(
|
||||
cls.internetservers_query, sizeof( cls.internetservers_query ),
|
||||
&cls.internetservers_key, nat, Cmd_Argv( 1 ));
|
||||
len = CL_BuildMasterServerScanRequest( fullquery, sizeof( fullquery ), nat );
|
||||
|
||||
Con_Printf( "Scanning for servers on the internet area...\n" );
|
||||
|
||||
NET_Config( true, true ); // allow remote
|
||||
|
||||
CL_SendMasterServerScanRequest();
|
||||
cls.internetservers_wait = NET_SendToMasters( NS_CLIENT, len, fullquery );
|
||||
cls.internetservers_pending = true;
|
||||
|
||||
if( !cls.internetservers_wait )
|
||||
{
|
||||
// now we clearing the vgui request
|
||||
if( clgame.master_request != NULL )
|
||||
memset( clgame.master_request, 0, sizeof( net_request_t ));
|
||||
clgame.request_type = NET_REQUEST_GAMEUI;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2008,11 +1990,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
int realsize;
|
||||
dword crcValue2 = 0;
|
||||
|
||||
// this message only used during connection
|
||||
// it doesn't make sense after client_connect
|
||||
if( cls.state != ca_connecting )
|
||||
return;
|
||||
|
||||
if( !CL_IsFromConnectingServer( from ))
|
||||
return;
|
||||
|
||||
@@ -2076,11 +2053,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
}
|
||||
else if( !Q_strcmp( c, "challenge" ))
|
||||
{
|
||||
// this message only used during connection
|
||||
// it doesn't make sense after client_connect
|
||||
if( cls.state != ca_connecting )
|
||||
return;
|
||||
|
||||
if( !CL_IsFromConnectingServer( from ))
|
||||
return;
|
||||
|
||||
@@ -2099,11 +2071,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
}
|
||||
else if( !Q_strcmp( c, "disconnect" ))
|
||||
{
|
||||
// this message only used during connection
|
||||
// it doesn't make sense after client_connect
|
||||
if( cls.state != ca_connecting )
|
||||
return;
|
||||
|
||||
if( !CL_IsFromConnectingServer( from ))
|
||||
return;
|
||||
|
||||
@@ -2167,25 +2134,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
return;
|
||||
}
|
||||
|
||||
// check the extra header
|
||||
if( MSG_ReadByte( msg ) == 0x7f )
|
||||
{
|
||||
uint32_t key = MSG_ReadDword( msg );
|
||||
|
||||
if( cls.internetservers_key != key )
|
||||
{
|
||||
Con_Printf( S_WARN "unexpected server list packet from %s (invalid key)\n", NET_AdrToString( from ));
|
||||
return;
|
||||
}
|
||||
|
||||
MSG_ReadByte( msg ); // reserved byte
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( S_WARN "invalid server list packet from %s (missing extra header)\n", NET_AdrToString( from ));
|
||||
return;
|
||||
}
|
||||
|
||||
// serverlist got from masterserver
|
||||
while( MSG_GetNumBitsLeft( msg ) > 8 )
|
||||
{
|
||||
@@ -2195,10 +2143,58 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
|
||||
// list is ends here
|
||||
if( !servadr.port )
|
||||
break;
|
||||
{
|
||||
if( clgame.request_type == NET_REQUEST_CLIENT && clgame.master_request != NULL )
|
||||
{
|
||||
net_request_t *nr = clgame.master_request;
|
||||
net_adrlist_t *list, **prev;
|
||||
|
||||
NET_Config( true, false ); // allow remote
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION );
|
||||
// setup the answer
|
||||
nr->resp.remote_address = from;
|
||||
nr->resp.error = NET_SUCCESS;
|
||||
nr->resp.ping = host.realtime - nr->timesend;
|
||||
|
||||
if( nr->timeout <= host.realtime )
|
||||
SetBits( nr->resp.error, NET_ERROR_TIMEOUT );
|
||||
|
||||
Con_Printf( "serverlist call: %s\n", NET_AdrToString( from ));
|
||||
nr->pfnFunc( &nr->resp );
|
||||
|
||||
// throw the list, now it will be stored in user area
|
||||
prev = (net_adrlist_t**)&nr->resp.response;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
list = *prev;
|
||||
if( !list ) break;
|
||||
|
||||
// throw out any variables the game created
|
||||
*prev = list->next;
|
||||
Mem_Free( list );
|
||||
}
|
||||
memset( nr, 0, sizeof( *nr )); // done
|
||||
clgame.request_type = NET_REQUEST_CANCEL;
|
||||
clgame.master_request = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( clgame.request_type == NET_REQUEST_CLIENT && clgame.master_request != NULL )
|
||||
{
|
||||
net_request_t *nr = clgame.master_request;
|
||||
net_adrlist_t *list;
|
||||
|
||||
// adding addresses into list
|
||||
list = Z_Malloc( sizeof( *list ));
|
||||
list->remote_address = servadr;
|
||||
list->next = nr->resp.response;
|
||||
nr->resp.response = list;
|
||||
}
|
||||
else if( clgame.request_type == NET_REQUEST_GAMEUI )
|
||||
{
|
||||
NET_Config( true, false ); // allow remote
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION );
|
||||
}
|
||||
}
|
||||
|
||||
if( cls.internetservers_pending )
|
||||
@@ -2247,13 +2243,10 @@ void CL_ReadNetMessage( void )
|
||||
|
||||
while( CL_GetMessage( net_message_buffer, &curSize ))
|
||||
{
|
||||
const int split_header = LittleLong( 0xFFFFFFFE );
|
||||
if( cls.legacymode && !memcmp( &split_header, net_message_buffer, sizeof( split_header )))
|
||||
{
|
||||
if( cls.legacymode && *((int *)&net_message_buffer) == 0xFFFFFFFE )
|
||||
// Will rewrite existing packet by merged
|
||||
if( !NetSplit_GetLong( &cls.netchan.netsplit, &net_from, net_message_buffer, &curSize ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
MSG_Init( &net_message, "ServerData", net_message_buffer, curSize );
|
||||
|
||||
@@ -2330,7 +2323,7 @@ void CL_ReadPackets( void )
|
||||
// decide the simulation time
|
||||
cl.oldtime = cl.time;
|
||||
|
||||
if( !cl.paused )
|
||||
if( cls.demoplayback != DEMO_XASH3D && !cl.paused )
|
||||
cl.time += host.frametime;
|
||||
|
||||
// demo time
|
||||
@@ -2372,7 +2365,7 @@ void CL_ReadPackets( void )
|
||||
// check timeout
|
||||
if( cls.state >= ca_connected && cls.state != ca_cinematic && !cls.demoplayback )
|
||||
{
|
||||
if( host.realtime - cls.netchan.last_received > cl_timeout.value )
|
||||
if( host.realtime - cls.netchan.last_received > cl_timeout->value )
|
||||
{
|
||||
Con_Printf( "\nServer connection timed out.\n" );
|
||||
CL_Disconnect();
|
||||
@@ -2866,57 +2859,55 @@ void CL_InitLocal( void )
|
||||
VGui_RegisterCvars();
|
||||
|
||||
// register our variables
|
||||
Cvar_RegisterVariable( &cl_crosshair );
|
||||
Cvar_RegisterVariable( &cl_nodelta );
|
||||
Cvar_RegisterVariable( &cl_idealpitchscale );
|
||||
Cvar_RegisterVariable( &cl_solid_players );
|
||||
Cvar_RegisterVariable( &cl_interp );
|
||||
Cvar_RegisterVariable( &cl_timeout );
|
||||
Cvar_RegisterVariable( &cl_charset );
|
||||
Cvar_RegisterVariable( &hud_utf8 );
|
||||
cl_crosshair = Cvar_Get( "crosshair", "1", FCVAR_ARCHIVE, "show weapon chrosshair" );
|
||||
cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0, "disable delta-compression for server messages" );
|
||||
cl_idealpitchscale = Cvar_Get( "cl_idealpitchscale", "0.8", 0, "how much to look up/down slopes and stairs when not using freelook" );
|
||||
cl_solid_players = Cvar_Get( "cl_solid_players", "1", 0, "Make all players not solid (can't traceline them)" );
|
||||
cl_interp = Cvar_Get( "ex_interp", "0.1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "Interpolate object positions starting this many seconds in past" );
|
||||
cl_timeout = Cvar_Get( "cl_timeout", "60", 0, "connect timeout (in-seconds)" );
|
||||
cl_charset = Cvar_Get( "cl_charset", "utf-8", FCVAR_ARCHIVE, "1-byte charset to use (iconv style)" );
|
||||
hud_utf8 = Cvar_Get( "hud_utf8", "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" );
|
||||
|
||||
Cvar_RegisterVariable( &rcon_address );
|
||||
rcon_address = Cvar_Get( "rcon_address", "", FCVAR_PRIVILEGED, "remote control address" );
|
||||
|
||||
Cvar_RegisterVariable( &cl_trace_messages );
|
||||
Cvar_RegisterVariable( &cl_trace_events );
|
||||
cl_trace_messages = Cvar_Get( "cl_trace_messages", "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable message names tracing (good for developers)");
|
||||
|
||||
// userinfo
|
||||
Cvar_RegisterVariable( &cl_nopred );
|
||||
Cvar_RegisterVariable( &name );
|
||||
Cvar_DirectSet( &name, Sys_GetCurrentUser( ));
|
||||
Cvar_RegisterVariable( &model );
|
||||
Cvar_RegisterVariable( &cl_updaterate );
|
||||
Cvar_RegisterVariable( &cl_dlmax );
|
||||
Cvar_RegisterVariable( &cl_upmax );
|
||||
Cvar_RegisterVariable( &cl_nat );
|
||||
Cvar_RegisterVariable( &rate );
|
||||
Cvar_RegisterVariable( &topcolor );
|
||||
Cvar_RegisterVariable( &bottomcolor );
|
||||
Cvar_RegisterVariable( &cl_lw );
|
||||
cl_nopred = Cvar_Get( "cl_nopred", "0", FCVAR_ARCHIVE|FCVAR_USERINFO, "disable client movement prediction" );
|
||||
name = Cvar_Get( "name", Sys_GetCurrentUser(), FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_PRINTABLEONLY, "player name" );
|
||||
model = Cvar_Get( "model", "", FCVAR_USERINFO|FCVAR_ARCHIVE, "player model ('player' is a singleplayer model)" );
|
||||
cl_updaterate = Cvar_Get( "cl_updaterate", "20", FCVAR_USERINFO|FCVAR_ARCHIVE, "refresh rate of server messages" );
|
||||
cl_dlmax = Cvar_Get( "cl_dlmax", "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "max allowed outcoming fragment size" );
|
||||
cl_upmax = Cvar_Get( "cl_upmax", "1200", FCVAR_ARCHIVE, "max allowed incoming fragment size" );
|
||||
cl_nat = Cvar_Get( "cl_nat", "0", 0, "show servers running under NAT" );
|
||||
rate = Cvar_Get( "rate", "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
|
||||
topcolor = Cvar_Get( "topcolor", "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "player top color" );
|
||||
bottomcolor = Cvar_Get( "bottomcolor", "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "player bottom color" );
|
||||
cl_lw = Cvar_Get( "cl_lw", "1", FCVAR_ARCHIVE|FCVAR_USERINFO, "enable client weapon predicting" );
|
||||
Cvar_Get( "cl_lc", "1", FCVAR_ARCHIVE|FCVAR_USERINFO, "enable lag compensation" );
|
||||
Cvar_Get( "password", "", FCVAR_USERINFO, "server password" );
|
||||
Cvar_Get( "team", "", FCVAR_USERINFO, "player team" );
|
||||
Cvar_Get( "skin", "", FCVAR_USERINFO, "player skin" );
|
||||
|
||||
Cvar_RegisterVariable( &cl_nosmooth );
|
||||
Cvar_RegisterVariable( &cl_nointerp );
|
||||
Cvar_RegisterVariable( &cl_smoothtime );
|
||||
Cvar_RegisterVariable( &cl_cmdbackup );
|
||||
Cvar_RegisterVariable( &cl_cmdrate );
|
||||
Cvar_RegisterVariable( &cl_draw_particles );
|
||||
Cvar_RegisterVariable( &cl_draw_tracers );
|
||||
Cvar_RegisterVariable( &cl_draw_beams );
|
||||
Cvar_RegisterVariable( &cl_lightstyle_lerping );
|
||||
Cvar_RegisterVariable( &cl_showerror );
|
||||
Cvar_RegisterVariable( &cl_bmodelinterp );
|
||||
Cvar_RegisterVariable( &cl_clockreset );
|
||||
Cvar_RegisterVariable( &cl_fixtimerate );
|
||||
Cvar_RegisterVariable( &hud_fontscale );
|
||||
Cvar_RegisterVariable( &hud_scale );
|
||||
cl_nosmooth = Cvar_Get( "cl_nosmooth", "0", FCVAR_ARCHIVE, "disable smooth up stair climbing" );
|
||||
cl_nointerp = Cvar_Get( "cl_nointerp", "0", FCVAR_CLIENTDLL, "disable interpolation of entities and players" );
|
||||
cl_smoothtime = Cvar_Get( "cl_smoothtime", "0.1", FCVAR_ARCHIVE, "time to smooth up" );
|
||||
cl_cmdbackup = Cvar_Get( "cl_cmdbackup", "10", FCVAR_ARCHIVE, "how many additional history commands are sent" );
|
||||
cl_cmdrate = Cvar_Get( "cl_cmdrate", "60", FCVAR_ARCHIVE, "Max number of command packets sent to server per second" );
|
||||
cl_draw_particles = Cvar_Get( "r_drawparticles", "1", FCVAR_CHEAT, "render particles" );
|
||||
cl_draw_tracers = Cvar_Get( "r_drawtracers", "1", FCVAR_CHEAT, "render tracers" );
|
||||
cl_draw_beams = Cvar_Get( "r_drawbeams", "1", FCVAR_CHEAT, "render beams" );
|
||||
cl_lightstyle_lerping = Cvar_Get( "cl_lightstyle_lerping", "0", FCVAR_ARCHIVE, "enables animated light lerping (perfomance option)" );
|
||||
cl_showerror = Cvar_Get( "cl_showerror", "0", FCVAR_ARCHIVE, "show prediction error" );
|
||||
cl_bmodelinterp = Cvar_Get( "cl_bmodelinterp", "1", FCVAR_ARCHIVE, "enable bmodel interpolation" );
|
||||
cl_clockreset = Cvar_Get( "cl_clockreset", "0.1", FCVAR_ARCHIVE, "frametime delta maximum value before reset" );
|
||||
cl_fixtimerate = Cvar_Get( "cl_fixtimerate", "7.5", FCVAR_ARCHIVE, "time in msec to client clock adjusting" );
|
||||
hud_fontscale = Cvar_Get( "hud_fontscale", "1.0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud font texture" );
|
||||
hud_scale = Cvar_Get( "hud_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud at current resolution" );
|
||||
Cvar_Get( "cl_background", "0", FCVAR_READ_ONLY, "indicate what background map is running" );
|
||||
Cvar_RegisterVariable( &cl_showevents );
|
||||
cl_showevents = Cvar_Get( "cl_showevents", "0", FCVAR_ARCHIVE, "show events playback" );
|
||||
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );
|
||||
Cvar_RegisterVariable( &ui_renderworld );
|
||||
ui_renderworld = Cvar_Get( "ui_renderworld", "0", FCVAR_ARCHIVE, "render world when UI is visible" );
|
||||
|
||||
// these two added to shut up CS 1.5 about 'unknown' commands
|
||||
Cvar_Get( "lightgamma", "1", FCVAR_ARCHIVE, "ambient lighting level (legacy, unused)" );
|
||||
@@ -2996,10 +2987,10 @@ to smooth lag effect
|
||||
*/
|
||||
void CL_AdjustClock( void )
|
||||
{
|
||||
if( cl.timedelta == 0.0f || !cl_fixtimerate.value )
|
||||
if( cl.timedelta == 0.0f || !cl_fixtimerate->value )
|
||||
return;
|
||||
|
||||
if( cl_fixtimerate.value < 0.0f )
|
||||
if( cl_fixtimerate->value < 0.0f )
|
||||
Cvar_SetValue( "cl_fixtimerate", 7.5f );
|
||||
|
||||
if( fabs( cl.timedelta ) >= 0.001f )
|
||||
@@ -3009,7 +3000,7 @@ void CL_AdjustClock( void )
|
||||
|
||||
msec = ( cl.timedelta * 1000.0 );
|
||||
sign = ( msec < 0 ) ? 1.0 : -1.0;
|
||||
msec = Q_min( cl_fixtimerate.value, fabs( msec ));
|
||||
msec = Q_min( cl_fixtimerate->value, fabs( msec ));
|
||||
adjust = sign * ( msec / 1000.0 );
|
||||
|
||||
if( fabs( adjust ) < fabs( cl.timedelta ))
|
||||
@@ -3127,6 +3118,7 @@ void CL_Init( void )
|
||||
VID_Init(); // init video
|
||||
S_Init(); // init sound
|
||||
Voice_Init( VOICE_DEFAULT_CODEC, 3 ); // init voice
|
||||
Sequence_Init();
|
||||
|
||||
// unreliable buffer. unsed for unreliable commands and voice stream
|
||||
MSG_Init( &cls.datagram, "cls.datagram", cls.datagram_buf, sizeof( cls.datagram_buf ));
|
||||
|
||||
@@ -20,17 +20,17 @@ GNU General Public License for more details.
|
||||
#include "input.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" );
|
||||
static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" );
|
||||
convar_t *vibration_length;
|
||||
convar_t *vibration_enable;
|
||||
|
||||
static cl_font_t g_scaled_font;
|
||||
static float g_font_scale;
|
||||
|
||||
static void pfnVibrate( float life, char flags )
|
||||
{
|
||||
if( !vibration_enable.value )
|
||||
if( !vibration_enable->value )
|
||||
return;
|
||||
|
||||
if( life < 0.0f )
|
||||
@@ -42,7 +42,7 @@ static void pfnVibrate( float life, char flags )
|
||||
//Con_Reportf( "Vibrate: %f %d\n", life, flags );
|
||||
|
||||
// here goes platform-specific backends
|
||||
Platform_Vibrate( life * vibration_length.value, flags );
|
||||
Platform_Vibrate( life * vibration_length->value, flags );
|
||||
}
|
||||
|
||||
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 };
|
||||
int flags = FONT_DRAW_HUD;
|
||||
|
||||
if( hud_utf8.value )
|
||||
if( hud_utf8->value )
|
||||
SetBits( flags, FONT_DRAW_UTF8 );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
Touch_HideButtons( name, state, true );
|
||||
@@ -115,7 +124,7 @@ static mobile_engfuncs_t gpMobileEngfuncs =
|
||||
Touch_ResetDefaultButtons,
|
||||
pfnDrawScaledCharacter,
|
||||
Sys_Warn,
|
||||
Sys_GetNativeObject,
|
||||
pfnGetNativeObject,
|
||||
ID_SetCustomClientID,
|
||||
pfnParseFileSafe
|
||||
};
|
||||
@@ -133,8 +142,8 @@ qboolean Mobile_Init( void )
|
||||
success = true;
|
||||
|
||||
Cmd_AddCommand( "vibrate", (xcommand_t)Vibrate_f, "Vibrate for specified time");
|
||||
Cvar_RegisterVariable( &vibration_length );
|
||||
Cvar_RegisterVariable( &vibration_enable );
|
||||
vibration_length = Cvar_Get( "vibration_length", "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "Vibration length");
|
||||
vibration_enable = Cvar_Get( "vibration_enable", "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "Enable vibration");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ GNU General Public License for more details.
|
||||
#define NETGRAPH_NET_COLORS 5
|
||||
#define NUM_LATENCY_SAMPLES 8
|
||||
|
||||
CVAR_DEFINE_AUTO( net_graph, "0", FCVAR_ARCHIVE, "draw network usage graph" );
|
||||
static CVAR_DEFINE_AUTO( net_graphpos, "1", FCVAR_ARCHIVE, "network usage graph position" );
|
||||
static CVAR_DEFINE_AUTO( net_scale, "5", FCVAR_ARCHIVE, "network usage graph scale level" );
|
||||
static CVAR_DEFINE_AUTO( net_graphwidth, "192", FCVAR_ARCHIVE, "network usage graph width" );
|
||||
static CVAR_DEFINE_AUTO( net_graphheight, "64", FCVAR_ARCHIVE, "network usage graph height" );
|
||||
static CVAR_DEFINE_AUTO( net_graphsolid, "1", FCVAR_ARCHIVE, "fill segments in network usage graph" );
|
||||
convar_t *net_graph;
|
||||
static convar_t *net_graphpos;
|
||||
static convar_t *net_graphwidth;
|
||||
static convar_t *net_graphheight;
|
||||
static convar_t *net_graphsolid;
|
||||
static convar_t *net_scale;
|
||||
|
||||
static struct packet_latency_t
|
||||
{
|
||||
@@ -211,7 +211,7 @@ static void NetGraph_GetFrameData( float *latency, int *latency_count )
|
||||
else
|
||||
{
|
||||
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 )
|
||||
{
|
||||
@@ -260,7 +260,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
|
||||
for( a = 0; a < w; a++ )
|
||||
{
|
||||
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.right = fill.bottom = 1;
|
||||
@@ -273,7 +273,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
|
||||
h -= extrap_point;
|
||||
fill.top -= extrap_point;
|
||||
|
||||
if( !net_graphsolid.value )
|
||||
if( !net_graphsolid->value )
|
||||
{
|
||||
fill.top -= (h - 1);
|
||||
start = (h - 1);
|
||||
@@ -295,7 +295,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
|
||||
fill.top -= h;
|
||||
h = extrap_point - h;
|
||||
|
||||
if( !net_graphsolid.value )
|
||||
if( !net_graphsolid->value )
|
||||
h = 1;
|
||||
|
||||
for( j = 0; j < h; j++ )
|
||||
@@ -334,7 +334,7 @@ NetGraph_DrawHatches
|
||||
*/
|
||||
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 color[4] = { 0, 200, 0, 255 };
|
||||
wrect_t hatch = { x, 4, y, 1 };
|
||||
@@ -342,9 +342,9 @@ static void NetGraph_DrawHatches( int x, int y )
|
||||
|
||||
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 );
|
||||
}
|
||||
@@ -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 out, i = ( cls.netchan.outgoing_sequence - 1 ) & 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 )
|
||||
{
|
||||
avg = avg / (float)( count - ( host.frametime * FRAMERATE_AVG_FRAC ));
|
||||
|
||||
if( cl_updaterate.value > 0.0f )
|
||||
avg -= 1000.0f / cl_updaterate.value;
|
||||
if( cl_updaterate->value > 0.0f )
|
||||
avg -= 1000.0f / cl_updaterate->value;
|
||||
|
||||
// can't be below zero
|
||||
avg = Q_max( 0.0f, avg );
|
||||
@@ -391,7 +391,7 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
|
||||
|
||||
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);
|
||||
|
||||
@@ -422,9 +422,9 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
float h = bytes / net_scale.value;
|
||||
float h = bytes / net_scale->value;
|
||||
byte colors[4] = { r, g, b, a };
|
||||
|
||||
fill->top -= (int)h;
|
||||
|
||||
if( net_graphsolid.value )
|
||||
if( net_graphsolid->value )
|
||||
fill->bottom = (int)h;
|
||||
else fill->bottom = 1;
|
||||
|
||||
@@ -498,7 +498,7 @@ NetGraph_DrawDataUsage
|
||||
static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
|
||||
{
|
||||
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 };
|
||||
byte color[4];
|
||||
|
||||
@@ -554,7 +554,7 @@ static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
|
||||
continue;
|
||||
|
||||
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;
|
||||
|
||||
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 ))
|
||||
continue;
|
||||
|
||||
fill.top = y - net_graphheight.value - 1;
|
||||
fill.top = y - net_graphheight->value - 1;
|
||||
fill.bottom = 1;
|
||||
fill.top -= 2;
|
||||
|
||||
@@ -598,7 +598,7 @@ static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
|
||||
}
|
||||
|
||||
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->bottom = refState.height;
|
||||
|
||||
*w = Q_min( NET_TIMINGS, net_graphwidth.value );
|
||||
*w = Q_min( NET_TIMINGS, net_graphwidth->value );
|
||||
if( rect->right < *w + 10 )
|
||||
*w = rect->right - 10;
|
||||
|
||||
// detect x and y position
|
||||
switch( (int)net_graphpos.value )
|
||||
switch( (int)net_graphpos->value )
|
||||
{
|
||||
case 1: // right sided
|
||||
*x = rect->left + rect->right - 5 - *w;
|
||||
@@ -661,16 +661,16 @@ void SCR_DrawNetGraph( void )
|
||||
{
|
||||
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
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( net_scale.value <= 0 )
|
||||
if( net_scale->value <= 0 )
|
||||
Cvar_SetValue( "net_scale", 0.1f );
|
||||
|
||||
NetGraph_GetScreenPos( &rect, &w, &x, &y );
|
||||
@@ -697,12 +697,12 @@ void SCR_DrawNetGraph( void )
|
||||
|
||||
void CL_InitNetgraph( void )
|
||||
{
|
||||
Cvar_RegisterVariable( &net_graph );
|
||||
Cvar_RegisterVariable( &net_graphpos );
|
||||
Cvar_RegisterVariable( &net_scale );
|
||||
Cvar_RegisterVariable( &net_graphwidth );
|
||||
Cvar_RegisterVariable( &net_graphheight );
|
||||
Cvar_RegisterVariable( &net_graphsolid );
|
||||
net_graph = Cvar_Get( "net_graph", "0", FCVAR_ARCHIVE, "draw network usage graph" );
|
||||
net_graphpos = Cvar_Get( "net_graphpos", "1", FCVAR_ARCHIVE, "network usage graph position" );
|
||||
net_scale = Cvar_Get( "net_scale", "5", FCVAR_ARCHIVE, "network usage graph scale level" );
|
||||
net_graphwidth = Cvar_Get( "net_graphwidth", "192", FCVAR_ARCHIVE, "network usage graph width" );
|
||||
net_graphheight = Cvar_Get( "net_graphheight", "64", FCVAR_ARCHIVE, "network usage graph height" );
|
||||
net_graphsolid = Cvar_Get( "net_graphsolid", "1", FCVAR_ARCHIVE, "fill segments in network usage graph" );
|
||||
packet_loss = packet_choke = 0.0;
|
||||
|
||||
NetGraph_InitColors();
|
||||
|
||||
@@ -21,7 +21,6 @@ GNU General Public License for more details.
|
||||
#include "shake.h"
|
||||
#include "hltv.h"
|
||||
#include "input.h"
|
||||
#include "server.h"
|
||||
#if XASH_LOW_MEMORY != 2
|
||||
int CL_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
|
||||
#endif
|
||||
@@ -197,7 +196,7 @@ void CL_ParseServerTime( sizebuf_t *msg )
|
||||
|
||||
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.timedelta = 0.0f;
|
||||
@@ -849,10 +848,8 @@ CL_ParseServerData
|
||||
void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
|
||||
{
|
||||
char gamefolder[MAX_QPATH];
|
||||
string mapfile;
|
||||
qboolean background;
|
||||
int i;
|
||||
uint32_t mapCRC;
|
||||
|
||||
HPAK_CheckSize( CUSTOM_RES_PATH );
|
||||
|
||||
@@ -915,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 )
|
||||
Con_Printf( S_WARN "server model limit is above client model limit %i > %i\n", clgame.maxModels, MAX_MODELS );
|
||||
|
||||
@@ -946,10 +931,10 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
|
||||
// loading user settings
|
||||
CSCR_LoadDefaultCVars( "user.scr" );
|
||||
|
||||
if( r_decals.value > mp_decals.value )
|
||||
Cvar_DirectSet( &r_decals, mp_decals.string );
|
||||
if( r_decals->value > mp_decals.value )
|
||||
Cvar_SetValue( "r_decals", mp_decals.value );
|
||||
}
|
||||
else Cvar_DirectSet( &r_decals, NULL );
|
||||
else Cvar_Reset( "r_decals" );
|
||||
|
||||
// set the background state
|
||||
if( cls.demoplayback && ( cls.demonum != -1 ))
|
||||
@@ -981,7 +966,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
|
||||
Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle ));
|
||||
|
||||
if( !cls.changelevel && !cls.changedemo )
|
||||
CL_InitEdicts( cl.maxclients ); // re-arrange edicts
|
||||
CL_InitEdicts (); // re-arrange edicts
|
||||
|
||||
// get splash name
|
||||
if( cls.demoplayback && ( cls.demonum != -1 ))
|
||||
@@ -989,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" ));
|
||||
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
|
||||
cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime)
|
||||
}
|
||||
@@ -1255,7 +1240,7 @@ CL_ParseSetAngle
|
||||
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 );
|
||||
}
|
||||
@@ -1534,8 +1519,7 @@ void CL_SendConsistencyInfo( sizebuf_t *msg )
|
||||
{
|
||||
case force_exactfile:
|
||||
MD5_HashFile( md5, filename, NULL );
|
||||
memcpy( &pc->value, md5, sizeof( pc->value ));
|
||||
LittleLongSW( pc->value );
|
||||
pc->value = *(int *)md5;
|
||||
|
||||
if( user_changed_diskfile )
|
||||
MSG_WriteUBitLong( msg, 0, 32 );
|
||||
@@ -1566,7 +1550,7 @@ CL_StartDark
|
||||
*/
|
||||
static void CL_StartDark( void )
|
||||
{
|
||||
if( v_dark.value )
|
||||
if( Cvar_VariableValue( "v_dark" ))
|
||||
{
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
float fadetime = 5.0f;
|
||||
@@ -1591,7 +1575,7 @@ static void CL_StartDark( void )
|
||||
sf->fadeReset += cl.time;
|
||||
sf->fadeEnd += sf->fadeReset;
|
||||
|
||||
Cvar_DirectSet( &v_dark, "0" );
|
||||
Cvar_SetValue( "v_dark", 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2169,7 +2153,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
||||
// parse user message into buffer
|
||||
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",
|
||||
clgame.msg[i].name, iSize, clgame.msg[i].number );
|
||||
@@ -2276,8 +2260,6 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
|
||||
old_background = cl.background;
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
{
|
||||
int maxclients = cl.maxclients;
|
||||
|
||||
cls.changelevel = true;
|
||||
S_StopAllSounds( true );
|
||||
|
||||
@@ -2289,8 +2271,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
|
||||
cls.changedemo = true;
|
||||
}
|
||||
|
||||
CL_ClearState();
|
||||
CL_InitEdicts( maxclients ); // re-arrange edicts
|
||||
CL_ClearState ();
|
||||
CL_InitEdicts (); // re-arrange edicts
|
||||
}
|
||||
else Con_Printf( "Server disconnected, reconnecting\n" );
|
||||
|
||||
@@ -2509,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;
|
||||
}
|
||||
|
||||
@@ -1,705 +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
|
||||
==================
|
||||
*/
|
||||
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;
|
||||
|
||||
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 );
|
||||
#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;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ CL_IsPredicted
|
||||
*/
|
||||
qboolean CL_IsPredicted( void )
|
||||
{
|
||||
if( cl_nopred.value || cl.intermission )
|
||||
if( cl_nopred->value || cl.intermission )
|
||||
return false;
|
||||
|
||||
// never predict the quake demos
|
||||
@@ -183,7 +183,7 @@ void CL_SetIdealPitch( void )
|
||||
}
|
||||
|
||||
if( steps < 2 ) return;
|
||||
cl.local.idealpitch = -dir * cl_idealpitchscale.value;
|
||||
cl.local.idealpitch = -dir * cl_idealpitchscale->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -234,7 +234,7 @@ void CL_CheckPredictionError( void )
|
||||
// save the prediction error for interpolation
|
||||
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 );
|
||||
|
||||
// a teleport or something or gamepaused
|
||||
@@ -242,7 +242,7 @@ void CL_CheckPredictionError( void )
|
||||
}
|
||||
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 );
|
||||
|
||||
VectorCopy( cl.frames[cmd].playerstate[cl.playernum].origin, cl.local.predicted_origins[frame] );
|
||||
@@ -253,7 +253,7 @@ void CL_CheckPredictionError( void )
|
||||
// GoldSrc checks for singleplayer
|
||||
// we would check for local server
|
||||
if( dist > MIN_CORRECTION_DISTANCE && !SV_Active() )
|
||||
cls.correction_time = cl_smoothtime.value;
|
||||
cls.correction_time = cl_smoothtime->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ void GAME_EXPORT CL_SetSolidPlayers( int playernum )
|
||||
physent_t *pe;
|
||||
int i;
|
||||
|
||||
if( !cl_solid_players.value )
|
||||
if( !cl_solid_players->value )
|
||||
return;
|
||||
|
||||
for( i = 0; i < MAX_CLIENTS; i++ )
|
||||
@@ -1105,7 +1105,7 @@ void CL_PredictMovement( qboolean repredicting )
|
||||
cl.local.onground = frame->playerstate[cl.playernum].onground;
|
||||
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.repredicting = false;
|
||||
cl.local.moving = false;
|
||||
@@ -1137,7 +1137,7 @@ void CL_PredictMovement( qboolean repredicting )
|
||||
|
||||
cl.local.waterlevel = to->client.waterlevel;
|
||||
cl.local.usehull = to->playerstate.usehull;
|
||||
if( !repredicting || !cl_lw.value )
|
||||
if( !repredicting || !CVAR_TO_BOOL( cl_lw ))
|
||||
cl.local.viewmodel = to->client.viewmodel;
|
||||
|
||||
if( FBitSet( to->client.flags, FL_ONGROUND ))
|
||||
@@ -1167,7 +1167,7 @@ void CL_PredictMovement( qboolean repredicting )
|
||||
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;
|
||||
float frac;
|
||||
@@ -1177,14 +1177,14 @@ void CL_PredictMovement( qboolean repredicting )
|
||||
cls.correction_time -= host.frametime;
|
||||
|
||||
// Make sure smoothtime is postive
|
||||
if( cl_smoothtime.value <= 0.0f )
|
||||
Cvar_DirectSet( &cl_smoothtime, "0.1" );
|
||||
if( cl_smoothtime->value <= 0.0f )
|
||||
Cvar_DirectSet( cl_smoothtime, "0.1" );
|
||||
|
||||
// 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
|
||||
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
|
||||
VectorSubtract( cl.simorg, cl.local.lastorigin, delta );
|
||||
|
||||
@@ -232,10 +232,10 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
// loading user settings
|
||||
CSCR_LoadDefaultCVars( "user.scr" );
|
||||
|
||||
if( r_decals.value > mp_decals.value )
|
||||
Cvar_DirectSet( &r_decals, mp_decals.string );
|
||||
if( r_decals->value > mp_decals.value )
|
||||
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
|
||||
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 ));
|
||||
|
||||
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
|
||||
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" ));
|
||||
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
|
||||
cls.scrshot_request = scrshot_plaque; // request levelshot even if exist (check filetime)
|
||||
}
|
||||
@@ -694,13 +694,17 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
|
||||
cl_entity_t *ent;
|
||||
int newnum;
|
||||
|
||||
memset( &state, 0, sizeof( state ));
|
||||
newnum = MSG_ReadWord( msg ); // entnum
|
||||
|
||||
if( newnum >= clgame.maxEntities )
|
||||
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
|
||||
memset( &state, 0, sizeof( state ));
|
||||
state.modelindex = MSG_ReadByte( msg );
|
||||
state.frame = 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.origin[2] = MSG_ReadCoord( msg );
|
||||
state.angles[2] = MSG_ReadAngle( msg );
|
||||
|
||||
ent = CL_EDICT_NUM( newnum );
|
||||
ent->index = newnum;
|
||||
ent->player = CL_IsPlayerIndex( newnum );
|
||||
|
||||
memcpy( &ent->baseline, &state, sizeof( entity_state_t ));
|
||||
memcpy( &ent->prevstate, &state, sizeof( entity_state_t ));
|
||||
}
|
||||
|
||||
@@ -41,24 +41,11 @@ CL_CmpStudioTextures
|
||||
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;
|
||||
mstudiotexture_t *p2;
|
||||
|
||||
if( !p1 ) // no textures
|
||||
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;
|
||||
if( !p1 || !p2 ) return false;
|
||||
|
||||
for( i = 0; i < numtexs; i++, p1++, p2++ )
|
||||
{
|
||||
@@ -78,7 +65,7 @@ CL_CreateRawTextureFromPixels
|
||||
Convert texture_t struct into mstudiotexture_t prototype
|
||||
====================
|
||||
*/
|
||||
static byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
{
|
||||
static mstudiotexture_t pin;
|
||||
byte *pal;
|
||||
@@ -111,7 +98,7 @@ CL_DuplicateTexture
|
||||
Dupliacte texture with remap pixels
|
||||
====================
|
||||
*/
|
||||
static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
const char *name;
|
||||
texture_t *tx = NULL;
|
||||
@@ -154,7 +141,7 @@ CL_UpdateStudioTexture
|
||||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
rgbdata_t *pic;
|
||||
texture_t *tx = NULL;
|
||||
@@ -215,7 +202,7 @@ CL_UpdateAliasTexture
|
||||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
{
|
||||
char texname[MAX_QPATH];
|
||||
rgbdata_t skin, *pic;
|
||||
@@ -247,68 +234,6 @@ static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture,
|
||||
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_AllocRemapInfo
|
||||
@@ -317,7 +242,7 @@ Allocate new remap info per entity
|
||||
and make copy of remap textures
|
||||
====================
|
||||
*/
|
||||
static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
studiohdr_t *phdr;
|
||||
@@ -357,9 +282,10 @@ static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor
|
||||
if( !phdr ) return; // bad model?
|
||||
|
||||
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
|
||||
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
|
||||
// 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;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_ClearAllRemaps
|
||||
@@ -446,21 +434,3 @@ void CL_ClearAllRemaps( void )
|
||||
}
|
||||
clgame.remap_info = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_EntitySetRemapColors
|
||||
=============
|
||||
*/
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom )
|
||||
{
|
||||
CL_AllocRemapInfo( e, mod, top, bottom );
|
||||
|
||||
if( CL_GetRemapInfoForEntity( e ))
|
||||
{
|
||||
CL_UpdateRemapInfo( e, top, bottom );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -164,14 +164,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
||||
return (intptr_t)world.deluxedata;
|
||||
case PARM_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:
|
||||
// indicates call from client.dll
|
||||
if( checkRef )
|
||||
@@ -207,8 +199,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
||||
return pfnNumberOfEntities();
|
||||
case PARM_NUMMODELS:
|
||||
return cl.nummodels;
|
||||
case PARM_WORLD_VERSION:
|
||||
return world.version;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -20,18 +20,18 @@ GNU General Public License for more details.
|
||||
#include "input.h"
|
||||
#include "library.h"
|
||||
|
||||
CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" );
|
||||
CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" );
|
||||
CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" );
|
||||
CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" );
|
||||
CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" );
|
||||
CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
|
||||
CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" );
|
||||
static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" );
|
||||
CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" );
|
||||
static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" );
|
||||
static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" );
|
||||
static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" );
|
||||
convar_t *scr_centertime;
|
||||
convar_t *scr_loading;
|
||||
convar_t *scr_download;
|
||||
convar_t *scr_viewsize;
|
||||
convar_t *cl_testlights;
|
||||
convar_t *cl_allow_levelshots;
|
||||
convar_t *cl_levelshot_name;
|
||||
static convar_t *cl_envshot_size;
|
||||
convar_t *v_dark;
|
||||
static convar_t *net_speeds;
|
||||
static convar_t *cl_showfps;
|
||||
static convar_t *cl_showpos;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -59,7 +59,7 @@ void SCR_DrawFPS( int height )
|
||||
char fpsstring[64];
|
||||
int offset;
|
||||
|
||||
if( cls.state != ca_active || !cl_showfps.value || cl.background )
|
||||
if( cls.state != ca_active || !cl_showfps->value || cl.background )
|
||||
return;
|
||||
|
||||
switch( cls.scrshot_action )
|
||||
@@ -95,7 +95,7 @@ void SCR_DrawFPS( int height )
|
||||
if( curfps < minfps ) minfps = 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 );
|
||||
else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps );
|
||||
MakeRGBA( color, 255, 255, 255, 255 );
|
||||
@@ -119,7 +119,7 @@ void SCR_DrawPos( void )
|
||||
cl_entity_t *ent;
|
||||
rgba_t color;
|
||||
|
||||
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
||||
if( cls.state != ca_active || !cl_showpos->value || cl.background )
|
||||
return;
|
||||
|
||||
ent = CL_GetLocalPlayer();
|
||||
@@ -164,7 +164,7 @@ void SCR_NetSpeeds( void )
|
||||
if( !host.allow_console )
|
||||
return;
|
||||
|
||||
if( !net_speeds.value || cls.state != ca_active )
|
||||
if( !net_speeds->value || cls.state != ca_active )
|
||||
return;
|
||||
|
||||
// prevent to get too big values at max
|
||||
@@ -290,7 +290,7 @@ void SCR_MakeScreenShot( void )
|
||||
|
||||
if( cls.envshot_viewsize > 0 )
|
||||
viewsize = cls.envshot_viewsize;
|
||||
else viewsize = cl_envshot_size.value;
|
||||
else viewsize = cl_envshot_size->value;
|
||||
|
||||
switch( cls.scrshot_action )
|
||||
{
|
||||
@@ -344,9 +344,9 @@ SCR_DrawPlaque
|
||||
*/
|
||||
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.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
|
||||
if( !cl.background ) CL_DrawHUD( CL_LOADING );
|
||||
@@ -366,7 +366,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
|
||||
cl.video_prepped = false;
|
||||
|
||||
if( !Host_IsDedicated() )
|
||||
oldclear = gl_clear.value;
|
||||
oldclear = gl_clear->value;
|
||||
|
||||
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
|
||||
{
|
||||
@@ -382,7 +382,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
|
||||
return;
|
||||
|
||||
if( !Host_IsDedicated() )
|
||||
gl_clear.value = 0.0f;
|
||||
gl_clear->value = 0.0f;
|
||||
|
||||
if( is_background ) IN_MouseSavePos( );
|
||||
cls.draw_changelevel = !is_background;
|
||||
@@ -391,7 +391,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
|
||||
cl.background = is_background; // set right state before svc_serverdata is came
|
||||
|
||||
if( !Host_IsDedicated() )
|
||||
gl_clear.value = oldclear;
|
||||
gl_clear->value = oldclear;
|
||||
|
||||
// SNDDMA_LockSound();
|
||||
}
|
||||
@@ -442,7 +442,7 @@ void SCR_TileClear( void )
|
||||
int i, top, bottom, left, right;
|
||||
dirty_t clear;
|
||||
|
||||
if( scr_viewsize.value >= 120 )
|
||||
if( scr_viewsize->value >= 120 )
|
||||
return; // full screen rendering
|
||||
|
||||
// erase rect will be the union of the past three frames
|
||||
@@ -558,7 +558,7 @@ void SCR_LoadCreditsFont( void )
|
||||
{
|
||||
cl_font_t *const font = &cls.creditsFont;
|
||||
qboolean success = false;
|
||||
float scale = hud_fontscale.value;
|
||||
float scale = hud_fontscale->value;
|
||||
dword crc = 0;
|
||||
|
||||
// replace default gfx.wad textures by current charset's font
|
||||
@@ -652,13 +652,13 @@ void SCR_RegisterTextures( void )
|
||||
|
||||
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 );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
else if( FS_FileExists( "gfx/loading.lmp", false ))
|
||||
{
|
||||
if( cl_allow_levelshots.value )
|
||||
if( cl_allow_levelshots->value )
|
||||
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 );
|
||||
}
|
||||
@@ -675,7 +675,7 @@ Keybinding command
|
||||
*/
|
||||
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 ));
|
||||
}
|
||||
|
||||
|
||||
@@ -688,7 +688,7 @@ Keybinding command
|
||||
*/
|
||||
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 ));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -715,7 +715,9 @@ void SCR_VidInit( void )
|
||||
// notify vgui about screen size change
|
||||
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
|
||||
@@ -726,7 +728,6 @@ void SCR_VidInit( void )
|
||||
|
||||
// restart console size
|
||||
Con_VidInit ();
|
||||
Touch_NotifyResize();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -738,18 +739,18 @@ void SCR_Init( void )
|
||||
{
|
||||
if( scr_init ) return;
|
||||
|
||||
Cvar_RegisterVariable( &scr_centertime );
|
||||
Cvar_RegisterVariable( &cl_levelshot_name );
|
||||
Cvar_RegisterVariable( &cl_allow_levelshots );
|
||||
Cvar_RegisterVariable( &scr_loading );
|
||||
Cvar_RegisterVariable( &scr_download );
|
||||
Cvar_RegisterVariable( &cl_testlights );
|
||||
Cvar_RegisterVariable( &cl_envshot_size );
|
||||
Cvar_RegisterVariable( &v_dark );
|
||||
Cvar_RegisterVariable( &scr_viewsize );
|
||||
Cvar_RegisterVariable( &net_speeds );
|
||||
Cvar_RegisterVariable( &cl_showfps );
|
||||
Cvar_RegisterVariable( &cl_showpos );
|
||||
scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" );
|
||||
cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" );
|
||||
cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
|
||||
scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" );
|
||||
scr_download = Cvar_Get( "scr_download", "-1", 0, "downloading bar progress" );
|
||||
cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" );
|
||||
cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", FCVAR_ARCHIVE, "envshot size of cube side" );
|
||||
v_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" );
|
||||
scr_viewsize = Cvar_Get( "viewsize", "120", FCVAR_ARCHIVE, "screen size" );
|
||||
net_speeds = Cvar_Get( "net_speeds", "0", FCVAR_ARCHIVE, "show network packets" );
|
||||
cl_showfps = Cvar_Get( "cl_showfps", "0", FCVAR_ARCHIVE, "show client fps" );
|
||||
cl_showpos = Cvar_Get( "cl_showpos", "0", FCVAR_ARCHIVE, "show local player position and velocity" );
|
||||
|
||||
// register our commands
|
||||
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
|
||||
|
||||
@@ -2629,7 +2629,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
vec3_t forward, view_ofs;
|
||||
vec3_t vecSrc, vecEnd;
|
||||
float falloff;
|
||||
pmtrace_t trace;
|
||||
pmtrace_t *trace;
|
||||
cl_entity_t *hit;
|
||||
dlight_t *dl;
|
||||
|
||||
@@ -2660,26 +2660,28 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
VectorAdd( ent->origin, view_ofs, vecSrc );
|
||||
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
|
||||
dl = CL_AllocDlight( ent->index );
|
||||
#if 1
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->physents[trace.ent].info );
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace->ent].info );
|
||||
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
|
||||
VectorCopy( hit->origin, dl->origin );
|
||||
else VectorCopy( trace.endpos, dl->origin );
|
||||
else VectorCopy( trace->endpos, dl->origin );
|
||||
#else
|
||||
VectorCopy( trace->endpos, dl->origin );
|
||||
#endif
|
||||
// compute falloff
|
||||
falloff = trace.fraction * FLASHLIGHT_DISTANCE;
|
||||
falloff = trace->fraction * FLASHLIGHT_DISTANCE;
|
||||
if( falloff < 500.0f ) falloff = 1.0f;
|
||||
else falloff = 500.0f / falloff;
|
||||
falloff *= falloff;
|
||||
|
||||
// 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->radius = 80;
|
||||
}
|
||||
@@ -2841,10 +2843,10 @@ void CL_TestLights( void )
|
||||
float f, r;
|
||||
dlight_t *dl;
|
||||
|
||||
if( !cl_testlights.value )
|
||||
if( !CVAR_TO_BOOL( cl_testlights ))
|
||||
return;
|
||||
|
||||
numLights = bound( 1, cl_testlights.value, MAX_DLIGHTS );
|
||||
numLights = bound( 1, cl_testlights->value, MAX_DLIGHTS );
|
||||
AngleVectors( cl.viewangles, forward, right, NULL );
|
||||
|
||||
for( i = 0; i < numLights; i++ )
|
||||
|
||||
@@ -202,6 +202,7 @@ SCR_PlayCinematic
|
||||
*/
|
||||
qboolean SCR_PlayCinematic( const char *arg )
|
||||
{
|
||||
string path;
|
||||
const char *fullpath;
|
||||
|
||||
fullpath = FS_GetDiskPath( arg, false );
|
||||
|
||||
@@ -39,7 +39,7 @@ void V_CalcViewRect( void )
|
||||
{
|
||||
// intermission is always full screen
|
||||
if( cl.intermission ) size = 120.0f;
|
||||
else size = scr_viewsize.value;
|
||||
else size = scr_viewsize->value;
|
||||
|
||||
if( size >= 120.0f )
|
||||
sb_lines = 0; // no status bar at all
|
||||
@@ -47,12 +47,12 @@ void V_CalcViewRect( void )
|
||||
sb_lines = 24; // no inventory
|
||||
else sb_lines = 48;
|
||||
|
||||
if( scr_viewsize.value >= 100.0f )
|
||||
if( scr_viewsize->value >= 100.0f )
|
||||
{
|
||||
full = true;
|
||||
size = 100.0f;
|
||||
}
|
||||
else size = scr_viewsize.value;
|
||||
else size = scr_viewsize->value;
|
||||
|
||||
if( cl.intermission )
|
||||
{
|
||||
@@ -144,7 +144,7 @@ void V_SetRefParams( ref_params_t *fd )
|
||||
VectorCopy( cl.viewangles, fd->cl_viewangles );
|
||||
fd->health = cl.local.health;
|
||||
VectorCopy( cl.crosshairangle, fd->crosshairangle );
|
||||
fd->viewsize = scr_viewsize.value;
|
||||
fd->viewsize = scr_viewsize->value;
|
||||
|
||||
VectorCopy( cl.punchangle, fd->punchangle );
|
||||
fd->maxclients = cl.maxclients;
|
||||
@@ -311,7 +311,7 @@ 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] );
|
||||
|
||||
// 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 );
|
||||
|
||||
rvp->flags = 0;
|
||||
@@ -339,7 +339,7 @@ qboolean V_PreRender( void )
|
||||
// if the screen is disabled (loading plaque is up)
|
||||
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" );
|
||||
cls.disable_screen = 0.0f;
|
||||
@@ -364,13 +364,11 @@ V_RenderView
|
||||
*/
|
||||
void V_RenderView( void )
|
||||
{
|
||||
// HACKHACK: make ref params static
|
||||
// not really critical but allows client.dll to take address of refdef and don't trigger ASan
|
||||
static ref_params_t rp;
|
||||
ref_params_t rp;
|
||||
ref_viewpass_t rvp;
|
||||
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
|
||||
|
||||
V_CalcViewRect (); // compute viewport rectangle
|
||||
@@ -474,7 +472,7 @@ void R_ShowTree( void )
|
||||
float y = NODE_INTERVAL_Y(1.0f);
|
||||
mleaf_t *viewleaf;
|
||||
|
||||
if( !cl.worldmodel || !r_showtree.value )
|
||||
if( !cl.worldmodel || !CVAR_TO_BOOL( r_showtree ))
|
||||
return;
|
||||
|
||||
world.recursion_level = 0;
|
||||
|
||||
@@ -423,6 +423,13 @@ typedef struct
|
||||
float applied_angle;
|
||||
} 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
|
||||
{
|
||||
net_response_t resp;
|
||||
@@ -484,7 +491,9 @@ typedef struct
|
||||
client_textmessage_t *titles; // title messages, not network messages
|
||||
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 *master_request; // queued master request
|
||||
|
||||
efrag_t *free_efrags; // linked efrags
|
||||
cl_entity_t viewent; // viewmodel
|
||||
@@ -618,10 +627,7 @@ typedef struct
|
||||
file_t *demofile;
|
||||
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_pending; // if true, clean master server pings
|
||||
uint32_t internetservers_key; // compare key to validate master server reply
|
||||
char internetservers_query[512]; // cached query
|
||||
uint32_t internetservers_query_len;
|
||||
qboolean internetservers_pending; // internetservers is waiting for dns request
|
||||
|
||||
// legacy mode support
|
||||
qboolean legacymode; // one-way 48 protocol compatibility
|
||||
@@ -653,47 +659,46 @@ extern convar_t cl_logocolor;
|
||||
extern convar_t cl_allow_download;
|
||||
extern convar_t cl_allow_upload;
|
||||
extern convar_t cl_download_ingame;
|
||||
extern convar_t cl_nopred;
|
||||
extern convar_t cl_timeout;
|
||||
extern convar_t cl_nodelta;
|
||||
extern convar_t cl_interp;
|
||||
extern convar_t cl_nointerp;
|
||||
extern convar_t cl_showerror;
|
||||
extern convar_t cl_nosmooth;
|
||||
extern convar_t cl_smoothtime;
|
||||
extern convar_t cl_crosshair;
|
||||
extern convar_t cl_testlights;
|
||||
extern convar_t cl_cmdrate;
|
||||
extern convar_t cl_updaterate;
|
||||
extern convar_t cl_solid_players;
|
||||
extern convar_t cl_idealpitchscale;
|
||||
extern convar_t cl_allow_levelshots;
|
||||
extern convar_t cl_lightstyle_lerping;
|
||||
extern convar_t cl_draw_particles;
|
||||
extern convar_t cl_draw_tracers;
|
||||
extern convar_t cl_levelshot_name;
|
||||
extern convar_t cl_draw_beams;
|
||||
extern convar_t cl_clockreset;
|
||||
extern convar_t cl_fixtimerate;
|
||||
extern convar_t hud_fontscale;
|
||||
extern convar_t hud_scale;
|
||||
extern convar_t r_showtextures;
|
||||
extern convar_t cl_bmodelinterp;
|
||||
extern convar_t cl_lw; // local weapons
|
||||
extern convar_t cl_charset;
|
||||
extern convar_t cl_trace_messages;
|
||||
extern convar_t cl_trace_events;
|
||||
extern convar_t hud_utf8;
|
||||
extern convar_t cl_showevents;
|
||||
extern convar_t scr_centertime;
|
||||
extern convar_t scr_viewsize;
|
||||
extern convar_t scr_loading;
|
||||
extern convar_t v_dark; // start from dark
|
||||
extern convar_t net_graph;
|
||||
extern convar_t rate;
|
||||
extern convar_t m_ignore;
|
||||
extern convar_t r_showtree;
|
||||
extern convar_t ui_renderworld;
|
||||
extern convar_t *cl_nopred;
|
||||
extern convar_t *cl_timeout;
|
||||
extern convar_t *cl_nodelta;
|
||||
extern convar_t *cl_interp;
|
||||
extern convar_t *cl_nointerp;
|
||||
extern convar_t *cl_showerror;
|
||||
extern convar_t *cl_nosmooth;
|
||||
extern convar_t *cl_smoothtime;
|
||||
extern convar_t *cl_crosshair;
|
||||
extern convar_t *cl_testlights;
|
||||
extern convar_t *cl_cmdrate;
|
||||
extern convar_t *cl_updaterate;
|
||||
extern convar_t *cl_solid_players;
|
||||
extern convar_t *cl_idealpitchscale;
|
||||
extern convar_t *cl_allow_levelshots;
|
||||
extern convar_t *cl_lightstyle_lerping;
|
||||
extern convar_t *cl_draw_particles;
|
||||
extern convar_t *cl_draw_tracers;
|
||||
extern convar_t *cl_levelshot_name;
|
||||
extern convar_t *cl_draw_beams;
|
||||
extern convar_t *cl_clockreset;
|
||||
extern convar_t *cl_fixtimerate;
|
||||
extern convar_t *hud_fontscale;
|
||||
extern convar_t *hud_scale;
|
||||
extern convar_t *gl_showtextures;
|
||||
extern convar_t *cl_bmodelinterp;
|
||||
extern convar_t *cl_lw; // local weapons
|
||||
extern convar_t *cl_charset;
|
||||
extern convar_t *cl_trace_messages;
|
||||
extern convar_t *hud_utf8;
|
||||
extern convar_t *cl_showevents;
|
||||
extern convar_t *scr_centertime;
|
||||
extern convar_t *scr_viewsize;
|
||||
extern convar_t *scr_loading;
|
||||
extern convar_t *v_dark; // start from dark
|
||||
extern convar_t *net_graph;
|
||||
extern convar_t *rate;
|
||||
extern convar_t *m_ignore;
|
||||
extern convar_t *r_showtree;
|
||||
extern convar_t *ui_renderworld;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
@@ -759,6 +764,7 @@ int CL_IsDevOverviewMode( void );
|
||||
void CL_PingServers_f( void );
|
||||
void CL_SignonReply( void );
|
||||
void CL_ClearState( void );
|
||||
size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat );
|
||||
|
||||
//
|
||||
// cl_demo.c
|
||||
@@ -824,7 +830,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize );
|
||||
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
|
||||
void CL_ParseTextMessage( sizebuf_t *msg );
|
||||
void CL_DrawHUD( int state );
|
||||
void CL_InitEdicts( int maxclients );
|
||||
void CL_InitEdicts( void );
|
||||
void CL_FreeEdicts( void );
|
||||
void CL_ClearWorld( void );
|
||||
void CL_DrawCenterPrint( void );
|
||||
@@ -832,21 +838,29 @@ void CL_ClearSpriteTextures( void );
|
||||
void CL_CenterPrint( const char *text, float y );
|
||||
void CL_TextMessageParse( byte *pMemFile, int fileSize );
|
||||
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 );
|
||||
void NetAPI_CancelAllRequests( void );
|
||||
int CL_FindModelIndex( const char *m );
|
||||
cl_entity_t *CL_GetLocalPlayer( void );
|
||||
model_t *CL_LoadClientSprite( const char *filename );
|
||||
model_t *CL_LoadModel( const char *modelname, int *index );
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
|
||||
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags );
|
||||
void SPR_AdjustSize( float *x, float *y, float *w, float *h );
|
||||
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 );
|
||||
int CL_GetScreenInfo( SCREENINFO *pscrinfo );
|
||||
void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a );
|
||||
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 );
|
||||
const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend );
|
||||
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 );
|
||||
struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend );
|
||||
movevars_t *pfnGetMoveVars( void );
|
||||
@@ -872,32 +886,10 @@ _inline cl_entity_t *CL_EDICT_NUM( int n )
|
||||
//
|
||||
// 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_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message );
|
||||
void CL_LegacyPrecache_f( void );
|
||||
|
||||
void CL_ParseTempEntity( sizebuf_t *msg );
|
||||
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
|
||||
qboolean CL_RequestMissingResources( void );
|
||||
@@ -905,12 +897,6 @@ void CL_RegisterResources ( sizebuf_t *msg );
|
||||
void CL_ParseViewEntity( sizebuf_t *msg );
|
||||
void CL_ParseServerTime( sizebuf_t *msg );
|
||||
|
||||
//
|
||||
// cl_parse_48.c
|
||||
//
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message );
|
||||
void CL_LegacyPrecache_f( void );
|
||||
|
||||
//
|
||||
// cl_scrn.c
|
||||
//
|
||||
@@ -996,7 +982,9 @@ void CL_EmitEntities( void );
|
||||
// cl_remap.c
|
||||
//
|
||||
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
|
||||
void CL_FreeRemapInfo( remap_info_t *info );
|
||||
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
|
||||
void CL_ClearAllRemaps( void );
|
||||
|
||||
//
|
||||
@@ -1017,6 +1005,7 @@ void R_AddEfrags( cl_entity_t *ent );
|
||||
// cl_tent.c
|
||||
//
|
||||
struct particle_s;
|
||||
int CL_AddEntity( int entityType, cl_entity_t *pEnt );
|
||||
void CL_WeaponAnim( int iAnim, int body );
|
||||
void CL_ClearEffects( void );
|
||||
void CL_ClearEfrags( void );
|
||||
@@ -1050,7 +1039,7 @@ void CL_RunLightStyles( void );
|
||||
//
|
||||
// console.c
|
||||
//
|
||||
extern convar_t con_fontsize;
|
||||
extern convar_t *con_fontsize;
|
||||
int Con_Visible( void );
|
||||
qboolean Con_FixedFont( void );
|
||||
void Con_VidInit( void );
|
||||
|
||||
@@ -22,14 +22,13 @@ GNU General Public License for more details.
|
||||
#include "wadfile.h"
|
||||
#include "input.h"
|
||||
|
||||
static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" );
|
||||
static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" );
|
||||
CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
|
||||
static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
|
||||
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
||||
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
||||
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
||||
|
||||
convar_t *con_notifytime;
|
||||
convar_t *scr_conspeed;
|
||||
convar_t *con_fontsize;
|
||||
convar_t *con_charset;
|
||||
convar_t *con_fontscale;
|
||||
convar_t *con_fontnum;
|
||||
convar_t *con_color;
|
||||
|
||||
static int g_codepage = 0;
|
||||
static qboolean g_utf8 = false;
|
||||
@@ -163,13 +162,14 @@ Con_SetColor
|
||||
*/
|
||||
static void Con_SetColor( void )
|
||||
{
|
||||
vec3_t color;
|
||||
int r, g, b;
|
||||
int num;
|
||||
|
||||
if( !FBitSet( con_color.flags, FCVAR_CHANGED ))
|
||||
if( !FBitSet( con_color->flags, FCVAR_CHANGED ))
|
||||
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 )
|
||||
{
|
||||
@@ -180,11 +180,11 @@ static void Con_SetColor( void )
|
||||
Con_DefaultColor( r, g, b );
|
||||
break;
|
||||
default:
|
||||
Cvar_DirectSet( &con_color, con_color.def_string );
|
||||
Cvar_DirectSet( con_color, con_color->def_string );
|
||||
break;
|
||||
}
|
||||
|
||||
ClearBits( con_color.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_color->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -538,7 +538,7 @@ INTERNAL RESOURCE
|
||||
static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
||||
{
|
||||
qboolean success = false;
|
||||
float scale = con_fontscale.value;
|
||||
float scale = con_fontscale->value;
|
||||
|
||||
if( font->valid )
|
||||
return; // already loaded
|
||||
@@ -593,8 +593,8 @@ static void Con_LoadConchars( void )
|
||||
Con_LoadConsoleFont( i, con.chars + i );
|
||||
|
||||
// select properly fontsize
|
||||
if( con_fontnum.value >= 0 && con_fontnum.value <= CON_NUMFONTS - 1 )
|
||||
fontSize = con_fontnum.value;
|
||||
if( con_fontnum->value >= 0 && con_fontnum->value <= CON_NUMFONTS - 1 )
|
||||
fontSize = con_fontnum->value;
|
||||
else if( refState.width <= 640 )
|
||||
fontSize = 0;
|
||||
else if( refState.width >= 1280 )
|
||||
@@ -808,7 +808,7 @@ compute string width and height in screen pixels
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -830,17 +830,19 @@ Con_Init
|
||||
*/
|
||||
void Con_Init( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( host.type == HOST_DEDICATED )
|
||||
return; // dedicated server already have console
|
||||
|
||||
// must be init before startup video subsystem
|
||||
Cvar_RegisterVariable( &scr_conspeed );
|
||||
Cvar_RegisterVariable( &con_notifytime );
|
||||
Cvar_RegisterVariable( &con_fontsize );
|
||||
Cvar_RegisterVariable( &con_charset );
|
||||
Cvar_RegisterVariable( &con_fontscale );
|
||||
Cvar_RegisterVariable( &con_fontnum );
|
||||
Cvar_RegisterVariable( &con_color );
|
||||
scr_conspeed = Cvar_Get( "scr_conspeed", "600", FCVAR_ARCHIVE, "console moving speed" );
|
||||
con_notifytime = Cvar_Get( "con_notifytime", "3", FCVAR_ARCHIVE, "notify time to live" );
|
||||
con_fontsize = Cvar_Get( "con_fontsize", "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
|
||||
con_charset = Cvar_Get( "con_charset", "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
|
||||
con_fontscale = Cvar_Get( "con_fontscale", "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
||||
con_fontnum = Cvar_Get( "con_fontnum", "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
||||
con_color = Cvar_Get( "con_color", "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
||||
|
||||
// init the console buffer
|
||||
con.bufsize = CON_TEXTSIZE;
|
||||
@@ -1752,15 +1754,11 @@ void Con_DrawDebug( void )
|
||||
string dlstring;
|
||||
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",
|
||||
host.downloadcount, host.downloadfile, scr_download.value, Sys_DoubleTime() - timeStart );
|
||||
|
||||
Con_DrawStringLen( dlstring, &length, NULL );
|
||||
length = Q_max( length, 500 );
|
||||
x = refState.width - length * 1.05f;
|
||||
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
|
||||
x = refState.width - 500;
|
||||
y = con.curFont->charHeight * 1.05f;
|
||||
Con_DrawString( x, y, dlstring, g_color_table[7] );
|
||||
}
|
||||
@@ -1801,7 +1799,7 @@ void Con_DrawNotify( void )
|
||||
{
|
||||
con_lineinfo_t *l = &CON_LINES( i );
|
||||
|
||||
if( l->addtime < ( time - con_notifytime.value ))
|
||||
if( l->addtime < ( time - con_notifytime->value ))
|
||||
continue;
|
||||
|
||||
Con_DrawString( x, y, l->start, g_color_table[7] );
|
||||
@@ -1983,7 +1981,7 @@ void Con_DrawConsole( void )
|
||||
|
||||
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 )
|
||||
con.vislines = con.showlines = 0;
|
||||
@@ -1993,7 +1991,7 @@ void Con_DrawConsole( void )
|
||||
{
|
||||
con.showlines = 0;
|
||||
|
||||
if( host_developer.value >= DEV_EXTENDED && !cls.timedemo )
|
||||
if( host_developer.value >= DEV_EXTENDED )
|
||||
Con_DrawNotify(); // draw notify lines
|
||||
}
|
||||
}
|
||||
@@ -2025,7 +2023,7 @@ void Con_DrawConsole( void )
|
||||
{
|
||||
if( 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
|
||||
}
|
||||
break;
|
||||
@@ -2058,13 +2056,16 @@ void Con_DrawVersion( void )
|
||||
break;
|
||||
}
|
||||
|
||||
if( !host.force_draw_version )
|
||||
{
|
||||
if(( cls.key_dest != key_menu && !draw_version ) || CL_IsDevOverviewMode() == 2 || net_graph->value )
|
||||
return;
|
||||
}
|
||||
|
||||
if( host.force_draw_version_time > host.realtime )
|
||||
draw_version = true;
|
||||
host.force_draw_version = false;
|
||||
|
||||
if(( cls.key_dest != key_menu && !draw_version ) || CL_IsDevOverviewMode() == 2 || net_graph.value )
|
||||
return;
|
||||
|
||||
if( draw_version )
|
||||
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( ));
|
||||
|
||||
@@ -2097,7 +2098,7 @@ void Con_RunConsole( void )
|
||||
}
|
||||
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 )
|
||||
{
|
||||
@@ -2112,35 +2113,35 @@ void Con_RunConsole( void )
|
||||
con.vislines = con.showlines;
|
||||
}
|
||||
|
||||
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 ))
|
||||
if( FBitSet( con_charset->flags, FCVAR_CHANGED ) ||
|
||||
FBitSet( con_fontscale->flags, FCVAR_CHANGED ) ||
|
||||
FBitSet( con_fontnum->flags, FCVAR_CHANGED ) ||
|
||||
FBitSet( cl_charset->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
// update codepage parameters
|
||||
if( !Q_stricmp( con_charset.string, "cp1251" ))
|
||||
if( !Q_stricmp( con_charset->string, "cp1251" ))
|
||||
{
|
||||
g_codepage = 1251;
|
||||
}
|
||||
else if( !Q_stricmp( con_charset.string, "cp1252" ))
|
||||
else if( !Q_stricmp( con_charset->string, "cp1252" ))
|
||||
{
|
||||
g_codepage = 1252;
|
||||
}
|
||||
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_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
|
||||
g_utf8 = !Q_stricmp( cl_charset->string, "utf-8" );
|
||||
Con_InvalidateFonts();
|
||||
Con_LoadConchars();
|
||||
ClearBits( con_charset.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_fontnum.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_fontscale.flags, FCVAR_CHANGED );
|
||||
ClearBits( cl_charset.flags, FCVAR_CHANGED );
|
||||
ClearBits( con_charset->flags, FCVAR_CHANGED );
|
||||
ClearBits( con_fontnum->flags, FCVAR_CHANGED );
|
||||
ClearBits( con_fontscale->flags, FCVAR_CHANGED );
|
||||
ClearBits( cl_charset->flags, FCVAR_CHANGED );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,24 +45,22 @@ static struct joy_axis_s
|
||||
} joyaxis[MAX_AXES] = { 0 };
|
||||
static byte currentbinding; // add posibility to remap keys, to place it in joykeys[]
|
||||
static qboolean joy_initialized;
|
||||
|
||||
static CVAR_DEFINE_AUTO( joy_pitch, "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick pitch sensitivity" );
|
||||
static CVAR_DEFINE_AUTO( joy_yaw, "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick yaw sensitivity" );
|
||||
static CVAR_DEFINE_AUTO( joy_side, "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick side sensitivity. Values from -1.0 to 1.0" );
|
||||
static CVAR_DEFINE_AUTO( joy_forward, "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick forward sensitivity. Values from -1.0 to 1.0" );
|
||||
static CVAR_DEFINE_AUTO( joy_lt_threshold, "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "left trigger threshold. Value from 0 to 32767");
|
||||
static CVAR_DEFINE_AUTO( joy_rt_threshold, "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "right trigger threshold. Value from 0 to 32767" );
|
||||
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 CVAR_DEFINE_AUTO( joy_forward_key_threshold, "24576", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis key event emit threshold. Value from 0 to 32767");
|
||||
static CVAR_DEFINE_AUTO( joy_side_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "side axis deadzone. Value from 0 to 32767" );
|
||||
static CVAR_DEFINE_AUTO( joy_forward_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis deadzone. Value from 0 to 32767");
|
||||
static CVAR_DEFINE_AUTO( joy_pitch_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "pitch axis deadzone. Value from 0 to 32767");
|
||||
static CVAR_DEFINE_AUTO( joy_yaw_deadzone, DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "yaw axis deadzone. Value from 0 to 32767" );
|
||||
static CVAR_DEFINE_AUTO( joy_axis_binding, "sfpyrl", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "axis hardware id to engine inner axis binding, "
|
||||
"s - side, f - forward, y - yaw, p - pitch, r - left trigger, l - right trigger" );
|
||||
static CVAR_DEFINE_AUTO( joy_found, "0", FCVAR_READ_ONLY, "is joystick is connected" );
|
||||
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" );
|
||||
convar_t *joy_enable;
|
||||
static convar_t *joy_pitch;
|
||||
static convar_t *joy_yaw;
|
||||
static convar_t *joy_forward;
|
||||
static convar_t *joy_side;
|
||||
static convar_t *joy_found;
|
||||
static convar_t *joy_index;
|
||||
static convar_t *joy_lt_threshold;
|
||||
static convar_t *joy_rt_threshold;
|
||||
static convar_t *joy_side_deadzone;
|
||||
static convar_t *joy_forward_deadzone;
|
||||
static convar_t *joy_side_key_threshold;
|
||||
static convar_t *joy_forward_key_threshold;
|
||||
static convar_t *joy_pitch_deadzone;
|
||||
static convar_t *joy_yaw_deadzone;
|
||||
static convar_t *joy_axis_binding;
|
||||
|
||||
/*
|
||||
============
|
||||
@@ -71,7 +69,7 @@ Joy_IsActive
|
||||
*/
|
||||
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;
|
||||
|
||||
if( !joy_found.value )
|
||||
if( !joy_found->value )
|
||||
return;
|
||||
|
||||
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:
|
||||
trigButton = K_JOY2;
|
||||
trigThreshold = joy_rt_threshold.value;
|
||||
trigThreshold = joy_rt_threshold->value;
|
||||
break;
|
||||
case JOY_AXIS_LT:
|
||||
trigButton = K_JOY1;
|
||||
trigThreshold = joy_lt_threshold.value;
|
||||
trigThreshold = joy_lt_threshold->value;
|
||||
break;
|
||||
default:
|
||||
Con_Reportf( S_ERROR "Joy_ProcessTrigger: invalid axis = %i", engineAxis );
|
||||
@@ -161,12 +159,12 @@ static int Joy_GetHatValueForAxis( const engineAxis_t engineAxis )
|
||||
switch( engineAxis )
|
||||
{
|
||||
case JOY_AXIS_SIDE:
|
||||
threshold = joy_side_key_threshold.value;
|
||||
threshold = joy_side_key_threshold->value;
|
||||
negative = JOY_HAT_LEFT;
|
||||
positive = JOY_HAT_RIGHT;
|
||||
break;
|
||||
case JOY_AXIS_FWD:
|
||||
threshold = joy_side_key_threshold.value;
|
||||
threshold = joy_side_key_threshold->value;
|
||||
negative = JOY_HAT_UP;
|
||||
positive = JOY_HAT_DOWN;
|
||||
break;
|
||||
@@ -200,10 +198,10 @@ static void Joy_ProcessStick( const engineAxis_t engineAxis, short value )
|
||||
|
||||
switch( engineAxis )
|
||||
{
|
||||
case JOY_AXIS_FWD: deadzone = joy_forward_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_YAW: deadzone = joy_yaw_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_PITCH: deadzone = joy_pitch_deadzone->value; break;
|
||||
case JOY_AXIS_YAW: deadzone = joy_yaw_deadzone->value; break;
|
||||
default:
|
||||
Con_Reportf( S_ERROR "Joy_ProcessStick: invalid axis = %i", engineAxis );
|
||||
break;
|
||||
@@ -238,7 +236,7 @@ Axis events
|
||||
*/
|
||||
void Joy_AxisMotionEvent( byte axis, short value )
|
||||
{
|
||||
if( !joy_found.value )
|
||||
if( !joy_found->value )
|
||||
return;
|
||||
|
||||
if( axis >= MAX_AXES )
|
||||
@@ -273,7 +271,7 @@ Trackball events. UNDONE
|
||||
*/
|
||||
void Joy_BallMotionEvent( byte ball, short xrel, short yrel )
|
||||
{
|
||||
//if( !joy_found.value )
|
||||
//if( !joy_found->value )
|
||||
// return;
|
||||
}
|
||||
|
||||
@@ -286,7 +284,7 @@ Button events
|
||||
*/
|
||||
void Joy_ButtonEvent( byte button, byte down )
|
||||
{
|
||||
if( !joy_found.value )
|
||||
if( !joy_found->value )
|
||||
return;
|
||||
|
||||
// generic game button code.
|
||||
@@ -311,7 +309,7 @@ Called when joystick is removed. For future expansion
|
||||
*/
|
||||
void Joy_RemoveEvent( void )
|
||||
{
|
||||
if( joy_found.value )
|
||||
if( joy_found->value )
|
||||
Cvar_FullSet( "joy_found", "0", FCVAR_READ_ONLY );
|
||||
}
|
||||
|
||||
@@ -324,7 +322,7 @@ Called when joystick is removed. For future expansion
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -340,9 +338,9 @@ void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
|
||||
if( !Joy_IsActive() )
|
||||
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;
|
||||
|
||||
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
|
||||
*side += joy_side.value * (float)joyaxis[JOY_AXIS_SIDE].val/(float)SHRT_MAX;
|
||||
*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;
|
||||
#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
|
||||
*dyaw -= joy_yaw.value * (float)joyaxis[JOY_AXIS_YAW ].val/(float)SHRT_MAX * host.realframetime;
|
||||
*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;
|
||||
#else
|
||||
// HACKHACK: SDL have inverted look axis.
|
||||
*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;
|
||||
*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;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -383,31 +381,32 @@ Main init procedure
|
||||
*/
|
||||
void Joy_Init( void )
|
||||
{
|
||||
Cvar_RegisterVariable( &joy_pitch );
|
||||
Cvar_RegisterVariable( &joy_yaw );
|
||||
Cvar_RegisterVariable( &joy_side );
|
||||
Cvar_RegisterVariable( &joy_forward );
|
||||
joy_pitch = Cvar_Get( "joy_pitch", "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick pitch sensitivity" );
|
||||
joy_yaw = Cvar_Get( "joy_yaw", "100.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick yaw sensitivity" );
|
||||
joy_side = Cvar_Get( "joy_side", "1.0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "joystick side sensitivity. Values from -1.0 to 1.0" );
|
||||
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 );
|
||||
Cvar_RegisterVariable( &joy_rt_threshold );
|
||||
joy_lt_threshold = Cvar_Get( "joy_lt_threshold", "16384", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "left trigger threshold. Value from 0 to 32767");
|
||||
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
|
||||
Cvar_RegisterVariable( &joy_side_key_threshold );
|
||||
Cvar_RegisterVariable( &joy_forward_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" );
|
||||
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
|
||||
Cvar_RegisterVariable( &joy_side_deadzone );
|
||||
Cvar_RegisterVariable( &joy_forward_deadzone );
|
||||
Cvar_RegisterVariable( &joy_pitch_deadzone );
|
||||
Cvar_RegisterVariable( &joy_yaw_deadzone );
|
||||
joy_side_deadzone = Cvar_Get( "joy_side_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "side axis deadzone. Value from 0 to 32767" );
|
||||
joy_forward_deadzone = Cvar_Get( "joy_forward_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "forward axis deadzone. Value from 0 to 32767");
|
||||
joy_pitch_deadzone = Cvar_Get( "joy_pitch_deadzone", DEFAULT_JOY_DEADZONE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "pitch axis deadzone. Value from 0 to 32767");
|
||||
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 );
|
||||
Cvar_RegisterVariable( &joy_found );
|
||||
joy_axis_binding = Cvar_Get( "joy_axis_binding", "sfpyrl", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "axis hardware id to engine inner axis binding, "
|
||||
"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.
|
||||
// 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
|
||||
// client.dll's joystick support
|
||||
@@ -417,7 +416,7 @@ void Joy_Init( void )
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -132,8 +132,6 @@ static struct touch_s
|
||||
int whitetexture;
|
||||
int joytexture; // touch indicator
|
||||
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;
|
||||
|
||||
// private to the engine flags
|
||||
@@ -142,27 +140,28 @@ static struct touch_s
|
||||
touchdefaultbutton_t g_DefaultButtons[256];
|
||||
int g_LastDefaultButton;
|
||||
|
||||
static CVAR_DEFINE_AUTO( touch_in_menu, "0", FCVAR_FILTERABLE, "draw touch in menu (for internal use only)" );
|
||||
static CVAR_DEFINE_AUTO( touch_forwardzone, "0.06", FCVAR_FILTERABLE, "forward touch zone" );
|
||||
static CVAR_DEFINE_AUTO( touch_sidezone, "0.06", FCVAR_FILTERABLE, "side touch zone" );
|
||||
static CVAR_DEFINE_AUTO( touch_pitch, "90", FCVAR_FILTERABLE, "touch pitch sensitivity" );
|
||||
static CVAR_DEFINE_AUTO( touch_yaw, "120", FCVAR_FILTERABLE, "touch yaw sensitivity" );
|
||||
static CVAR_DEFINE_AUTO( touch_nonlinear_look, "0", FCVAR_FILTERABLE, "enable nonlinear touch look" );
|
||||
static CVAR_DEFINE_AUTO( touch_pow_factor, "1.3", FCVAR_FILTERABLE, "set > 1 to enable" );
|
||||
static CVAR_DEFINE_AUTO( touch_pow_mult, "400.0", FCVAR_FILTERABLE, "power multiplier, usually 200-1000" );
|
||||
static CVAR_DEFINE_AUTO( touch_exp_mult, "0", FCVAR_FILTERABLE, "exponent multiplier, usually 20-200, 0 to disable" );
|
||||
static CVAR_DEFINE_AUTO( touch_grid_count, "50", FCVAR_FILTERABLE, "touch grid count" );
|
||||
static CVAR_DEFINE_AUTO( touch_grid_enable, "1", FCVAR_FILTERABLE, "enable touch grid" );
|
||||
static CVAR_DEFINE_AUTO( touch_config_file, "touch.cfg", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "current touch profile file" );
|
||||
static CVAR_DEFINE_AUTO( touch_precise_amount, "0.5", FCVAR_FILTERABLE, "sensitivity multiplier for precise-look" );
|
||||
static CVAR_DEFINE_AUTO( touch_highlight_r, "1.0", 0, "highlight r color" );
|
||||
static CVAR_DEFINE_AUTO( touch_highlight_g, "1.0", 0, "highlight g color" );
|
||||
static CVAR_DEFINE_AUTO( touch_highlight_b, "1.0", 0, "highlight b color" );
|
||||
static CVAR_DEFINE_AUTO( touch_highlight_a, "1.0", 0, "highlight alpha" );
|
||||
static CVAR_DEFINE_AUTO( touch_dpad_radius, "1.0", FCVAR_FILTERABLE, "dpad radius multiplier" );
|
||||
static CVAR_DEFINE_AUTO( touch_joy_radius, "1.0", FCVAR_FILTERABLE, "joy radius multiplier" );
|
||||
static CVAR_DEFINE_AUTO( touch_move_indicator, "0.0", FCVAR_FILTERABLE, "indicate move events (0 to disable)" );
|
||||
static CVAR_DEFINE_AUTO( touch_joy_texture, "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator");
|
||||
convar_t *touch_pitch;
|
||||
convar_t *touch_yaw;
|
||||
convar_t *touch_forwardzone;
|
||||
convar_t *touch_sidezone;
|
||||
convar_t *touch_nonlinear_look;
|
||||
convar_t *touch_pow_mult;
|
||||
convar_t *touch_pow_factor;
|
||||
convar_t *touch_exp_mult;
|
||||
convar_t *touch_grid_enable;
|
||||
convar_t *touch_grid_count;
|
||||
convar_t *touch_config_file;
|
||||
convar_t *touch_in_menu;
|
||||
convar_t *touch_joy_radius;
|
||||
convar_t *touch_dpad_radius;
|
||||
convar_t *touch_move_indicator;
|
||||
convar_t *touch_highlight_r;
|
||||
convar_t *touch_highlight_g;
|
||||
convar_t *touch_highlight_b;
|
||||
convar_t *touch_highlight_a;
|
||||
convar_t *touch_precise_amount;
|
||||
convar_t *touch_joy_texture;
|
||||
|
||||
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" );
|
||||
|
||||
@@ -170,42 +169,13 @@ CVAR_DEFINE_AUTO( touch_emulate, "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "emulate
|
||||
#define B(x) (button->x)
|
||||
#define SCR_W ((float)refState.width)
|
||||
#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))
|
||||
|
||||
static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 );
|
||||
static void IN_TouchEditClear( 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
|
||||
@@ -237,7 +207,7 @@ static inline int Touch_ExportButtonToConfig( file_t *f, touch_button_t *button,
|
||||
|
||||
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 );
|
||||
}
|
||||
else FS_Printf( f, "\n" );
|
||||
@@ -272,38 +242,36 @@ qboolean Touch_DumpConfig( const char *name, const char *profilename )
|
||||
FS_Printf( f, "\ntouch_config_file \"%s\"\n", profilename );
|
||||
FS_Printf( f, "\n// touch cvars\n" );
|
||||
FS_Printf( f, "\n// sensitivity settings\n" );
|
||||
FS_Printf( f, "touch_pitch \"%f\"\n", touch_pitch.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_sidezone \"%f\"\n", touch_sidezone.value );
|
||||
FS_Printf( f, "touch_nonlinear_look \"%d\"\n", touch_nonlinear_look.value ? 1 : 0 );
|
||||
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_exp_mult \"%f\"\n", touch_exp_mult.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_forwardzone \"%f\"\n", touch_forwardzone->value );
|
||||
FS_Printf( f, "touch_sidezone \"%f\"\n", touch_sidezone->value );
|
||||
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_mult \"%f\"\n", touch_pow_mult->value );
|
||||
FS_Printf( f, "touch_exp_mult \"%f\"\n", touch_exp_mult->value );
|
||||
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_enable \"%d\"\n", touch_grid_enable.value ? 1 : 0 );
|
||||
FS_Printf( f, "touch_grid_count \"%d\"\n", (int)touch_grid_count->value );
|
||||
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, "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, "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_b \"%f\"\n", touch_highlight_b.value );
|
||||
FS_Printf( f, "touch_highlight_a \"%f\"\n", touch_highlight_a.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_b \"%f\"\n", touch_highlight_b->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, "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_dpad_radius \"%f\"\n", touch_dpad_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, "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, "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, "touch_setclientonly 0\n" );
|
||||
FS_Printf( f, "\n// touch buttons\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 )
|
||||
{
|
||||
@@ -333,18 +301,18 @@ void Touch_WriteConfig( void )
|
||||
if( Sys_CheckParm( "-nowriteconfig" ) || !touch.configchanged || !touch.config_loaded )
|
||||
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( oldconfigfile, sizeof( oldconfigfile ), "%s.bak", 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 );
|
||||
|
||||
if( Touch_DumpConfig( newconfigfile, touch_config_file.string ))
|
||||
if( Touch_DumpConfig( newconfigfile, touch_config_file->string ))
|
||||
{
|
||||
FS_Delete( oldconfigfile );
|
||||
FS_Rename( touch_config_file.string, oldconfigfile );
|
||||
FS_Rename( touch_config_file->string, oldconfigfile );
|
||||
|
||||
FS_Delete( touch_config_file.string );
|
||||
FS_Rename( newconfigfile, touch_config_file.string );
|
||||
FS_Delete( 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 ))
|
||||
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 ) ) )
|
||||
{
|
||||
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;
|
||||
|
||||
if( !touch_grid_enable.value )
|
||||
if( !touch_grid_enable->value )
|
||||
return;
|
||||
|
||||
for( button = touch.list_user.first; button; button = button->next )
|
||||
@@ -582,7 +550,6 @@ static void Touch_RemoveAll_f( void )
|
||||
{
|
||||
IN_TouchEditClear();
|
||||
Touch_ClearList( &touch.list_user );
|
||||
touch.config_aspect_ratio = 0.0f;
|
||||
}
|
||||
|
||||
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" );
|
||||
}
|
||||
|
||||
static void Touch_LoadDefaults_f( void );
|
||||
|
||||
static void Touch_ReloadConfig_f( void )
|
||||
{
|
||||
touch.state = state_none;
|
||||
@@ -771,15 +736,8 @@ static void Touch_ReloadConfig_f( void )
|
||||
touch.selection->finger = -1;
|
||||
touch.edit = touch.selection = NULL;
|
||||
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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Touch_LoadDefaults_f();
|
||||
touch.configchanged = true;
|
||||
}
|
||||
|
||||
Cbuf_AddTextf( "exec %s\n", touch_config_file->string );
|
||||
}
|
||||
|
||||
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 );
|
||||
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->flags |= flags | TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT;
|
||||
@@ -852,7 +810,7 @@ static void Touch_LoadDefaults_f( void )
|
||||
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;
|
||||
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 );
|
||||
@@ -860,7 +818,6 @@ static void Touch_LoadDefaults_f( void )
|
||||
button->flags |= g_DefaultButtons[i].flags;
|
||||
button->aspect = g_DefaultButtons[i].aspect;
|
||||
}
|
||||
touch.configchanged = true;
|
||||
}
|
||||
|
||||
// Add default button from client
|
||||
@@ -953,7 +910,7 @@ static void Touch_AddButton_f( void )
|
||||
if( aspect )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -961,39 +918,11 @@ static void Touch_AddButton_f( void )
|
||||
|
||||
static void Touch_EnableEdit_f( void )
|
||||
{
|
||||
touch_button_t *button;
|
||||
float current_ratio = SCR_H/SCR_W;
|
||||
if( touch.state == state_none )
|
||||
touch.state = state_edit;
|
||||
touch.resize_finger = touch.move_finger = touch.look_finger = touch.wheel_finger = -1;
|
||||
touch.move_button = NULL;
|
||||
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 )
|
||||
@@ -1006,7 +935,7 @@ static void Touch_DisableEdit_f( void )
|
||||
touch.edit = touch.selection = NULL;
|
||||
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" );
|
||||
}
|
||||
@@ -1028,7 +957,7 @@ static void Touch_DeleteProfile_f( void )
|
||||
|
||||
static void Touch_InitEditor( void )
|
||||
{
|
||||
float x = 0.1f * (Touch_AspectRatio());
|
||||
float x = 0.1f * (SCR_H/SCR_W);
|
||||
float y = 0.05f;
|
||||
touch_button_t *temp;
|
||||
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_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_aspectratio", Touch_ConfigAspectRatio_f, "set current aspect ratio" );
|
||||
|
||||
// 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
|
||||
Cvar_RegisterVariable( &touch_forwardzone );
|
||||
Cvar_RegisterVariable( &touch_sidezone );
|
||||
Cvar_RegisterVariable( &touch_pitch );
|
||||
Cvar_RegisterVariable( &touch_yaw );
|
||||
Cvar_RegisterVariable( &touch_nonlinear_look );
|
||||
Cvar_RegisterVariable( &touch_pow_factor );
|
||||
Cvar_RegisterVariable( &touch_pow_mult );
|
||||
Cvar_RegisterVariable( &touch_exp_mult );
|
||||
touch_forwardzone = Cvar_Get( "touch_forwardzone", "0.06", FCVAR_FILTERABLE, "forward touch zone" );
|
||||
touch_sidezone = Cvar_Get( "touch_sidezone", "0.06", FCVAR_FILTERABLE, "side touch zone" );
|
||||
touch_pitch = Cvar_Get( "touch_pitch", "90", FCVAR_FILTERABLE, "touch pitch sensitivity" );
|
||||
touch_yaw = Cvar_Get( "touch_yaw", "120", FCVAR_FILTERABLE, "touch yaw sensitivity" );
|
||||
touch_nonlinear_look = Cvar_Get( "touch_nonlinear_look", "0", FCVAR_FILTERABLE, "enable nonlinear touch look" );
|
||||
touch_pow_factor = Cvar_Get( "touch_pow_factor", "1.3", FCVAR_FILTERABLE, "set > 1 to enable" );
|
||||
touch_pow_mult = Cvar_Get( "touch_pow_mult", "400.0", FCVAR_FILTERABLE, "power multiplier, usually 200-1000" );
|
||||
touch_exp_mult = Cvar_Get( "touch_exp_mult", "0", FCVAR_FILTERABLE, "exponent multiplier, usually 20-200, 0 to disable" );
|
||||
|
||||
// touch.cfg
|
||||
Cvar_RegisterVariable( &touch_grid_count );
|
||||
Cvar_RegisterVariable( &touch_grid_enable );
|
||||
Cvar_RegisterVariable( &touch_config_file );
|
||||
Cvar_RegisterVariable( &touch_precise_amount );
|
||||
Cvar_RegisterVariable( &touch_highlight_r );
|
||||
Cvar_RegisterVariable( &touch_highlight_g );
|
||||
Cvar_RegisterVariable( &touch_highlight_b );
|
||||
Cvar_RegisterVariable( &touch_highlight_a );
|
||||
Cvar_RegisterVariable( &touch_dpad_radius );
|
||||
Cvar_RegisterVariable( &touch_joy_radius );
|
||||
Cvar_RegisterVariable( &touch_move_indicator );
|
||||
Cvar_RegisterVariable( &touch_joy_texture );
|
||||
touch_grid_count = Cvar_Get( "touch_grid_count", "50", FCVAR_FILTERABLE, "touch grid count" );
|
||||
touch_grid_enable = Cvar_Get( "touch_grid_enable", "1", FCVAR_FILTERABLE, "enable touch grid" );
|
||||
touch_config_file = Cvar_Get( "touch_config_file", "touch.cfg", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "current touch profile file" );
|
||||
touch_precise_amount = Cvar_Get( "touch_precise_amount", "0.5", FCVAR_FILTERABLE, "sensitivity multiplier for precise-look" );
|
||||
touch_highlight_r = Cvar_Get( "touch_highlight_r", "1.0", 0, "highlight r color" );
|
||||
touch_highlight_g = Cvar_Get( "touch_highlight_g", "1.0", 0, "highlight g color" );
|
||||
touch_highlight_b = Cvar_Get( "touch_highlight_b", "1.0", 0, "highlight b color" );
|
||||
touch_highlight_a = Cvar_Get( "touch_highlight_a", "1.0", 0, "highlight alpha" );
|
||||
touch_dpad_radius = Cvar_Get( "touch_dpad_radius", "1.0", FCVAR_FILTERABLE, "dpad radius multiplier" );
|
||||
touch_joy_radius = Cvar_Get( "touch_joy_radius", "1.0", FCVAR_FILTERABLE, "joy radius multiplier" );
|
||||
touch_move_indicator = Cvar_Get( "touch_move_indicator", "0.0", FCVAR_FILTERABLE, "indicate move events (0 to disable)" );
|
||||
touch_joy_texture = Cvar_Get( "touch_joy_texture", "touch_default/joy", FCVAR_FILTERABLE, "texture for move indicator");
|
||||
|
||||
// input devices cvar
|
||||
Cvar_RegisterVariable( &touch_enable );
|
||||
@@ -1160,7 +1088,7 @@ void Touch_Init( void )
|
||||
#if SDL_VERSION_ATLEAST( 2, 0, 10 )
|
||||
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_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" );
|
||||
#endif
|
||||
|
||||
@@ -1181,9 +1109,9 @@ static void Touch_InitConfig( void )
|
||||
|
||||
/// TODO: hud font
|
||||
//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();
|
||||
}
|
||||
else
|
||||
@@ -1192,7 +1120,7 @@ static void Touch_InitConfig( void )
|
||||
}
|
||||
|
||||
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.configchanged = false;
|
||||
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 );
|
||||
}
|
||||
|
||||
#define GRID_COUNT_X ((int)touch_grid_count.value)
|
||||
#define GRID_COUNT_Y (((int)touch_grid_count.value) * Touch_AspectRatio())
|
||||
#define GRID_COUNT_X ((int)touch_grid_count->value)
|
||||
#define GRID_COUNT_Y (((int)touch_grid_count->value) * SCR_H / SCR_W)
|
||||
#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_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;
|
||||
if( *x2 > 1 )
|
||||
*x1 -= *x2 - 1, *x2 = 1;
|
||||
if( touch_grid_enable.value )
|
||||
if( CVAR_TO_BOOL( touch_grid_enable ))
|
||||
{
|
||||
*x1 = GRID_ROUND_X( *x1 );
|
||||
*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 ) )
|
||||
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 )
|
||||
break;
|
||||
@@ -1360,10 +1288,10 @@ static void Touch_DrawButtons( touchbuttonlist_t *list )
|
||||
|
||||
if( ( B( finger ) != -1 ) && !FBitSet( B( flags ), TOUCH_FL_CLIENT ) )
|
||||
{
|
||||
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[2] = bound( 0,(float) color[2] * touch_highlight_b.value, 255 );
|
||||
color[3] = bound( 0,(float) color[3] * touch_highlight_a.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[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] *= B( fade );
|
||||
@@ -1430,18 +1358,17 @@ void Touch_Draw( void )
|
||||
if( !touch.initialized || ( !touch_enable.value && !touch.clientonly ))
|
||||
return;
|
||||
|
||||
if( cls.key_dest != key_game && !touch_in_menu.value )
|
||||
return;
|
||||
|
||||
Touch_InitConfig();
|
||||
|
||||
if( cls.key_dest != key_game && !CVAR_TO_BOOL(touch_in_menu) )
|
||||
return;
|
||||
|
||||
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;
|
||||
if( touch_in_menu.value )
|
||||
if( CVAR_TO_BOOL(touch_in_menu) )
|
||||
Touch_DrawTexture( 0, 0, 1, 1, touch.whitetexture, 32, 32, 32, 255 );
|
||||
else
|
||||
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 );
|
||||
|
||||
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 height;
|
||||
if( FBitSet( touch_joy_texture.flags, FCVAR_CHANGED ) )
|
||||
if( FBitSet( 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 );
|
||||
ClearBits( touch_joy_texture->flags, FCVAR_CHANGED );
|
||||
touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
|
||||
}
|
||||
if( touch.move_button->type == touch_move )
|
||||
{
|
||||
width = touch_sidezone.value;
|
||||
height = touch_forwardzone.value;
|
||||
width = touch_sidezone->value;
|
||||
height = touch_forwardzone->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1522,13 +1449,13 @@ void Touch_Draw( void )
|
||||
height = (touch.move_button->y2 - touch.move_button->y1)/2;
|
||||
}
|
||||
ref.dllFuncs.Color4ub( 255, 255, 255, 128 );
|
||||
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_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.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_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.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_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.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_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 )
|
||||
{
|
||||
// check bounds
|
||||
if( touch_forwardzone.value <= 0 )
|
||||
if( touch_forwardzone->value <= 0 )
|
||||
Cvar_SetValue( "touch_forwardzone", 0.5 );
|
||||
if( touch_sidezone.value <= 0 )
|
||||
if( touch_sidezone->value <= 0 )
|
||||
Cvar_SetValue( "touch_sidezone", 0.3 );
|
||||
|
||||
if( !touch.move_button || touch.move_button->type == touch_move )
|
||||
{
|
||||
// move relative to touch start
|
||||
touch.forward = ( touch.move_start_y - y ) / touch_forwardzone.value;
|
||||
touch.side = ( x - touch.move_start_x ) / touch_sidezone.value;
|
||||
touch.forward = ( touch.move_start_y - y ) / touch_forwardzone->value;
|
||||
touch.side = ( x - touch.move_start_x ) / touch_sidezone->value;
|
||||
}
|
||||
else if( touch.move_button->type == touch_joy )
|
||||
{
|
||||
// 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.side = ( x * 2 - ( touch.move_button->x2 + touch.move_button->x1 ) ) / ( touch.move_button->x2 - touch.move_button->x1 ) * 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;
|
||||
}
|
||||
else if( touch.move_button->type == touch_dpad )
|
||||
{
|
||||
// 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.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 = 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.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( 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;
|
||||
|
||||
@@ -1684,11 +1611,11 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
|
||||
dcos = dx / dabs;
|
||||
dsin = dy / dabs;
|
||||
|
||||
if( touch_exp_mult.value > 1 )
|
||||
dabs = ( exp( dabs * touch_exp_mult.value ) - 1 ) / touch_exp_mult.value;
|
||||
if( touch_exp_mult->value > 1 )
|
||||
dabs = ( exp( dabs * touch_exp_mult->value ) - 1 ) / touch_exp_mult->value;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
dx = dabs * dcos;
|
||||
dy = dabs * dsin;
|
||||
@@ -1699,7 +1626,7 @@ static void Touch_Motion( touchEventType type, int fingerID, float x, float y, f
|
||||
return;
|
||||
|
||||
// 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 )
|
||||
{
|
||||
y *= SCR_H/SCR_W/Touch_AspectRatio();
|
||||
// Con_Printf("%f %f\n", TO_SCRN_X(x), TO_SCRN_Y(y));
|
||||
// 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;
|
||||
// Hack for keyboard, hope it help
|
||||
|
||||
@@ -36,15 +36,16 @@ static struct inputstate_s
|
||||
float lastpitch, lastyaw;
|
||||
} inputstate;
|
||||
|
||||
CVAR_DEFINE_AUTO( m_pitch, "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse pitch value" );
|
||||
CVAR_DEFINE_AUTO( m_yaw, "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse yaw value" );
|
||||
CVAR_DEFINE_AUTO( m_ignore, DEFAULT_M_IGNORE, FCVAR_ARCHIVE | FCVAR_FILTERABLE, "ignore mouse events" );
|
||||
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" );
|
||||
extern convar_t *vid_fullscreen;
|
||||
convar_t *m_pitch;
|
||||
convar_t *m_yaw;
|
||||
|
||||
static CVAR_DEFINE_AUTO( cl_forwardspeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default forward move speed" );
|
||||
static CVAR_DEFINE_AUTO( cl_backspeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default back move speed" );
|
||||
static CVAR_DEFINE_AUTO( cl_sidespeed, "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default side move speed" );
|
||||
convar_t *m_ignore;
|
||||
convar_t *cl_forwardspeed;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if( touch_enable.value )
|
||||
@@ -85,18 +86,18 @@ player is connected to the server
|
||||
*/
|
||||
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 )
|
||||
{
|
||||
SetBits( m_ignore.flags, FCVAR_READ_ONLY );
|
||||
SetBits( joy_enable.flags, FCVAR_READ_ONLY );
|
||||
SetBits( m_ignore->flags, FCVAR_READ_ONLY );
|
||||
SetBits( joy_enable->flags, FCVAR_READ_ONLY );
|
||||
SetBits( touch_enable.flags, FCVAR_READ_ONLY );
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearBits( m_ignore.flags, FCVAR_READ_ONLY );
|
||||
ClearBits( joy_enable.flags, FCVAR_READ_ONLY );
|
||||
ClearBits( m_ignore->flags, FCVAR_READ_ONLY );
|
||||
ClearBits( joy_enable->flags, FCVAR_READ_ONLY );
|
||||
ClearBits( touch_enable.flags, FCVAR_READ_ONLY );
|
||||
}
|
||||
}
|
||||
@@ -109,12 +110,12 @@ IN_StartupMouse
|
||||
*/
|
||||
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 );
|
||||
Cvar_RegisterVariable( &m_yaw );
|
||||
Cvar_RegisterVariable( &look_filter );
|
||||
Cvar_RegisterVariable( &m_rawinput );
|
||||
m_pitch = Cvar_Get( "m_pitch", "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse pitch value" );
|
||||
m_yaw = Cvar_Get( "m_yaw", "0.022", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "mouse yaw value" );
|
||||
look_filter = Cvar_Get( "look_filter", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "filter look events making it smoother" );
|
||||
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
|
||||
// -noenginemouse will disable all mouse input
|
||||
@@ -179,6 +180,9 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
{
|
||||
Platform_SetCursorType( dc_arrow );
|
||||
|
||||
#if XASH_ANDROID
|
||||
Android_ShowMouse( true );
|
||||
#endif
|
||||
#if XASH_USE_EVDEV
|
||||
Evdev_SetGrab( false );
|
||||
#endif
|
||||
@@ -187,15 +191,14 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
{
|
||||
Platform_SetCursorType( dc_none );
|
||||
|
||||
#if XASH_ANDROID
|
||||
Android_ShowMouse( false );
|
||||
#endif
|
||||
#if XASH_USE_EVDEV
|
||||
Evdev_SetGrab( true );
|
||||
#endif
|
||||
}
|
||||
|
||||
// don't leave the user without cursor if they enabled m_ignore
|
||||
if( m_ignore.value )
|
||||
return;
|
||||
|
||||
if( oldstate == key_game )
|
||||
{
|
||||
IN_DeactivateMouse();
|
||||
@@ -211,14 +214,11 @@ void IN_CheckMouseState( qboolean active )
|
||||
static qboolean s_bRawInput, s_bMouseGrab;
|
||||
|
||||
#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
|
||||
qboolean useRawInput = true; // always use SDL code
|
||||
#endif
|
||||
|
||||
if( m_ignore.value )
|
||||
return;
|
||||
|
||||
if( active && useRawInput && !host.mouse_visible && cls.state == ca_active )
|
||||
{
|
||||
if( !s_bRawInput )
|
||||
@@ -414,9 +414,9 @@ IN_Init
|
||||
*/
|
||||
void IN_Init( void )
|
||||
{
|
||||
Cvar_RegisterVariable( &cl_forwardspeed );
|
||||
Cvar_RegisterVariable( &cl_backspeed );
|
||||
Cvar_RegisterVariable( &cl_sidespeed );
|
||||
cl_forwardspeed = Cvar_Get( "cl_forwardspeed", "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default forward move speed" );
|
||||
cl_backspeed = Cvar_Get( "cl_backspeed", "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default back move speed" );
|
||||
cl_sidespeed = Cvar_Get( "cl_sidespeed", "400", FCVAR_ARCHIVE | FCVAR_CLIENTDLL | FCVAR_FILTERABLE, "Default side move speed" );
|
||||
|
||||
if( !Host_IsDedicated() )
|
||||
{
|
||||
@@ -453,8 +453,8 @@ static void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove
|
||||
{
|
||||
static uint moveflags = T | S;
|
||||
|
||||
if( forwardmove ) cmd->forwardmove = forwardmove * cl_forwardspeed.value;
|
||||
if( sidemove ) cmd->sidemove = sidemove * cl_sidespeed.value;
|
||||
if( forwardmove ) cmd->forwardmove = forwardmove * cl_forwardspeed->value;
|
||||
if( sidemove ) cmd->sidemove = sidemove * cl_sidespeed->value;
|
||||
|
||||
if( forwardmove )
|
||||
{
|
||||
@@ -529,8 +529,8 @@ static void IN_CollectInput( float *forward, float *side, float *pitch, float *y
|
||||
{
|
||||
float x, y;
|
||||
Platform_MouseMove( &x, &y );
|
||||
*pitch += y * m_pitch.value;
|
||||
*yaw -= x * m_yaw.value;
|
||||
*pitch += y * m_pitch->value;
|
||||
*yaw -= x * m_yaw->value;
|
||||
|
||||
#if XASH_USE_EVDEV
|
||||
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 );
|
||||
Touch_GetMove( forward, side, yaw, pitch );
|
||||
|
||||
if( look_filter.value )
|
||||
if( look_filter->value )
|
||||
{
|
||||
*pitch = ( inputstate.lastpitch + *pitch ) / 2;
|
||||
*yaw = ( inputstate.lastyaw + *yaw ) / 2;
|
||||
@@ -598,7 +598,7 @@ void IN_Commands( void )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
|
||||
@@ -46,8 +46,8 @@ uint IN_CollectInputDevices( void );
|
||||
void IN_LockInputDevices( qboolean lock );
|
||||
void IN_EngineAppendMove( float frametime, void *cmd, qboolean active );
|
||||
|
||||
extern convar_t m_yaw;
|
||||
extern convar_t m_pitch;
|
||||
extern convar_t *m_yaw;
|
||||
extern convar_t *m_pitch;
|
||||
//
|
||||
// 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 );
|
||||
void Touch_KeyEvent( int key, int down );
|
||||
qboolean Touch_WantVisibleCursor( void );
|
||||
void Touch_NotifyResize( void );
|
||||
|
||||
//
|
||||
// in_joy.c
|
||||
|
||||
@@ -144,8 +144,8 @@ keyname_t keynames[] =
|
||||
|
||||
static void OSK_EnableTextInput( qboolean enable, qboolean force );
|
||||
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 CVAR_DEFINE_AUTO( key_rotate, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "rotate arrow keys (0-3)" );
|
||||
static convar_t *osk_enable;
|
||||
static convar_t *key_rotate;
|
||||
|
||||
/*
|
||||
===================
|
||||
@@ -513,8 +513,8 @@ void Key_Init( void )
|
||||
// setup default binding. "unbindall" from config.cfg will be reset it
|
||||
for( kn = keynames; kn->name; kn++ ) Key_SetBinding( kn->keynum, kn->binding );
|
||||
|
||||
Cvar_RegisterVariable( &osk_enable );
|
||||
Cvar_RegisterVariable( &key_rotate );
|
||||
osk_enable = Cvar_Get( "osk_enable", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "enable built-in on-screen keyboard" );
|
||||
key_rotate = Cvar_Get( "key_rotate", "0", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "rotate arrow keys (0-3)" );
|
||||
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ static qboolean Key_IsAllowedAutoRepeat( 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 )
|
||||
key = K_LEFTARROW;
|
||||
@@ -602,7 +602,7 @@ static int Key_Rotate( int key )
|
||||
key = K_RIGHTARROW;
|
||||
}
|
||||
|
||||
else if( key_rotate.value == 3.0f ) // CCW
|
||||
else if( key_rotate->value == 3.0f ) // CCW
|
||||
{
|
||||
if( key == K_UPARROW )
|
||||
key = K_RIGHTARROW;
|
||||
@@ -614,7 +614,7 @@ static int Key_Rotate( int key )
|
||||
key = K_LEFTARROW;
|
||||
}
|
||||
|
||||
else if( key_rotate.value == 2.0f )
|
||||
else if( key_rotate->value == 2.0f )
|
||||
{
|
||||
if( key == K_UPARROW )
|
||||
key = K_DOWNARROW;
|
||||
@@ -719,10 +719,10 @@ void GAME_EXPORT Key_Event( int key, int down )
|
||||
switch( cls.key_dest )
|
||||
{
|
||||
case key_game:
|
||||
if( r_showtextures.value )
|
||||
if( CVAR_TO_BOOL( gl_showtextures ))
|
||||
{
|
||||
// close texture atlas
|
||||
Cvar_DirectSet( &r_showtextures, "0" );
|
||||
Cvar_SetValue( "r_showtextures", 0.0f );
|
||||
return;
|
||||
}
|
||||
else if( host.mouse_visible && cls.state != ca_cinematic )
|
||||
@@ -797,7 +797,7 @@ Key_EnableTextInput
|
||||
*/
|
||||
void Key_EnableTextInput( qboolean enable, qboolean force )
|
||||
{
|
||||
if( osk_enable.value )
|
||||
if( CVAR_TO_BOOL( osk_enable ) )
|
||||
{
|
||||
OSK_EnableTextInput( enable, force );
|
||||
return;
|
||||
@@ -995,7 +995,7 @@ struct osk_s
|
||||
|
||||
static qboolean OSK_KeyEvent( int key, int down )
|
||||
{
|
||||
if( !osk.enable || !osk_enable.value )
|
||||
if( !osk.enable || !CVAR_TO_BOOL( osk_enable ) )
|
||||
return false;
|
||||
|
||||
if( osk.sending )
|
||||
@@ -1055,7 +1055,7 @@ static qboolean OSK_KeyEvent( int key, int down )
|
||||
break;
|
||||
}
|
||||
|
||||
if( !Q_stricmp( cl_charset.string, "utf-8" ) )
|
||||
if( !Q_stricmp( cl_charset->string, "utf-8" ) )
|
||||
ch = (unsigned char)osk.curbutton.val;
|
||||
else
|
||||
ch = Con_UtfProcessCharForce( (unsigned char)osk.curbutton.val );
|
||||
@@ -1190,7 +1190,7 @@ void OSK_Draw( void )
|
||||
float x, y;
|
||||
int i, j;
|
||||
|
||||
if( !osk.enable || !osk_enable.value || !osk.curbutton.val )
|
||||
if( !osk.enable || !CVAR_TO_BOOL(osk_enable) || !osk.curbutton.val )
|
||||
return;
|
||||
|
||||
// draw keyboard
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
void Mod_InitDebugHulls( model_t *loadmodel )
|
||||
void Mod_InitDebugHulls( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -8,15 +8,14 @@
|
||||
struct ref_state_s ref;
|
||||
ref_globals_t refState;
|
||||
|
||||
CVAR_DEFINE_AUTO( gl_vsync, "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
|
||||
CVAR_DEFINE_AUTO( r_showtextures, "0", FCVAR_CHEAT, "show all uploaded textures" );
|
||||
CVAR_DEFINE_AUTO( r_adjust_fov, "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
|
||||
CVAR_DEFINE_AUTO( r_decals, "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
|
||||
CVAR_DEFINE_AUTO( gl_msaa_samples, "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" );
|
||||
CVAR_DEFINE_AUTO( gl_clear, "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
|
||||
CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
|
||||
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
|
||||
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
|
||||
convar_t *gl_vsync;
|
||||
convar_t *gl_showtextures;
|
||||
convar_t *r_decals;
|
||||
convar_t *r_adjust_fov;
|
||||
convar_t *r_showtree;
|
||||
convar_t *gl_msaa_samples;
|
||||
convar_t *gl_clear;
|
||||
convar_t *r_refdll;
|
||||
|
||||
void R_GetTextureParms( int *w, int *h, int texnum )
|
||||
{
|
||||
@@ -99,14 +98,24 @@ static void *pfnMod_Extradata( int type, model_t *m )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static model_t *pfnMod_GetCurrentLoadingModel( void )
|
||||
{
|
||||
return loadmodel;
|
||||
}
|
||||
|
||||
static void pfnMod_SetCurrentLoadingModel( model_t *m )
|
||||
{
|
||||
loadmodel = m;
|
||||
}
|
||||
|
||||
static void pfnGetPredictedOrigin( vec3_t v )
|
||||
{
|
||||
VectorCopy( cl.simorg, v );
|
||||
}
|
||||
|
||||
static color24 *pfnCL_GetPaletteColor( void ) // clgame.palette[color]
|
||||
static color24 *pfnCL_GetPaletteColor( int color ) // clgame.palette[color]
|
||||
{
|
||||
return clgame.palette;
|
||||
return &clgame.palette[color];
|
||||
}
|
||||
|
||||
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
|
||||
@@ -158,6 +167,11 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
|
||||
0;
|
||||
}
|
||||
|
||||
static poolhandle_t pfnImage_GetPool( void )
|
||||
{
|
||||
return host.imagepool;
|
||||
}
|
||||
|
||||
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
|
||||
{
|
||||
return &PFDesc[idx];
|
||||
@@ -207,11 +221,6 @@ static qboolean R_Init_Video_( const int type )
|
||||
return R_Init_Video( type );
|
||||
}
|
||||
|
||||
static model_t **pfnGetModels( void )
|
||||
{
|
||||
return cl.models;
|
||||
}
|
||||
|
||||
static ref_api_t gEngfuncs =
|
||||
{
|
||||
pfnEngineGetParm,
|
||||
@@ -222,7 +231,7 @@ static ref_api_t gEngfuncs =
|
||||
Cvar_VariableString,
|
||||
Cvar_SetValue,
|
||||
Cvar_Set,
|
||||
Cvar_RegisterVariable,
|
||||
(void*)Cvar_RegisterVariable,
|
||||
Cvar_FullSet,
|
||||
|
||||
Cmd_AddRefCommand,
|
||||
@@ -246,7 +255,9 @@ static ref_api_t gEngfuncs =
|
||||
Con_DrawString,
|
||||
CL_DrawCenterPrint,
|
||||
|
||||
CL_GetLocalPlayer,
|
||||
CL_GetViewModel,
|
||||
CL_GetEntityByIndex,
|
||||
R_BeamGetEntity,
|
||||
CL_GetWaterEntity,
|
||||
CL_AddVisibleEntity,
|
||||
@@ -270,10 +281,14 @@ static ref_api_t gEngfuncs =
|
||||
|
||||
Mod_ForName,
|
||||
pfnMod_Extradata,
|
||||
pfnGetModels,
|
||||
CL_ModelHandle,
|
||||
pfnMod_GetCurrentLoadingModel,
|
||||
pfnMod_SetCurrentLoadingModel,
|
||||
|
||||
CL_EntitySetRemapColors,
|
||||
CL_GetRemapInfoForEntity,
|
||||
CL_AllocRemapInfo,
|
||||
CL_FreeRemapInfo,
|
||||
CL_UpdateRemapInfo,
|
||||
|
||||
CL_ExtraUpdate,
|
||||
Host_Error,
|
||||
@@ -281,6 +296,7 @@ static ref_api_t gEngfuncs =
|
||||
COM_RandomFloat,
|
||||
COM_RandomLong,
|
||||
pfnRefGetScreenFade,
|
||||
CL_TextMessageGet,
|
||||
pfnGetPredictedOrigin,
|
||||
pfnCL_GetPaletteColor,
|
||||
pfnCL_GetScreenInfo,
|
||||
@@ -344,6 +360,7 @@ static ref_api_t gEngfuncs =
|
||||
FS_CopyImage,
|
||||
FS_FreeImage,
|
||||
Image_SetMDLPointer,
|
||||
pfnImage_GetPool,
|
||||
pfnImage_GetPFDesc,
|
||||
|
||||
pfnDrawNormalTriangles,
|
||||
@@ -362,14 +379,14 @@ static void R_UnloadProgs( void )
|
||||
|
||||
Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY );
|
||||
|
||||
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG );
|
||||
Cmd_Unlink( CMD_REFDLL );
|
||||
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
ref.hInstance = NULL;
|
||||
|
||||
memset( &refState, 0, sizeof( refState ));
|
||||
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 )
|
||||
@@ -425,7 +442,7 @@ static qboolean R_LoadProgs( const char *name )
|
||||
// make local copy of engfuncs to prevent overwrite it with user dll
|
||||
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
|
||||
|
||||
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
|
||||
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ))
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
|
||||
@@ -514,7 +531,6 @@ static qboolean R_LoadRenderer( const char *refopt )
|
||||
return false;
|
||||
}
|
||||
|
||||
Cvar_FullSet( "r_refdll_loaded", refopt, FCVAR_READ_ONLY );
|
||||
Con_Reportf( "Renderer %s initialized\n", refdll );
|
||||
|
||||
return true;
|
||||
@@ -533,17 +549,21 @@ static void SetWidthAndHeightFromCommandLine( void )
|
||||
return;
|
||||
}
|
||||
|
||||
R_SaveVideoMode( width, height, width, height, false );
|
||||
R_SaveVideoMode( width, height, width, height );
|
||||
}
|
||||
|
||||
static void SetFullscreenModeFromCommandLine( void )
|
||||
{
|
||||
if( Sys_CheckParm( "-borderless" ))
|
||||
Cvar_DirectSet( &vid_fullscreen, "2" );
|
||||
else if( Sys_CheckParm( "-fullscreen" ))
|
||||
Cvar_DirectSet( &vid_fullscreen, "1" );
|
||||
#if !XASH_MOBILE_PLATFORM
|
||||
if( Sys_CheckParm( "-fullscreen" ))
|
||||
{
|
||||
Cvar_Set( "fullscreen", "1" );
|
||||
}
|
||||
else if( Sys_CheckParm( "-windowed" ))
|
||||
Cvar_DirectSet( &vid_fullscreen, "0" );
|
||||
{
|
||||
Cvar_Set( "fullscreen", "0" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void R_CollectRendererNames( void )
|
||||
@@ -563,9 +583,6 @@ static void R_CollectRendererNames( void )
|
||||
#if XASH_REF_GL4ES_ENABLED
|
||||
"gl4es",
|
||||
#endif
|
||||
#if XASH_REF_GLES3COMPAT_ENABLED
|
||||
"gles3compat",
|
||||
#endif
|
||||
#if XASH_REF_SOFT_ENABLED
|
||||
"soft",
|
||||
#endif
|
||||
@@ -586,9 +603,6 @@ static void R_CollectRendererNames( void )
|
||||
#if XASH_REF_GL4ES_ENABLED
|
||||
"GL4ES",
|
||||
#endif
|
||||
#if XASH_REF_GLES3COMPAT_ENABLED
|
||||
"GLES3 (gl2_shim)"
|
||||
#endif
|
||||
#if XASH_REF_SOFT_ENABLED
|
||||
"Software",
|
||||
#endif
|
||||
@@ -604,15 +618,14 @@ qboolean R_Init( void )
|
||||
qboolean success = false;
|
||||
string requested;
|
||||
|
||||
Cvar_RegisterVariable( &gl_vsync );
|
||||
Cvar_RegisterVariable( &r_showtextures );
|
||||
Cvar_RegisterVariable( &r_adjust_fov );
|
||||
Cvar_RegisterVariable( &r_decals );
|
||||
Cvar_RegisterVariable( &gl_msaa_samples );
|
||||
Cvar_RegisterVariable( &gl_clear );
|
||||
Cvar_RegisterVariable( &r_showtree );
|
||||
Cvar_RegisterVariable( &r_refdll );
|
||||
Cvar_RegisterVariable( &r_refdll_loaded );
|
||||
gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
|
||||
gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" );
|
||||
r_adjust_fov = Cvar_Get( "r_adjust_fov", "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
|
||||
r_decals = Cvar_Get( "r_decals", "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
|
||||
gl_msaa_samples = Cvar_Get( "gl_msaa_samples", "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" );
|
||||
gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
|
||||
r_showtree = Cvar_Get( "r_showtree", "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
|
||||
r_refdll = Cvar_Get( "r_refdll", "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
|
||||
|
||||
// cvars that are expected to exist
|
||||
Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );
|
||||
@@ -656,9 +669,9 @@ qboolean R_Init( void )
|
||||
if( !success && Sys_GetParmFromCmdLine( "-ref", 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 );
|
||||
}
|
||||
|
||||
@@ -678,7 +691,7 @@ qboolean R_Init( void )
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ void R_GetTextureParms( int *w, int *h, int texnum );
|
||||
void GL_RenderFrame( const struct ref_viewpass_s *rvp );
|
||||
|
||||
// common engine and renderer cvars
|
||||
extern convar_t r_decals;
|
||||
extern convar_t r_adjust_fov;
|
||||
extern convar_t gl_clear;
|
||||
extern convar_t *r_decals;
|
||||
extern convar_t *r_adjust_fov;
|
||||
extern convar_t *gl_clear;
|
||||
|
||||
qboolean R_Init( void );
|
||||
void R_Shutdown( void );
|
||||
|
||||
@@ -78,7 +78,7 @@ typedef struct dly_s
|
||||
int *lpdelayline;
|
||||
} dly_t;
|
||||
|
||||
static const sx_preset_t rgsxpre[] =
|
||||
const sx_preset_t rgsxpre[] =
|
||||
{
|
||||
// -------reverb-------- -------delay--------
|
||||
// lp mod size refl rvblp delay feedback dlylp left
|
||||
@@ -115,7 +115,7 @@ static const sx_preset_t rgsxpre[] =
|
||||
|
||||
// 0x0045dca8 enginegl.exe
|
||||
// SHA256: 42383d32cd712e59ee2c1bd78b7ba48814e680e7026c4223e730111f34a60d66
|
||||
static const sx_preset_t rgsxpre_hlalpha052[] =
|
||||
const sx_preset_t rgsxpre_hlalpha052[] =
|
||||
{
|
||||
// -------reverb-------- -------delay--------
|
||||
// lp mod size refl rvblp delay feedback dlylp left
|
||||
@@ -150,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
|
||||
};
|
||||
|
||||
static const sx_preset_t *ptable = rgsxpre;
|
||||
const sx_preset_t *ptable = rgsxpre;
|
||||
|
||||
// cvars
|
||||
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing" );
|
||||
static CVAR_DEFINE_AUTO( dsp_coeff_table, "0", FCVAR_ARCHIVE, "select DSP coefficient table: 0 for release or 1 for alpha 0.52" );
|
||||
static CVAR_DEFINE_AUTO( room_type, "0", 0, "current room type preset" );
|
||||
|
||||
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" );
|
||||
convar_t *dsp_off; // disable dsp
|
||||
convar_t *roomwater_type; // water room_type
|
||||
convar_t *room_type; // current room type
|
||||
convar_t *hisound; // DSP quality
|
||||
|
||||
// underwater/special fx modulations
|
||||
static CVAR_DEFINE( sxmod_mod, "room_mod", "0", 0, "stereo amptitude modulation for room" );
|
||||
static CVAR_DEFINE( sxmod_lowpass, "room_lp", "0", 0, "for water fx, lowpass for entire room" );
|
||||
convar_t *sxmod_mod;
|
||||
convar_t *sxmod_lowpass;
|
||||
|
||||
// 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
|
||||
static CVAR_DEFINE( sxrvb_lp, "room_rvblp", "1", 0, "reverb: low pass filtering level" );
|
||||
static CVAR_DEFINE( sxrvb_feedback, "room_refl", "0", 0, "reverb: decay time" );
|
||||
static CVAR_DEFINE( sxrvb_size, "room_size", "0", 0, "reverb: initial reflection size" );
|
||||
convar_t *sxrvb_lp; // lowpass
|
||||
convar_t *sxrvb_feedback; // reverb decay. Higher -- longer
|
||||
convar_t *sxrvb_size; // room size. Higher -- larger
|
||||
|
||||
// mono delay
|
||||
static CVAR_DEFINE( sxdly_lp, "room_dlylp", "1", 0, "mono delay: low pass filtering level" );
|
||||
static CVAR_DEFINE( sxdly_feedback, "room_feedback", "0.2", 0, "mono delay: decay time" );
|
||||
static CVAR_DEFINE( sxdly_delay, "room_delay", "0.8", 0, "mono delay: delay time" );
|
||||
convar_t *sxdly_lp; // lowpass
|
||||
convar_t *sxdly_feedback; // cycles
|
||||
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;
|
||||
static int room_typeprev;
|
||||
int room_typeprev;
|
||||
|
||||
// routines
|
||||
static int sxamodl, sxamodr; // amplitude modulation values
|
||||
static int sxamodlt, sxamodrt; // modulation targets
|
||||
static int sxmod1cur, sxmod2cur;
|
||||
static int sxmod1, sxmod2;
|
||||
static int sxhires;
|
||||
int sxamodl, sxamodr; // amplitude modulation values
|
||||
int sxamodlt, sxamodrt; // modulation targets
|
||||
int sxmod1cur, sxmod2cur;
|
||||
int sxmod1, sxmod2;
|
||||
int sxhires;
|
||||
|
||||
static portable_samplepair_t *paintto = NULL;
|
||||
portable_samplepair_t *paintto = NULL;
|
||||
|
||||
static dly_t rgsxdly[MAXDLY]; // stereo is last
|
||||
static int rgsxlp[MAXLP];
|
||||
dly_t rgsxdly[MAXDLY]; // stereo is last
|
||||
int rgsxlp[MAXLP];
|
||||
|
||||
static void SX_Profiling_f( void );
|
||||
void SX_Profiling_f( void );
|
||||
|
||||
/*
|
||||
============
|
||||
@@ -201,12 +202,14 @@ SX_ReloadRoomFX
|
||||
|
||||
============
|
||||
*/
|
||||
static void SX_ReloadRoomFX( void )
|
||||
void SX_ReloadRoomFX( void )
|
||||
{
|
||||
SetBits( sxste_delay.flags, FCVAR_CHANGED );
|
||||
SetBits( sxrvb_feedback.flags, FCVAR_CHANGED );
|
||||
SetBits( sxdly_delay.flags, FCVAR_CHANGED );
|
||||
SetBits( room_type.flags, FCVAR_CHANGED );
|
||||
if( !dsp_room ) return; // not initialized
|
||||
|
||||
SetBits( sxste_delay->flags, FCVAR_CHANGED );
|
||||
SetBits( sxrvb_feedback->flags, FCVAR_CHANGED );
|
||||
SetBits( sxdly_delay->flags, FCVAR_CHANGED );
|
||||
SetBits( room_type->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -224,33 +227,36 @@ void SX_Init( void )
|
||||
sxamodr = sxamodl = sxamodrt = sxamodlt = 255;
|
||||
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;
|
||||
|
||||
sxmod1cur = sxmod1 = 350 * ( idsp_dma_speed / SOUND_11k );
|
||||
sxmod2cur = sxmod2 = 450 * ( idsp_dma_speed / SOUND_11k );
|
||||
|
||||
Cvar_RegisterVariable( &dsp_off );
|
||||
Cvar_RegisterVariable( &dsp_coeff_table );
|
||||
dsp_off = Cvar_Get( "dsp_off", "0", FCVAR_ARCHIVE, "disable DSP processing" );
|
||||
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 );
|
||||
Cvar_RegisterVariable( &room_type );
|
||||
roomwater_type = Cvar_Get( "waterroom_type", "14", 0, "water room type" );
|
||||
room_type = Cvar_Get( "room_type", "0", 0, "current room type preset" );
|
||||
|
||||
Cvar_RegisterVariable( &sxmod_lowpass );
|
||||
Cvar_RegisterVariable( &sxmod_mod );
|
||||
sxmod_lowpass = Cvar_Get( "room_lp", "0", 0, "for water fx, lowpass for entire room" );
|
||||
sxmod_mod = Cvar_Get( "room_mod", "0", 0, "stereo amptitude modulation for room" );
|
||||
|
||||
Cvar_RegisterVariable( &sxrvb_size );
|
||||
Cvar_RegisterVariable( &sxrvb_feedback );
|
||||
Cvar_RegisterVariable( &sxrvb_lp );
|
||||
sxrvb_size = Cvar_Get( "room_size", "0", 0, "reverb: initial reflection size" );
|
||||
sxrvb_feedback = Cvar_Get( "room_refl", "0", 0, "reverb: decay time" );
|
||||
sxrvb_lp = Cvar_Get( "room_rvblp", "1", 0, "reverb: low pass filtering level" );
|
||||
|
||||
Cvar_RegisterVariable( &sxdly_delay );
|
||||
Cvar_RegisterVariable( &sxdly_feedback );
|
||||
Cvar_RegisterVariable( &sxdly_lp );
|
||||
sxdly_delay = Cvar_Get( "room_delay", "0.8", 0, "mono delay: delay time" );
|
||||
sxdly_feedback = Cvar_Get( "room_feedback", "0.2", 0, "mono delay: decay time" );
|
||||
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" );
|
||||
|
||||
// for compability
|
||||
dsp_room = room_type;
|
||||
|
||||
SX_ReloadRoomFX();
|
||||
}
|
||||
|
||||
@@ -261,7 +267,7 @@ DLY_Free
|
||||
Free memory allocated for DSP
|
||||
===========
|
||||
*/
|
||||
static void DLY_Free( int idelay )
|
||||
void DLY_Free( int idelay )
|
||||
{
|
||||
Assert( idelay >= 0 && idelay < MAXDLY );
|
||||
|
||||
@@ -297,7 +303,7 @@ DLY_Init
|
||||
Initialize dly
|
||||
===========
|
||||
*/
|
||||
static int DLY_Init( int idelay, float delay )
|
||||
int DLY_Init( int idelay, float delay )
|
||||
{
|
||||
dly_t *cur;
|
||||
|
||||
@@ -349,12 +355,12 @@ DLY_CheckNewStereoDelayVal
|
||||
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];
|
||||
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;
|
||||
|
||||
if( delay == 0 )
|
||||
@@ -397,7 +403,7 @@ DLY_DoStereoDelay
|
||||
Do stereo processing
|
||||
=============
|
||||
*/
|
||||
static void DLY_DoStereoDelay( int count )
|
||||
void DLY_DoStereoDelay( int count )
|
||||
{
|
||||
int delay, samplexf;
|
||||
dly_t *const dly = &rgsxdly[STEREODLY];
|
||||
@@ -462,12 +468,12 @@ DLY_CheckNewDelayVal
|
||||
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];
|
||||
|
||||
if( FBitSet( sxdly_delay.flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( sxdly_delay->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
if( delay == 0 )
|
||||
{
|
||||
@@ -497,8 +503,8 @@ static void DLY_CheckNewDelayVal( void )
|
||||
}
|
||||
}
|
||||
|
||||
dly->lp = sxdly_lp.value;
|
||||
dly->delayfeedback = 255 * sxdly_feedback.value;
|
||||
dly->lp = sxdly_lp->value;
|
||||
dly->delayfeedback = 255 * sxdly_feedback->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -508,7 +514,7 @@ DLY_DoDelay
|
||||
Do delay processing
|
||||
=============
|
||||
*/
|
||||
static void DLY_DoDelay( int count )
|
||||
void DLY_DoDelay( int count )
|
||||
{
|
||||
dly_t *const dly = &rgsxdly[MONODLY];
|
||||
portable_samplepair_t *paint = paintto;
|
||||
@@ -559,7 +565,7 @@ RVB_SetUpDly
|
||||
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;
|
||||
|
||||
@@ -595,13 +601,13 @@ RVB_CheckNewReverbVal
|
||||
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 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 )
|
||||
{
|
||||
@@ -610,13 +616,13 @@ static void RVB_CheckNewReverbVal( void )
|
||||
}
|
||||
else
|
||||
{
|
||||
RVB_SetUpDly( REVERBPOS, sxrvb_size.value, 500 );
|
||||
RVB_SetUpDly( REVERBPOS+1, sxrvb_size.value * 0.71f, 700 );
|
||||
RVB_SetUpDly( REVERBPOS, sxrvb_size->value, 500 );
|
||||
RVB_SetUpDly( REVERBPOS+1, sxrvb_size->value * 0.71f, 700 );
|
||||
}
|
||||
}
|
||||
|
||||
dly1->lp = dly2->lp = sxrvb_lp.value;
|
||||
dly1->delayfeedback = dly2->delayfeedback = (int)(255 * sxrvb_feedback.value);
|
||||
dly1->lp = dly2->lp = sxrvb_lp->value;
|
||||
dly1->delayfeedback = dly2->delayfeedback = (int)(255 * sxrvb_feedback->value);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -626,7 +632,7 @@ RVB_DoReverbForOneDly
|
||||
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 samplexf;
|
||||
@@ -700,7 +706,7 @@ RVB_DoReverb
|
||||
Do reverberation processing
|
||||
===========
|
||||
*/
|
||||
static void RVB_DoReverb( int count )
|
||||
void RVB_DoReverb( int count )
|
||||
{
|
||||
dly_t *const dly1 = &rgsxdly[REVERBPOS];
|
||||
dly_t *const dly2 = &rgsxdly[REVERBPOS+1];
|
||||
@@ -717,7 +723,7 @@ static void RVB_DoReverb( int count )
|
||||
voutm = RVB_DoReverbForOneDly( dly1, 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
|
||||
else voutm = (11 * voutm) >> 6;
|
||||
|
||||
@@ -733,18 +739,18 @@ RVB_DoAMod
|
||||
Do amplification modulation processing
|
||||
===========
|
||||
*/
|
||||
static void RVB_DoAMod( int count )
|
||||
void RVB_DoAMod( int count )
|
||||
{
|
||||
portable_samplepair_t *paint = paintto;
|
||||
|
||||
if( !sxmod_lowpass.value && !sxmod_mod.value )
|
||||
if( !sxmod_lowpass->value && !sxmod_mod->value )
|
||||
return;
|
||||
|
||||
for( ; count; count--, 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.right = rgsxlp[5] + rgsxlp[6] + rgsxlp[7] + rgsxlp[8] + rgsxlp[9] + res.right;
|
||||
@@ -766,7 +772,7 @@ static void RVB_DoAMod( int count )
|
||||
rgsxlp[8] = rgsxlp[9];
|
||||
}
|
||||
|
||||
if( sxmod_mod.value )
|
||||
if( sxmod_mod->value )
|
||||
{
|
||||
if( --sxmod1cur < 0 )
|
||||
sxmod1cur = sxmod1;
|
||||
@@ -808,7 +814,7 @@ DSP_Process
|
||||
*/
|
||||
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount )
|
||||
{
|
||||
if( dsp_off.value )
|
||||
if( dsp_off->value )
|
||||
return;
|
||||
|
||||
// don't process DSP while in menu
|
||||
@@ -846,12 +852,12 @@ CheckNewDspPresets
|
||||
*/
|
||||
void CheckNewDspPresets( void )
|
||||
{
|
||||
if( dsp_off.value != 0.0f )
|
||||
if( dsp_off->value != 0.0f )
|
||||
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
|
||||
ptable = rgsxpre;
|
||||
@@ -867,20 +873,20 @@ void CheckNewDspPresets( void )
|
||||
SX_ReloadRoomFX();
|
||||
room_typeprev = -1;
|
||||
|
||||
ClearBits( dsp_coeff_table.flags, FCVAR_CHANGED );
|
||||
ClearBits( dsp_coeff_table->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( s_listener.waterlevel > 2 )
|
||||
idsp_room = roomwater_type.value;
|
||||
else idsp_room = room_type.value;
|
||||
idsp_room = roomwater_type->value;
|
||||
else idsp_room = room_type->value;
|
||||
|
||||
// don't pass invalid presets
|
||||
idsp_room = bound( 0, idsp_room, MAX_ROOM_TYPES );
|
||||
|
||||
if( FBitSet( hisound.flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( hisound->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
sxhires = hisound.value;
|
||||
ClearBits( hisound.flags, FCVAR_CHANGED );
|
||||
sxhires = hisound->value;
|
||||
ClearBits( hisound->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( idsp_room == room_typeprev && idsp_room == 0 )
|
||||
@@ -909,15 +915,15 @@ void CheckNewDspPresets( void )
|
||||
DLY_CheckNewDelayVal( );
|
||||
DLY_CheckNewStereoDelayVal();
|
||||
|
||||
ClearBits( sxrvb_size.flags, FCVAR_CHANGED );
|
||||
ClearBits( sxdly_delay.flags, FCVAR_CHANGED );
|
||||
ClearBits( sxste_delay.flags, FCVAR_CHANGED );
|
||||
ClearBits( sxrvb_size->flags, FCVAR_CHANGED );
|
||||
ClearBits( sxdly_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];
|
||||
float oldroom = room_type.value;
|
||||
float oldroom = room_type->value;
|
||||
double start, end;
|
||||
int i, calls;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ GNU General Public License for more details.
|
||||
#include "common.h"
|
||||
#include "sound.h"
|
||||
#include "const.h"
|
||||
#include "sequence.h"
|
||||
#include <ctype.h>
|
||||
|
||||
static int cszrawsentences = 0;
|
||||
@@ -164,11 +165,24 @@ static const char *VOX_LookupString( const char *pszin )
|
||||
int i = -1, len;
|
||||
const char *c;
|
||||
|
||||
// check if we are an immediate sentence
|
||||
// check if we are a CSCZ or immediate sentence
|
||||
if( *pszin == '#' )
|
||||
{
|
||||
// immediate sentence, probably coming from "speak" command
|
||||
return pszin + 1;
|
||||
// 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
|
||||
return pszin + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// check if we received an index
|
||||
|
||||
@@ -219,6 +219,7 @@ extern dma_t dma;
|
||||
|
||||
extern convar_t s_musicvolume;
|
||||
extern convar_t s_lerping;
|
||||
extern convar_t *dsp_off;
|
||||
extern convar_t s_test; // cvar to testify new effects
|
||||
extern convar_t s_samplecount;
|
||||
extern convar_t snd_mute_losefocus;
|
||||
|
||||
@@ -35,7 +35,7 @@ static qboolean GAME_EXPORT VGUI_IsInGame( void );
|
||||
static struct
|
||||
{
|
||||
qboolean initialized;
|
||||
vguiapi_t dllFuncs;
|
||||
vgui_support_interface_t dllFuncs;
|
||||
VGUI_DefaultCursor cursor;
|
||||
|
||||
HINSTANCE hInstance;
|
||||
@@ -44,32 +44,7 @@ static struct
|
||||
} vgui =
|
||||
{
|
||||
false,
|
||||
{
|
||||
false, // Not initialized yet
|
||||
NULL, // VGUI_DrawInit,
|
||||
NULL, // VGUI_DrawShutdown,
|
||||
NULL, // VGUI_SetupDrawingText,
|
||||
NULL, // VGUI_SetupDrawingRect,
|
||||
NULL, // VGUI_SetupDrawingImage,
|
||||
NULL, // VGUI_BindTexture,
|
||||
NULL, // VGUI_EnableTexture,
|
||||
NULL, // VGUI_CreateTexture,
|
||||
NULL, // VGUI_UploadTexture,
|
||||
NULL, // VGUI_UploadTextureBlock,
|
||||
NULL, // VGUI_DrawQuad,
|
||||
NULL, // VGUI_GetTextureSizes,
|
||||
NULL, // VGUI_GenerateTexture,
|
||||
VGUI_EngineMalloc,
|
||||
VGUI_CursorSelect,
|
||||
VGUI_GetColor,
|
||||
VGUI_IsInGame,
|
||||
Key_EnableTextInput,
|
||||
VGUI_GetMousePos,
|
||||
VGUI_UtfProcessChar,
|
||||
Platform_GetClipboardText,
|
||||
Platform_SetClipboardText,
|
||||
Platform_GetKeyModifiers,
|
||||
},
|
||||
{ 0 }, // not initialized yet
|
||||
-1
|
||||
};
|
||||
|
||||
@@ -117,7 +92,37 @@ qboolean VGui_IsActive( void )
|
||||
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->DrawShutdown = from->VGUI_DrawShutdown;
|
||||
@@ -139,56 +144,144 @@ void VGui_RegisterCvars( void )
|
||||
Cvar_RegisterVariable( &vgui_utf8 );
|
||||
}
|
||||
|
||||
static HINSTANCE VGui_LoadSupportLibrary( void )
|
||||
{
|
||||
string vguiloader;
|
||||
string vguilib;
|
||||
HINSTANCE hInstance;
|
||||
|
||||
// HACKHACK: try to load path from custom path
|
||||
// to support having different versions of VGUI
|
||||
if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) && !COM_LoadLibrary( vguilib, false, false ))
|
||||
{
|
||||
Con_Reportf( S_WARN "VGUI preloading failed. Default library will be used! Reason: %s", COM_GetLibraryError());
|
||||
}
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ))
|
||||
{
|
||||
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, sizeof( vguiloader ));
|
||||
}
|
||||
|
||||
hInstance = COM_LoadLibrary( vguiloader, false, false );
|
||||
|
||||
if( !hInstance )
|
||||
{
|
||||
if( FS_FileExists( vguiloader, false ))
|
||||
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
|
||||
else Con_Reportf( "vgui_support: not found\n" );
|
||||
}
|
||||
|
||||
return hInstance;
|
||||
}
|
||||
|
||||
static qboolean VGui_ProbeNewAPI( HINSTANCE hInstance,
|
||||
vgui_support_interface_t *iface, const vgui_support_api_t *api )
|
||||
{
|
||||
const int version = VGUI_SUPPORT_API_VERSION;
|
||||
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;
|
||||
|
||||
Con_Reportf( "vgui_support: initialized legacy API in %s module\n", client ? "client" : "support" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean VGui_LoadProgs( HINSTANCE hInstance )
|
||||
{
|
||||
void (*F)( vguiapi_t* );
|
||||
LEGACY_VGUISUPPORTAPI F;
|
||||
qboolean client = hInstance != NULL;
|
||||
|
||||
// not loading interface from client.dll, load vgui_support.dll instead
|
||||
if( !client )
|
||||
{
|
||||
string vguiloader, vguilib;
|
||||
hInstance = vgui.hInstance = VGui_LoadSupportLibrary();
|
||||
|
||||
// HACKHACK: try to load path from custom path
|
||||
// to support having different versions of VGUI
|
||||
if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) && !COM_LoadLibrary( vguilib, false, false ))
|
||||
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_WARN "VGUI preloading failed. Default library will be used! Reason: %s", COM_GetLibraryError());
|
||||
}
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ))
|
||||
{
|
||||
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, sizeof( vguiloader ));
|
||||
}
|
||||
|
||||
hInstance = vgui.hInstance = COM_LoadLibrary( vguiloader, false, false );
|
||||
|
||||
if( !vgui.hInstance )
|
||||
{
|
||||
if( FS_FileExists( vguiloader, false ))
|
||||
Con_Reportf( S_ERROR "Failed to load vgui_support library: %s\n", COM_GetLibraryError() );
|
||||
else Con_Reportf( "vgui_support: not found\n" );
|
||||
|
||||
Con_Reportf( S_ERROR "Failed to find VGUI support API entry point in %s module\n", client ? "client" : "support" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// try legacy API first
|
||||
F = COM_GetProcAddress( hInstance, client ? "InitVGUISupportAPI" : "InitAPI" );
|
||||
|
||||
if( F )
|
||||
{
|
||||
VGui_FillAPIFromRef( &vgui.dllFuncs, &ref.dllFuncs );
|
||||
F( &vgui.dllFuncs );
|
||||
|
||||
vgui.initialized = vgui.dllFuncs.initialized = true;
|
||||
Con_Reportf( "vgui_support: initialized legacy API in %s module\n", client ? "client" : "support" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Con_Reportf( S_ERROR "Failed to find VGUI support API entry point in %s module\n", client ? "client" : "support" );
|
||||
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
|
||||
if( !vgui.initialized )
|
||||
@@ -212,12 +305,18 @@ void VGui_Startup( int width, int height )
|
||||
else if( width <= 1280 ) width = 1280;
|
||||
else if( width <= 1600 ) width = 1600;
|
||||
|
||||
if( vgui.dllFuncs.Startup )
|
||||
vgui.dllFuncs.Startup( width, height );
|
||||
if( !clientInstance )
|
||||
{
|
||||
if( vgui.dllFuncs.Startup )
|
||||
vgui.dllFuncs.Startup( width, height );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( vgui.dllFuncs.ClientStartup )
|
||||
vgui.dllFuncs.ClientStartup( clientInstance, width, height );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
VGui_Shutdown
|
||||
|
||||
@@ -21,7 +21,7 @@ GNU General Public License for more details.
|
||||
//
|
||||
void VGui_RegisterCvars( void );
|
||||
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_Paint( void );
|
||||
void VGui_RunFrame( void );
|
||||
|
||||
@@ -20,22 +20,21 @@ GNU General Public License for more details.
|
||||
#include "vid_common.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
|
||||
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
|
||||
static CVAR_DEFINE( vid_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
|
||||
static CVAR_DEFINE( vid_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
||||
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" );
|
||||
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
|
||||
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
|
||||
|
||||
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" );
|
||||
#define WINDOW_NAME XASH_ENGINE_NAME " Window" // Half-Life
|
||||
convar_t *vid_fullscreen;
|
||||
convar_t *vid_mode;
|
||||
convar_t *vid_brightness;
|
||||
convar_t *vid_gamma;
|
||||
convar_t *vid_highdpi;
|
||||
|
||||
glwstate_t glw_state;
|
||||
|
||||
convar_t *window_xpos;
|
||||
convar_t *window_ypos;
|
||||
|
||||
convar_t *vid_rotate;
|
||||
convar_t *vid_scale;
|
||||
|
||||
/*
|
||||
=================
|
||||
VID_StartupGamma
|
||||
@@ -43,10 +42,10 @@ 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 );
|
||||
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 );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -67,7 +66,7 @@ void VID_InitDefaultResolution( void )
|
||||
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 )
|
||||
{
|
||||
@@ -80,7 +79,6 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximiz
|
||||
|
||||
Cvar_SetValue( "width", w );
|
||||
Cvar_SetValue( "height", h );
|
||||
Cvar_DirectSet( &vid_maximized, maximized ? "1" : "0" );
|
||||
|
||||
// immediately drop changed state or we may trigger
|
||||
// video subsystem to reapply settings
|
||||
@@ -126,11 +124,11 @@ check vid modes and fullscreen
|
||||
*/
|
||||
void VID_CheckChanges( void )
|
||||
{
|
||||
if( FBitSet( cl_allow_levelshots.flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( cl_allow_levelshots->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
//GL_FreeTexture( cls.loadingBar );
|
||||
SCR_RegisterTextures(); // reload 'lambda' image
|
||||
ClearBits( cl_allow_levelshots.flags, FCVAR_CHANGED );
|
||||
ClearBits( cl_allow_levelshots->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( host.renderinfo_changed )
|
||||
@@ -147,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 )
|
||||
{
|
||||
int w, h;
|
||||
@@ -209,25 +177,25 @@ static void VID_Mode_f( void )
|
||||
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 )
|
||||
{
|
||||
// system screen width and height (don't suppose for change from console at all)
|
||||
Cvar_RegisterVariable( &window_width );
|
||||
Cvar_RegisterVariable( &window_height );
|
||||
Cvar_Get( "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
|
||||
Cvar_Get( "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
|
||||
|
||||
Cvar_RegisterVariable( &vid_mode );
|
||||
Cvar_RegisterVariable( &vid_highdpi );
|
||||
Cvar_RegisterVariable( &vid_rotate );
|
||||
Cvar_RegisterVariable( &vid_scale );
|
||||
Cvar_RegisterVariable( &vid_fullscreen );
|
||||
Cvar_RegisterVariable( &vid_maximized );
|
||||
Cvar_RegisterVariable( &vid_brightness );
|
||||
Cvar_RegisterVariable( &vid_gamma );
|
||||
Cvar_RegisterVariable( &window_xpos );
|
||||
Cvar_RegisterVariable( &window_ypos );
|
||||
window_xpos = Cvar_Get( "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
|
||||
window_ypos = Cvar_Get( "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );
|
||||
|
||||
vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
||||
vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
|
||||
vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
|
||||
vid_mode = Cvar_Get( "vid_mode", "0", FCVAR_RENDERINFO, "current video mode index (used just for storage)" );
|
||||
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
|
||||
// but supported mode list is filled by backends, so numbers are not portable any more
|
||||
|
||||
@@ -9,13 +9,6 @@ typedef struct vidmode_s
|
||||
int height;
|
||||
} 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
|
||||
{
|
||||
@@ -28,6 +21,8 @@ typedef struct
|
||||
qboolean initialized; // OpenGL subsystem started
|
||||
qboolean extended; // extended context allows to GL_Debug
|
||||
qboolean software;
|
||||
|
||||
|
||||
} glwstate_t;
|
||||
|
||||
extern glwstate_t glw_state;
|
||||
@@ -35,15 +30,13 @@ extern glwstate_t glw_state;
|
||||
#define VID_MIN_HEIGHT 200
|
||||
#define VID_MIN_WIDTH 320
|
||||
|
||||
extern convar_t vid_fullscreen;
|
||||
extern convar_t vid_maximized;
|
||||
extern convar_t vid_highdpi;
|
||||
extern convar_t window_xpos;
|
||||
extern convar_t window_ypos;
|
||||
extern convar_t gl_msaa_samples;
|
||||
extern convar_t *vid_fullscreen;
|
||||
extern convar_t *vid_highdpi;
|
||||
extern convar_t *vid_rotate;
|
||||
extern convar_t *vid_scale;
|
||||
|
||||
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized );
|
||||
void VID_SetDisplayTransform( int *render_w, int *render_h );
|
||||
extern convar_t *gl_msaa_samples;
|
||||
void R_SaveVideoMode( int w, int h, int render_w, int render_h );
|
||||
void VID_CheckChanges( void );
|
||||
const char *VID_GetModeString( int vid_mode );
|
||||
void VID_StartupGamma( void );
|
||||
|
||||
@@ -382,7 +382,7 @@ void Voice_RecordStart( void )
|
||||
{
|
||||
Sound_Process( &voice.input_file, voice.samplerate, voice.width, SOUND_RESAMPLE );
|
||||
voice.input_file_pos = 0;
|
||||
|
||||
|
||||
voice.start_time = Sys_DoubleTime();
|
||||
voice.is_recording = true;
|
||||
}
|
||||
@@ -499,7 +499,7 @@ void CL_AddVoiceToDatagram( void )
|
||||
|
||||
if( cls.state != ca_active || !Voice_IsRecording() || !voice.encoder )
|
||||
return;
|
||||
|
||||
|
||||
size = Voice_GetOpusCompressedData( voice.output_buffer, sizeof( voice.output_buffer ), &frames );
|
||||
|
||||
if( size > 0 && MSG_GetNumBytesLeft( &cls.datagram ) >= size + 32 )
|
||||
@@ -600,10 +600,8 @@ qboolean Voice_Init( const char *pszCodecName, int quality )
|
||||
}
|
||||
|
||||
// reinitialize only if codec parameters are different
|
||||
if( !Q_strcmp( voice.codec, pszCodecName ) && voice.quality == quality )
|
||||
return true;
|
||||
|
||||
Voice_Shutdown();
|
||||
if( Q_strcmp( voice.codec, pszCodecName ) && voice.quality != quality )
|
||||
Voice_Shutdown();
|
||||
|
||||
voice.autogain.block_size = 128;
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ int GAME_EXPORT Cmd_Argc( void )
|
||||
Cmd_Argv
|
||||
============
|
||||
*/
|
||||
const char *GAME_EXPORT Cmd_Argv( int arg )
|
||||
const char *Cmd_Argv( int arg )
|
||||
{
|
||||
if((uint)arg >= cmd_argc )
|
||||
return "";
|
||||
@@ -559,7 +559,7 @@ const char *GAME_EXPORT Cmd_Argv( int arg )
|
||||
Cmd_Args
|
||||
============
|
||||
*/
|
||||
const char *GAME_EXPORT Cmd_Args( void )
|
||||
const char *Cmd_Args( void )
|
||||
{
|
||||
return cmd_args;
|
||||
}
|
||||
@@ -996,7 +996,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
|
||||
cmd_condlevel = 0;
|
||||
|
||||
// cvar value substitution
|
||||
if( cmd_scripting.value && isPrivileged )
|
||||
if( CVAR_TO_BOOL( cmd_scripting ) && isPrivileged )
|
||||
{
|
||||
while( *text )
|
||||
{
|
||||
@@ -1357,7 +1357,7 @@ inserts escape sequences
|
||||
void Cmd_Escape( char *newCommand, const char *oldCommand, int len )
|
||||
{
|
||||
int c;
|
||||
int scripting = cmd_scripting.value;
|
||||
int scripting = CVAR_TO_BOOL( cmd_scripting );
|
||||
|
||||
while( (c = *oldCommand++) && len > 1 )
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ GNU General Public License for more details.
|
||||
#include "const.h"
|
||||
#include "client.h"
|
||||
#include "library.h"
|
||||
#include "sequence.h"
|
||||
|
||||
static const char *file_exts[] =
|
||||
{
|
||||
@@ -103,7 +104,7 @@ static float fran1( void )
|
||||
return temp;
|
||||
}
|
||||
|
||||
void GAME_EXPORT COM_SetRandomSeed( int lSeed )
|
||||
void COM_SetRandomSeed( int lSeed )
|
||||
{
|
||||
if( lSeed ) idum = lSeed;
|
||||
else idum = -time( NULL );
|
||||
@@ -266,7 +267,7 @@ static void LZSS_BuildHash( lzss_state_t *state, const byte *source )
|
||||
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 *pEnd = pStart + input_length - sizeof( lzss_header_t ) - 8; // prevent compression failure
|
||||
@@ -612,7 +613,7 @@ COM_Nibble
|
||||
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' ))
|
||||
{
|
||||
@@ -660,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;
|
||||
|
||||
@@ -714,7 +715,7 @@ Cache_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 )
|
||||
return NULL;
|
||||
@@ -731,7 +732,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;
|
||||
byte *file, *pfile;
|
||||
@@ -771,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 );
|
||||
}
|
||||
@@ -857,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
|
||||
@@ -864,7 +918,7 @@ pfnCVarGetPointer
|
||||
can return NULL
|
||||
=============
|
||||
*/
|
||||
cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName )
|
||||
cvar_t *pfnCVarGetPointer( const char *szVarName )
|
||||
{
|
||||
return (cvar_t *)Cvar_FindVar( szVarName );
|
||||
}
|
||||
@@ -1046,7 +1100,7 @@ void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
|
||||
{
|
||||
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );
|
||||
|
||||
return NULL;
|
||||
return Sequence_Get( fileName, entryName );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1060,7 +1114,7 @@ void *GAME_EXPORT pfnSequencePickSentence( const char *groupName, int pickMethod
|
||||
{
|
||||
Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod );
|
||||
|
||||
return NULL;
|
||||
return Sequence_PickSentence( groupName, pickMethod, picked );
|
||||
|
||||
}
|
||||
|
||||
@@ -1071,7 +1125,30 @@ pfnIsCareerMatch
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ typedef enum
|
||||
|
||||
#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
|
||||
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 )
|
||||
#endif
|
||||
|
||||
extern convar_t gl_vsync;
|
||||
extern convar_t scr_loading;
|
||||
extern convar_t scr_download;
|
||||
extern convar_t cmd_scripting;
|
||||
extern convar_t cl_allow_levelshots;
|
||||
extern convar_t *gl_vsync;
|
||||
extern convar_t *scr_loading;
|
||||
extern convar_t *scr_download;
|
||||
extern convar_t *cmd_scripting;
|
||||
extern convar_t *sv_maxclients;
|
||||
extern convar_t *cl_allow_levelshots;
|
||||
extern convar_t host_developer;
|
||||
extern convar_t host_limitlocal;
|
||||
extern convar_t host_maxfps;
|
||||
extern convar_t *host_limitlocal;
|
||||
extern convar_t *host_framerate;
|
||||
extern convar_t *host_maxfps;
|
||||
extern convar_t sys_timescale;
|
||||
extern convar_t cl_filterstuffcmd;
|
||||
extern convar_t rcon_password;
|
||||
@@ -271,6 +273,40 @@ typedef struct
|
||||
double forcedEnd;
|
||||
} 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
|
||||
{
|
||||
// default mode, we assume that user dlls are not relying on engine bugs
|
||||
@@ -324,7 +360,8 @@ typedef struct host_parm_s
|
||||
qboolean change_game; // initialize when game is changed
|
||||
qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!)
|
||||
qboolean shutdown_issued; // engine is shutting down
|
||||
double force_draw_version_time;
|
||||
qboolean 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_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
|
||||
@@ -381,7 +418,6 @@ typedef void (*xcommand_t)( void );
|
||||
qboolean FS_LoadProgs( void );
|
||||
void FS_Init( void );
|
||||
void FS_Shutdown( void );
|
||||
void *FS_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
// cmd.c
|
||||
@@ -422,8 +458,8 @@ void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
|
||||
// zone.c
|
||||
//
|
||||
void Memory_Init( void );
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
|
||||
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
||||
@@ -593,6 +629,10 @@ 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 );
|
||||
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
|
||||
int COM_SaveFile( const char *filename, const void *data, int len );
|
||||
@@ -609,6 +649,7 @@ void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
|
||||
void pfnCVarDirectSet( cvar_t *var, const char *szValue );
|
||||
int COM_CheckParm( char *parm, char **ppnext );
|
||||
void pfnGetGameDir( char *szGetGameDir );
|
||||
int pfnDecalIndex( const char *m );
|
||||
int pfnGetModelType( model_t *mod );
|
||||
int pfnIsMapValid( char *filename );
|
||||
void Con_Reportf( const char *szFmt, ... ) _format( 1 );
|
||||
@@ -628,6 +669,8 @@ void *pfnSequencePickSentence( const char *groupName, int pickMethod, int *picke
|
||||
int pfnIsCareerMatch( void );
|
||||
|
||||
// Decay engfuncs (stubs)
|
||||
int pfnGetTimesTutorMessageShown( int mid );
|
||||
void pfnRegisterTutorMessageShown( int mid );
|
||||
void pfnConstructTutorMessageDecayBuffer( int *buffer, int buflen );
|
||||
void pfnProcessTutorMessageDecayBuffer( int *buffer, int bufferLength );
|
||||
void pfnResetTutorMessageDecayData( void );
|
||||
@@ -712,6 +755,7 @@ struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
|
||||
struct cmdalias_s *Cmd_AliasGetList( void );
|
||||
const char *Cmd_GetName( struct cmd_s *cmd );
|
||||
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
|
||||
void SV_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 SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
|
||||
@@ -748,6 +792,8 @@ void SV_ShutdownGame( void );
|
||||
void SV_ExecLoadLevel( void );
|
||||
void SV_ExecLoadGame( void );
|
||||
void SV_ExecChangeLevel( void );
|
||||
void SV_InitGameProgs( void );
|
||||
void SV_FreeGameProgs( void );
|
||||
void CL_WriteMessageHistory( void );
|
||||
void CL_SendCmd( void );
|
||||
void CL_Disconnect( void );
|
||||
@@ -793,7 +839,7 @@ void VID_Init( void );
|
||||
void UI_SetActiveMenu( qboolean fActive );
|
||||
void UI_ShowConnectionWarning( void );
|
||||
void Cmd_Null_f( void );
|
||||
void Rcon_Print( host_redirect_t *rd, const char *pMsg );
|
||||
void Rcon_Print( const char *pMsg );
|
||||
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
|
||||
void COM_NormalizeAngles( vec3_t angles );
|
||||
int COM_FileSize( const char *filename );
|
||||
|
||||
@@ -18,7 +18,7 @@ GNU General Public License for more details.
|
||||
#include "const.h"
|
||||
#include "kbutton.h"
|
||||
|
||||
extern convar_t con_gamemaps;
|
||||
extern convar_t *con_gamemaps;
|
||||
|
||||
#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';
|
||||
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 )
|
||||
{
|
||||
@@ -190,7 +190,7 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
||||
string matchbuf;
|
||||
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;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -1428,6 +1428,8 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
|
||||
|
||||
Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name );
|
||||
|
||||
SV_InitGameProgs(); // collect user variables
|
||||
|
||||
// FIXME: move this out until menu parser is done
|
||||
CSCR_LoadDefaultCVars( "settings.scr" );
|
||||
|
||||
@@ -1444,6 +1446,8 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
|
||||
Host_FinalizeConfig( f, name );
|
||||
}
|
||||
else Con_DPrintf( S_ERROR "Couldn't write %s.\n", name );
|
||||
|
||||
SV_FreeGameProgs(); // release progs with all variables
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -320,9 +320,7 @@ void Sys_RestoreCrashHandler( void )
|
||||
|
||||
#elif XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX
|
||||
// Posix signal handler
|
||||
#ifndef XASH_OPENBSD
|
||||
#include <ucontext.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
#include "library.h"
|
||||
@@ -336,6 +334,24 @@ void Sys_RestoreCrashHandler( void )
|
||||
|
||||
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 )
|
||||
{
|
||||
Dl_info dlinfo;
|
||||
@@ -390,9 +406,9 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
|
||||
bp = (void**)ucontext->uc_mcontext.mc_ebp;
|
||||
sp = (void**)ucontext->uc_mcontext.mc_esp;
|
||||
#elif XASH_NETBSD
|
||||
pc = (void*)ucontext->uc_mcontext.__gregs[_REG_EIP];
|
||||
bp = (void**)ucontext->uc_mcontext.__gregs[_REG_EBP];
|
||||
sp = (void**)ucontext->uc_mcontext.__gregs[_REG_ESP];
|
||||
pc = (void*)ucontext->uc_mcontext.__gregs[REG_EIP];
|
||||
bp = (void**)ucontext->uc_mcontext.__gregs[REG_EBP];
|
||||
sp = (void**)ucontext->uc_mcontext.__gregs[REG_ESP];
|
||||
#elif XASH_OPENBSD
|
||||
pc = (void*)ucontext->sc_eip;
|
||||
bp = (void**)ucontext->sc_ebp;
|
||||
@@ -490,7 +506,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
|
||||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#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
|
||||
if( host.type == HOST_NORMAL )
|
||||
|
||||
@@ -19,7 +19,7 @@ GNU General Public License for more details.
|
||||
#include "eiface.h" // ARRAYSIZE
|
||||
|
||||
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
|
||||
typedef struct cvar_filter_quirks_s
|
||||
@@ -211,7 +211,7 @@ const char *Cvar_ValidateString( convar_t *var, const char *value )
|
||||
int len = 0;
|
||||
|
||||
// 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 )
|
||||
{
|
||||
@@ -681,19 +681,19 @@ void Cvar_DirectSet( convar_t *var, const char *value )
|
||||
{
|
||||
const char *pszValue;
|
||||
|
||||
if( unlikely( !var )) return; // ???
|
||||
if( !var ) return; // ???
|
||||
|
||||
// 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
|
||||
Cvar_RegisterVariable( var ); // ok, register it
|
||||
|
||||
// lookup for registration again
|
||||
if( var != Cvar_FindVar( var->name ))
|
||||
return; // how this possible?
|
||||
}
|
||||
|
||||
// lookup for registration again
|
||||
if( var != Cvar_FindVar( var->name ))
|
||||
return; // how this possible?
|
||||
|
||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
||||
{
|
||||
Con_Printf( "%s is read-only.\n", var->name );
|
||||
@@ -1136,6 +1136,8 @@ As Cvar_Set, but also flags it as glconfig
|
||||
*/
|
||||
void Cvar_SetGL_f( void )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( Cmd_Argc() != 3 )
|
||||
{
|
||||
Con_Printf( S_USAGE "setgl <variable> <value>\n" );
|
||||
@@ -1238,7 +1240,7 @@ void Cvar_Init( void )
|
||||
{
|
||||
cvar_vars = 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( &cl_filterstuffcmd );
|
||||
Cmd_AddRestrictedCommand( "setgl", Cvar_SetGL_f, "change the value of a opengl variable" ); // OBSOLETE
|
||||
|
||||
@@ -56,7 +56,8 @@ typedef struct convar_s
|
||||
#define CVAR_DEFINE_AUTO( 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 );
|
||||
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
|
||||
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
|
||||
@@ -80,6 +81,5 @@ qboolean Cvar_CommandWithPrivilegeCheck( convar_t *v, qboolean isPrivileged );
|
||||
void Cvar_Init( void );
|
||||
void Cvar_PostFSInit( void );
|
||||
void Cvar_Unlink( int group );
|
||||
#endif // REF_DLL
|
||||
|
||||
#endif//CVAR_H
|
||||
|
||||
@@ -218,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 )
|
||||
{
|
||||
|
||||
|
||||
@@ -18,22 +18,12 @@ GNU General Public License for more details.
|
||||
|
||||
#include "common.h"
|
||||
#include "library.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
fs_api_t g_fsapi;
|
||||
fs_globals_t *FI;
|
||||
|
||||
static pfnCreateInterface_t fs_pfnCreateInterface;
|
||||
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 )
|
||||
{
|
||||
FS_Rescan();
|
||||
@@ -61,8 +51,6 @@ static fs_interface_t fs_memfuncs =
|
||||
_Mem_Alloc,
|
||||
_Mem_Realloc,
|
||||
_Mem_Free,
|
||||
|
||||
Sys_GetNativeObject,
|
||||
};
|
||||
|
||||
static void FS_UnloadProgs( void )
|
||||
@@ -107,13 +95,6 @@ qboolean FS_LoadProgs( void )
|
||||
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" );
|
||||
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,6 @@ GNU General Public License for more details.
|
||||
#include "common.h"
|
||||
#include "base_cmd.h"
|
||||
#include "client.h"
|
||||
#include "server.h"
|
||||
#include "netchan.h"
|
||||
#include "protocol.h"
|
||||
#include "mod_local.h"
|
||||
@@ -52,18 +51,18 @@ struct tests_stats_s tests_stats;
|
||||
#endif
|
||||
|
||||
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" );
|
||||
|
||||
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" );
|
||||
static CVAR_DEFINE_AUTO( host_gameloaded, "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" );
|
||||
static CVAR_DEFINE_AUTO( host_clientloaded, "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
|
||||
CVAR_DEFINE_AUTO( host_limitlocal, "0", 0, "apply cl_cmdrate and rate to loopback connection" );
|
||||
CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
|
||||
static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
|
||||
static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
|
||||
static CVAR_DEFINE_AUTO( host_sleeptime_debug, "0", 0, "print sleeps between frames" );
|
||||
CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
|
||||
convar_t *host_serverstate;
|
||||
convar_t *host_gameloaded;
|
||||
convar_t *host_clientloaded;
|
||||
convar_t *host_limitlocal;
|
||||
convar_t *host_maxfps;
|
||||
convar_t *host_framerate;
|
||||
convar_t *host_sleeptime;
|
||||
convar_t *con_gamemaps;
|
||||
convar_t *build, *ver;
|
||||
|
||||
void Sys_PrintUsage( void )
|
||||
{
|
||||
@@ -117,7 +116,6 @@ void Sys_PrintUsage( void )
|
||||
O("-oldfont ", "enable unused Quake font in Half-Life")
|
||||
O("-width <n> ", "set window width")
|
||||
O("-height <n> ", "set window height")
|
||||
O("-borderless ", "run engine in fullscreen borderless mode")
|
||||
O("-fullscreen ", "run engine in fullscreen mode")
|
||||
O("-windowed ", "run engine in windowed mode")
|
||||
O("-ref <name> ", "use selected renderer dll")
|
||||
@@ -129,7 +127,6 @@ void Sys_PrintUsage( void )
|
||||
O("-noenginejoy ", "disable engine builtin joystick support")
|
||||
O("-noenginemouse ", "disable engine builtin mouse support")
|
||||
O("-nosound ", "disable sound output")
|
||||
O("-timedemo ", "run timedemo and exit")
|
||||
#endif
|
||||
|
||||
"\nPlatform-specific options:\n"
|
||||
@@ -140,7 +137,7 @@ void Sys_PrintUsage( void )
|
||||
O("-sdl_joy_old_api ","use SDL legacy joystick API")
|
||||
O("-sdl_renderer <n>","use alternative SDL_Renderer for software")
|
||||
#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")
|
||||
#endif // XASH_ANDROID
|
||||
#if XASH_DOS
|
||||
@@ -281,27 +278,27 @@ static int Host_CalcSleep( void )
|
||||
#ifndef XASH_DEDICATED
|
||||
// never sleep in timedemo for benchmarking purposes
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
if( Host_IsDedicated() )
|
||||
{
|
||||
// let the dedicated server some sleep
|
||||
return host_sleeptime.value;
|
||||
return host_sleeptime->value;
|
||||
}
|
||||
|
||||
switch( host.status )
|
||||
{
|
||||
case HOST_NOFOCUS:
|
||||
if( SV_Active() && CL_IsInGame())
|
||||
return host_sleeptime.value;
|
||||
return host_sleeptime->value;
|
||||
// fallthrough
|
||||
case HOST_SLEEP:
|
||||
return 20;
|
||||
}
|
||||
|
||||
return host_sleeptime.value;
|
||||
return host_sleeptime->value;
|
||||
}
|
||||
|
||||
void Host_NewInstance( const char *name, const char *finalmsg )
|
||||
@@ -602,14 +599,14 @@ double Host_CalcFPS( void )
|
||||
}
|
||||
else if( Host_IsLocalGame( ))
|
||||
{
|
||||
if( !gl_vsync.value )
|
||||
fps = host_maxfps.value;
|
||||
if( !CVAR_TO_BOOL( gl_vsync ))
|
||||
fps = host_maxfps->value;
|
||||
}
|
||||
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;
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
}
|
||||
@@ -619,84 +616,6 @@ double Host_CalcFPS( void )
|
||||
return fps;
|
||||
}
|
||||
|
||||
static qboolean Host_Autosleep( double dt, double scale )
|
||||
{
|
||||
double targetframetime, fps;
|
||||
int sleep;
|
||||
|
||||
fps = Host_CalcFPS();
|
||||
|
||||
if( fps <= 0 )
|
||||
return true;
|
||||
|
||||
// limit fps to withing tolerable range
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
|
||||
if( Host_IsDedicated( ))
|
||||
targetframetime = ( 1.0 / ( fps + 1.0 ));
|
||||
else targetframetime = ( 1.0 / fps );
|
||||
|
||||
sleep = Host_CalcSleep();
|
||||
if( sleep == 0 ) // no sleeps between frames, much simpler code
|
||||
{
|
||||
if( dt < targetframetime * scale )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
static double timewindow; // allocate a time window for sleeps
|
||||
static int counter; // for debug
|
||||
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
|
||||
@@ -707,23 +626,63 @@ Returns false if the time is too short to run a frame
|
||||
qboolean Host_FilterTime( float time )
|
||||
{
|
||||
static double oldtime;
|
||||
double dt;
|
||||
double scale = sys_timescale.value;
|
||||
double fps, scale = sys_timescale.value;
|
||||
|
||||
host.realtime += time * scale;
|
||||
dt = host.realtime - oldtime;
|
||||
fps = Host_CalcFPS();
|
||||
|
||||
// clamp the fps in multiplayer games
|
||||
if( !Host_Autosleep( dt, scale ))
|
||||
return false;
|
||||
if( fps != 0.0 )
|
||||
{
|
||||
static int sleeps;
|
||||
double targetframetime;
|
||||
int sleeptime = Host_CalcSleep();
|
||||
|
||||
// limit fps to withing tolerable range
|
||||
fps = bound( MIN_FPS, fps, MAX_FPS );
|
||||
|
||||
if( Host_IsDedicated( ))
|
||||
targetframetime = ( 1.0 / ( fps + 1.0 ));
|
||||
else targetframetime = ( 1.0 / fps );
|
||||
|
||||
if(( host.realtime - oldtime ) < targetframetime * scale )
|
||||
{
|
||||
if( sleeptime > 0 && sleeps > 0 )
|
||||
{
|
||||
Sys_Sleep( sleeptime );
|
||||
sleeps--;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// always sleep at least once in minimized/nofocus state
|
||||
sleeps = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
host.frametime = host.realtime - oldtime;
|
||||
host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
|
||||
oldtime = host.realtime;
|
||||
|
||||
// NOTE: allow only in singleplayer while demos are not active
|
||||
if( host_framerate.value > 0.0f && Host_IsLocalGame() && !CL_IsPlaybackDemo() && !CL_IsRecordDemo( ))
|
||||
host.frametime = bound( MIN_FRAMETIME, host_framerate.value * scale, MAX_FRAMETIME );
|
||||
if( host_framerate->value > 0.0f && Host_IsLocalGame() && !CL_IsPlaybackDemo() && !CL_IsRecordDemo( ))
|
||||
host.frametime = bound( MIN_FRAMETIME, host_framerate->value * scale, MAX_FRAMETIME );
|
||||
else host.frametime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
|
||||
|
||||
return true;
|
||||
@@ -795,7 +754,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
|
||||
Key_SetKeyDest( key_console );
|
||||
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
|
||||
@@ -1057,31 +1016,21 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
||||
else
|
||||
{
|
||||
#if TARGET_OS_IOS
|
||||
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof( host.rootdir ));
|
||||
#elif XASH_ANDROID && XASH_SDL
|
||||
Q_strncpy( host.rootdir, SDL_AndroidGetExternalStoragePath(), sizeof( host.rootdir ));
|
||||
const char *IOS_GetDocsDir();
|
||||
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) );
|
||||
#elif XASH_PSVITA
|
||||
if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir )))
|
||||
if ( !PSVita_GetBasePath( host.rootdir, sizeof( host.rootdir ) ) )
|
||||
{
|
||||
Sys_Error( "couldn't find xash3d data directory" );
|
||||
host.rootdir[0] = 0;
|
||||
}
|
||||
#elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2
|
||||
char *szBasePath = SDL_GetBasePath();
|
||||
if( szBasePath )
|
||||
{
|
||||
Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir ));
|
||||
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
|
||||
char *szBasePath;
|
||||
|
||||
if( !( szBasePath = SDL_GetBasePath() ) )
|
||||
Sys_Error( "couldn't determine current directory: %s", SDL_GetError() );
|
||||
#endif
|
||||
}
|
||||
Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir ));
|
||||
SDL_free( szBasePath );
|
||||
#else
|
||||
if( !getcwd( host.rootdir, sizeof( host.rootdir )))
|
||||
{
|
||||
@@ -1128,9 +1077,10 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
||||
|
||||
FS_LoadProgs();
|
||||
|
||||
// TODO: this function will cause engine to stop in case of fail
|
||||
// when it will have an option to return string error, restore Sys_Error
|
||||
FS_SetCurrentDirectory( host.rootdir );
|
||||
if( FS_SetCurrentDirectory( host.rootdir ) != 0 )
|
||||
Con_Reportf( "%s is working directory now\n", host.rootdir );
|
||||
else
|
||||
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
|
||||
|
||||
FS_Init();
|
||||
|
||||
@@ -1200,7 +1150,6 @@ Host_Main
|
||||
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func )
|
||||
{
|
||||
static double oldtime, newtime;
|
||||
string demoname;
|
||||
|
||||
host.starttime = Sys_DoubleTime();
|
||||
|
||||
@@ -1216,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");
|
||||
}
|
||||
|
||||
Cvar_RegisterVariable( &host_serverstate );
|
||||
Cvar_RegisterVariable( &host_maxfps );
|
||||
Cvar_RegisterVariable( &host_framerate );
|
||||
Cvar_RegisterVariable( &host_sleeptime );
|
||||
Cvar_RegisterVariable( &host_sleeptime_debug );
|
||||
Cvar_RegisterVariable( &host_gameloaded );
|
||||
Cvar_RegisterVariable( &host_clientloaded );
|
||||
Cvar_RegisterVariable( &host_limitlocal );
|
||||
Cvar_RegisterVariable( &con_gamemaps );
|
||||
host_serverstate = Cvar_Get( "host_serverstate", "0", FCVAR_READ_ONLY, "displays current server state" );
|
||||
host_maxfps = Cvar_Get( "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
|
||||
host_framerate = Cvar_Get( "host_framerate", "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
|
||||
host_sleeptime = Cvar_Get( "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
|
||||
host_gameloaded = Cvar_Get( "host_gameloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" );
|
||||
host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
|
||||
host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" );
|
||||
con_gamemaps = Cvar_Get( "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
|
||||
Cvar_RegisterVariable( &sys_timescale );
|
||||
|
||||
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());
|
||||
build = Cvar_Getf( "buildnum", FCVAR_READ_ONLY, "returns a current build number", "%i", 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_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 );
|
||||
|
||||
@@ -1298,9 +1246,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
|
||||
Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline)
|
||||
SCR_CheckStartupVids(); // must be last
|
||||
|
||||
if( Sys_GetParmFromCmdLine( "-timedemo", demoname ))
|
||||
Cbuf_AddTextf( "timedemo %s\n", demoname );
|
||||
|
||||
oldtime = Sys_DoubleTime() - 0.1;
|
||||
|
||||
if( Host_IsDedicated( ))
|
||||
@@ -1349,7 +1294,6 @@ void EXPORT Host_Shutdown( void )
|
||||
#endif
|
||||
|
||||
SV_Shutdown( "Server shutdown\n" );
|
||||
SV_UnloadProgs();
|
||||
SV_ShutdownFilter();
|
||||
CL_Shutdown();
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ void Image_CopyPalette32bit( void );
|
||||
void Image_SetPixelFormat( void );
|
||||
void Image_GetPaletteQ1( void );
|
||||
void Image_GetPaletteHL( void );
|
||||
size_t Image_ComputeSize( int type, int width, int height, int depth );
|
||||
|
||||
//
|
||||
// formats load
|
||||
@@ -157,7 +156,6 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
qboolean Image_LoadFNT( const char *name, const byte *buffer, fs_offset_t filesize );
|
||||
qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesize );
|
||||
qboolean Image_LoadPAL( const char *name, const byte *buffer, fs_offset_t filesize );
|
||||
qboolean Image_LoadKTX2( const char *name, const byte *buffer, fs_offset_t filesize );
|
||||
|
||||
//
|
||||
// formats save
|
||||
|
||||
@@ -104,13 +104,6 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
{
|
||||
switch( headerExt->dxgiFormat )
|
||||
{
|
||||
case DXGI_FORMAT_BC4_TYPELESS:
|
||||
case DXGI_FORMAT_BC4_UNORM:
|
||||
image.type = PF_BC4_UNSIGNED;
|
||||
break;
|
||||
case DXGI_FORMAT_BC4_SNORM:
|
||||
image.type = PF_BC4_SIGNED;
|
||||
break;
|
||||
case DXGI_FORMAT_BC6H_SF16:
|
||||
image.type = PF_BC6H_SIGNED;
|
||||
break;
|
||||
@@ -119,20 +112,9 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
image.type = PF_BC6H_UNSIGNED;
|
||||
break;
|
||||
case DXGI_FORMAT_BC7_UNORM:
|
||||
case DXGI_FORMAT_BC7_TYPELESS:
|
||||
image.type = PF_BC7_UNORM;
|
||||
break;
|
||||
case DXGI_FORMAT_BC7_UNORM_SRGB:
|
||||
image.type = PF_BC7_SRGB;
|
||||
break;
|
||||
case DXGI_FORMAT_BC5_TYPELESS:
|
||||
image.type = PF_ATI2;
|
||||
break;
|
||||
case DXGI_FORMAT_BC5_UNORM:
|
||||
image.type = PF_BC5_UNSIGNED;
|
||||
break;
|
||||
case DXGI_FORMAT_BC5_SNORM:
|
||||
image.type = PF_BC5_SIGNED;
|
||||
case DXGI_FORMAT_BC7_TYPELESS:
|
||||
image.type = PF_BC7;
|
||||
break;
|
||||
default:
|
||||
image.type = PF_UNKNOWN;
|
||||
@@ -140,7 +122,7 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
switch( hdr->dsPixelFormat.dwFourCC )
|
||||
{
|
||||
case TYPE_DXT1:
|
||||
@@ -161,15 +143,6 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
case TYPE_ATI2:
|
||||
image.type = PF_ATI2;
|
||||
break;
|
||||
case TYPE_BC5S:
|
||||
image.type = PF_BC5_SIGNED;
|
||||
break;
|
||||
case TYPE_BC4S:
|
||||
image.type = PF_BC4_SIGNED;
|
||||
break;
|
||||
case TYPE_BC4U:
|
||||
image.type = PF_BC4_UNSIGNED;
|
||||
break;
|
||||
default:
|
||||
image.type = PF_UNKNOWN; // assume error
|
||||
break;
|
||||
@@ -215,6 +188,27 @@ void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
image.num_mips = hdr->dwMipMapCount; // get actual mip count
|
||||
}
|
||||
|
||||
size_t Image_DXTGetLinearSize( int type, int width, int height, int depth )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case PF_DXT1: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 8 );
|
||||
case PF_DXT3:
|
||||
case PF_DXT5:
|
||||
case PF_BC6H_SIGNED:
|
||||
case PF_BC6H_UNSIGNED:
|
||||
case PF_BC7:
|
||||
case PF_ATI2: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 16 );
|
||||
case PF_LUMINANCE: return (width * height * depth);
|
||||
case PF_BGR_24:
|
||||
case PF_RGB_24: return (width * height * depth * 3);
|
||||
case PF_BGRA_32:
|
||||
case PF_RGBA_32: return (width * height * depth * 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Image_DXTCalcMipmapSize( dds_t *hdr )
|
||||
{
|
||||
size_t buffsize = 0;
|
||||
@@ -225,7 +219,7 @@ size_t Image_DXTCalcMipmapSize( dds_t *hdr )
|
||||
{
|
||||
width = Q_max( 1, ( hdr->dwWidth >> i ));
|
||||
height = Q_max( 1, ( hdr->dwHeight >> i ));
|
||||
buffsize += Image_ComputeSize( image.type, width, height, image.depth );
|
||||
buffsize += Image_DXTGetLinearSize( image.type, width, height, image.depth );
|
||||
}
|
||||
|
||||
return buffsize;
|
||||
@@ -261,7 +255,7 @@ uint Image_DXTCalcSize( const char *name, dds_t *hdr, size_t filesize )
|
||||
|
||||
if( filesize != buffsize ) // main check
|
||||
{
|
||||
Con_DPrintf( S_WARN "Image_LoadDDS: (%s) probably corrupted (%zu should be %lu)\n", name, buffsize, filesize );
|
||||
Con_DPrintf( S_WARN "Image_LoadDDS: (%s) probably corrupted (%i should be %lu)\n", name, buffsize, filesize );
|
||||
if( buffsize > filesize )
|
||||
return false;
|
||||
}
|
||||
@@ -274,7 +268,7 @@ void Image_DXTAdjustVolume( dds_t *hdr )
|
||||
if( hdr->dwDepth <= 1 )
|
||||
return;
|
||||
|
||||
hdr->dwLinearSize = Image_ComputeSize( image.type, hdr->dwWidth, hdr->dwHeight, hdr->dwDepth );
|
||||
hdr->dwLinearSize = Image_DXTGetLinearSize( image.type, hdr->dwWidth, hdr->dwHeight, hdr->dwDepth );
|
||||
hdr->dwFlags |= DDS_LINEARSIZE;
|
||||
}
|
||||
|
||||
@@ -329,7 +323,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
Image_DXTGetPixelFormat( &header, &header2 ); // and image type too :)
|
||||
Image_DXTAdjustVolume( &header );
|
||||
|
||||
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageCompressed( image.type ))
|
||||
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageDXT( image.type ))
|
||||
return false; // silently rejected
|
||||
|
||||
if( image.type == PF_UNKNOWN )
|
||||
@@ -362,10 +356,8 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin ))
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
else if( image.type == PF_BC5_SIGNED || image.type == PF_BC5_UNSIGNED )
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
else if( image.type == PF_BC7_UNORM || image.type == PF_BC7_SRGB )
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
else if ( image.type == PF_BC7 )
|
||||
SetBits(image.flags, IMAGE_HAS_ALPHA);
|
||||
if( !FBitSet( header.dsPixelFormat.dwFlags, DDS_LUMINANCE ))
|
||||
SetBits( image.flags, IMAGE_HAS_COLOR );
|
||||
break;
|
||||
|
||||
@@ -32,9 +32,6 @@ GNU General Public License for more details.
|
||||
#define TYPE_DX10 (('0'<<24)+('1'<<16)+('X'<<8)+'D') // little-endian "DX10"
|
||||
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
|
||||
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
|
||||
#define TYPE_BC5S (('S'<<24)+('5'<<16)+('C'<<8)+'B') // little-endian "BC5S"
|
||||
#define TYPE_BC4S (('S'<<24)+('4'<<16)+('C'<<8)+'B') // little-endian "BC4S"
|
||||
#define TYPE_BC4U (('U'<<24)+('4'<<16)+('C'<<8)+'B') // little-endian "BC4U"
|
||||
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
|
||||
#define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
|
||||
#define TYPE_o (('\0'<<24)+('\0'<<16)+('\0'<<8)+'o') // little-endian "o"
|
||||
@@ -205,7 +202,7 @@ typedef enum
|
||||
DXGI_FORMAT_FORCE_UINT = 0xffffffff
|
||||
} dxgi_format_t;
|
||||
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
|
||||
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
/*
|
||||
img_ktx2.c - ktx2 format load
|
||||
Copyright (C) 2023 Provod
|
||||
|
||||
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 "imagelib.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "img_ktx2.h"
|
||||
|
||||
static void Image_KTX2Format( uint32_t ktx2_format )
|
||||
{
|
||||
switch( ktx2_format )
|
||||
{
|
||||
case KTX2_FORMAT_BC4_UNORM_BLOCK:
|
||||
image.type = PF_BC4_UNSIGNED;
|
||||
// 1 component for ref_gl
|
||||
break;
|
||||
case KTX2_FORMAT_BC4_SNORM_BLOCK:
|
||||
image.type = PF_BC4_SIGNED;
|
||||
// 1 component for ref_gl
|
||||
break;
|
||||
case KTX2_FORMAT_BC5_UNORM_BLOCK:
|
||||
image.type = PF_BC5_UNSIGNED;
|
||||
// 2 components for ref_gl
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
break;
|
||||
case KTX2_FORMAT_BC5_SNORM_BLOCK:
|
||||
image.type = PF_BC5_SIGNED;
|
||||
// 2 components for ref_gl
|
||||
SetBits( image.flags, IMAGE_HAS_ALPHA );
|
||||
break;
|
||||
case KTX2_FORMAT_BC6H_UFLOAT_BLOCK:
|
||||
image.type = PF_BC6H_UNSIGNED;
|
||||
// 3 components for ref_gl
|
||||
SetBits( image.flags, IMAGE_HAS_COLOR );
|
||||
break;
|
||||
case KTX2_FORMAT_BC6H_SFLOAT_BLOCK:
|
||||
image.type = PF_BC6H_SIGNED;
|
||||
// 3 components for ref_gl
|
||||
SetBits( image.flags, IMAGE_HAS_COLOR );
|
||||
break;
|
||||
case KTX2_FORMAT_BC7_UNORM_BLOCK:
|
||||
image.type = PF_BC7_UNORM;
|
||||
// 4 components for ref_gl
|
||||
SetBits( image.flags, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
|
||||
break;
|
||||
case KTX2_FORMAT_BC7_SRGB_BLOCK:
|
||||
image.type = PF_BC7_SRGB;
|
||||
// 4 components for ref_gl
|
||||
SetBits( image.flags, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
|
||||
break;
|
||||
default:
|
||||
image.type = PF_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
ktx2_index_t index;
|
||||
size_t total_size = 0;
|
||||
size_t max_offset = 0;
|
||||
const byte *const levels_begin = buffer + KTX2_LEVELS_OFFSET;
|
||||
|
||||
// Sets image.type and image.flags
|
||||
Image_KTX2Format( header->vkFormat );
|
||||
|
||||
if( image.type == PF_UNKNOWN )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unsupported KTX2 format %d\n", __FUNCTION__, header->vkFormat );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Image_CheckFlag( IL_DDS_HARDWARE ) && ImageCompressed( image.type ))
|
||||
{
|
||||
Con_DPrintf( S_WARN "%s: has compressed format, but support is not advertized\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->levelCount == 0 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: file has no mip levels\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->pixelDepth > 1 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->faceCount > 1 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unsupported KTX2 faceCount %d\n", __FUNCTION__, header->faceCount );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->layerCount > 1 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unsupported KTX2 layerCount %d\n", __FUNCTION__, header->layerCount );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->supercompressionScheme != 0 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unsupported KTX2 supercompressionScheme %d\n", __FUNCTION__, header->supercompressionScheme );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( header->levelCount * sizeof( ktx2_level_t ) + KTX2_LEVELS_OFFSET > filesize )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: file abruptly ends\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy( &index, buffer + KTX2_IDENTIFIER_SIZE + sizeof( ktx2_header_t ), sizeof( index ));
|
||||
|
||||
for( int mip = 0; mip < header->levelCount; ++mip )
|
||||
{
|
||||
const uint32_t width = Q_max( 1, ( header->pixelWidth >> mip ));
|
||||
const uint32_t height = Q_max( 1, ( header->pixelHeight >> mip ));
|
||||
const uint32_t mip_size = Image_ComputeSize( image.type, width, height, image.depth );
|
||||
|
||||
ktx2_level_t level;
|
||||
memcpy( &level, levels_begin + mip * sizeof( level ), sizeof( level ));
|
||||
|
||||
if( mip_size != level.byteLength )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: mip=%d size mismatch read=%d, but computed=%d\n",
|
||||
__FUNCTION__, mip, (int)level.byteLength, mip_size );
|
||||
return false;
|
||||
}
|
||||
|
||||
total_size += level.byteLength;
|
||||
max_offset = Q_max( max_offset, level.byteLength + level.byteOffset );
|
||||
}
|
||||
|
||||
if( max_offset > filesize )
|
||||
return false;
|
||||
|
||||
image.size = total_size;
|
||||
image.num_mips = header->levelCount;
|
||||
|
||||
image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||
memcpy( image.rgba, buffer, image.size );
|
||||
|
||||
for( int mip = 0, cursor = 0; mip < header->levelCount; ++mip )
|
||||
{
|
||||
ktx2_level_t level;
|
||||
memcpy( &level, levels_begin + mip * sizeof( level ), sizeof( level ));
|
||||
memcpy( image.rgba + cursor, buffer + level.byteOffset, level.byteLength );
|
||||
cursor += level.byteLength;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean Image_LoadKTX2( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
ktx2_header_t header;
|
||||
|
||||
if( filesize < KTX2_MINIMAL_HEADER_SIZE )
|
||||
return false;
|
||||
|
||||
if( memcmp( buffer, KTX2_IDENTIFIER, KTX2_IDENTIFIER_SIZE ) != 0 )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: (%s) has invalid identifier\n", __FUNCTION__, name );
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy( &header, buffer + KTX2_IDENTIFIER_SIZE, sizeof( header ));
|
||||
|
||||
image.width = header.pixelWidth;
|
||||
image.height = header.pixelHeight;
|
||||
image.depth = Q_max( 1, header.pixelDepth );
|
||||
image.num_mips = 1;
|
||||
|
||||
ClearBits( image.flags, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA | IMAGE_HAS_LUMA );
|
||||
|
||||
if( !Image_KTX2Parse( &header, buffer, filesize ))
|
||||
{
|
||||
if( !Image_CheckFlag( IL_KTX2_RAW ))
|
||||
return false;
|
||||
|
||||
// If KTX2 to imagelib conversion failed, try passing the file as raw data.
|
||||
// This is useful for ref_vk which can directly support hundreds of formats which we don't convert to pixformat_t here
|
||||
|
||||
Con_DPrintf( S_WARN "%s: (%s) could not be converted to supported imagelib format, passing as raw KTX2 data\n", __FUNCTION__, name );
|
||||
// This is a catch-all for ref_vk, which can do this format directly and natively
|
||||
image.type = PF_KTX2_RAW;
|
||||
|
||||
image.size = filesize;
|
||||
//image.encode = TODO custom encode type?
|
||||
|
||||
image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||
memcpy( image.rgba, buffer, image.size );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
img_ktx2.h - ktx2 format reference
|
||||
Copyright (C) 2023 Provod
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
#ifndef IMG_KTX2_H
|
||||
#define IMG_KTX2_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define KTX2_IDENTIFIER_SIZE 12
|
||||
#define KTX2_IDENTIFIER "\xABKTX 20\xBB\r\n\x1A\n"
|
||||
|
||||
/*
|
||||
static const char k_ktx2_identifier[KTX2_IDENTIFIER_SIZE] =
|
||||
{
|
||||
'\xAB', 'K', 'T', 'X', ' ', '2', '0', '\xBB', '\r', '\n', '\x1A', '\n'
|
||||
};
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t vkFormat;
|
||||
uint32_t typeSize;
|
||||
uint32_t pixelWidth;
|
||||
uint32_t pixelHeight;
|
||||
uint32_t pixelDepth;
|
||||
uint32_t layerCount;
|
||||
uint32_t faceCount;
|
||||
uint32_t levelCount;
|
||||
uint32_t supercompressionScheme;
|
||||
} ktx2_header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dfdByteOffset;
|
||||
uint32_t dfdByteLength;
|
||||
uint32_t kvdByteOffset;
|
||||
uint32_t kvdByteLength;
|
||||
uint64_t sgdByteOffset;
|
||||
uint64_t sgdByteLength;
|
||||
} ktx2_index_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t byteOffset;
|
||||
uint64_t byteLength;
|
||||
uint64_t uncompressedByteLength;
|
||||
} ktx2_level_t;
|
||||
|
||||
#define KTX2_LEVELS_OFFSET ( KTX2_IDENTIFIER_SIZE + sizeof( ktx2_header_t ) + sizeof( ktx2_index_t ))
|
||||
|
||||
#define KTX2_MINIMAL_HEADER_SIZE ( KTX2_LEVELS_OFFSET + sizeof( ktx2_level_t ))
|
||||
|
||||
// These have the same values as enum VkFormat in vulkan_core.h
|
||||
// There are hundreds of formats which can be contained in KTX2.
|
||||
// Below are listed the ones which are supported here. This list can be extended.
|
||||
typedef enum
|
||||
{
|
||||
KTX2_FORMAT_BC4_UNORM_BLOCK = 139,
|
||||
KTX2_FORMAT_BC4_SNORM_BLOCK = 140,
|
||||
KTX2_FORMAT_BC5_UNORM_BLOCK = 141,
|
||||
KTX2_FORMAT_BC5_SNORM_BLOCK = 142,
|
||||
KTX2_FORMAT_BC6H_UFLOAT_BLOCK = 143,
|
||||
KTX2_FORMAT_BC6H_SFLOAT_BLOCK = 144,
|
||||
KTX2_FORMAT_BC7_UNORM_BLOCK = 145,
|
||||
KTX2_FORMAT_BC7_SRGB_BLOCK = 146,
|
||||
} ktx2_format_t;
|
||||
|
||||
#endif // IMG_KTX2_H
|
||||
@@ -105,7 +105,6 @@ static const loadpixformat_t load_game[] =
|
||||
{ "%s%s.%s", "lmp", Image_LoadLMP, IL_HINT_NO }, // hl menu images (cached.wad etc)
|
||||
{ "%s%s.%s", "fnt", Image_LoadFNT, IL_HINT_HL }, // hl console font (fonts.wad etc)
|
||||
{ "%s%s.%s", "pal", Image_LoadPAL, IL_HINT_NO }, // install studio\sprite palette
|
||||
{ "%s%s.%s", "ktx2", Image_LoadKTX2, IL_HINT_NO }, // ktx2 for world and studio models
|
||||
{ NULL, NULL, NULL, IL_HINT_NO }
|
||||
};
|
||||
|
||||
@@ -284,10 +283,8 @@ int Image_ComparePalette( const byte *pal )
|
||||
void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
{
|
||||
byte rgba[4];
|
||||
uint uirgba; // TODO: palette looks byte-swapped on big-endian
|
||||
int i;
|
||||
|
||||
|
||||
// setup palette
|
||||
switch( image.d_rendermode )
|
||||
{
|
||||
@@ -298,8 +295,7 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
rgba[1] = pal[i*3+1];
|
||||
rgba[2] = pal[i*3+2];
|
||||
rgba[3] = 0xFF;
|
||||
memcpy( &uirgba, rgba, sizeof( uirgba ));
|
||||
d_table[i] = uirgba;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
case LUMP_GRADIENT:
|
||||
@@ -309,8 +305,7 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
rgba[1] = pal[766];
|
||||
rgba[2] = pal[767];
|
||||
rgba[3] = i;
|
||||
memcpy( &uirgba, rgba, sizeof( uirgba ));
|
||||
d_table[i] = uirgba;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
case LUMP_MASKED:
|
||||
@@ -320,8 +315,7 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
rgba[1] = pal[i*3+1];
|
||||
rgba[2] = pal[i*3+2];
|
||||
rgba[3] = 0xFF;
|
||||
memcpy( &uirgba, rgba, sizeof( uirgba ));
|
||||
d_table[i] = uirgba;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
d_table[255] = 0;
|
||||
break;
|
||||
@@ -332,8 +326,7 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
rgba[1] = pal[i*4+1];
|
||||
rgba[2] = pal[i*4+2];
|
||||
rgba[3] = pal[i*4+3];
|
||||
memcpy( &uirgba, rgba, sizeof( uirgba ));
|
||||
d_table[i] = uirgba;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1453,36 +1446,3 @@ qboolean Image_Process(rgbdata_t **pix, int width, int height, uint flags, float
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// This codebase has too many copies of this function:
|
||||
// - ref_gl has one
|
||||
// - ref_vk has one
|
||||
// - ref_soft has one
|
||||
// - many more places probably have one too
|
||||
// TODO figure out how to make it available for ref_*
|
||||
size_t Image_ComputeSize( int type, int width, int height, int depth )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case PF_DXT1:
|
||||
case PF_BC4_SIGNED:
|
||||
case PF_BC4_UNSIGNED:
|
||||
return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 8 );
|
||||
case PF_DXT3:
|
||||
case PF_DXT5:
|
||||
case PF_ATI2:
|
||||
case PF_BC5_UNSIGNED:
|
||||
case PF_BC5_SIGNED:
|
||||
case PF_BC6H_SIGNED:
|
||||
case PF_BC6H_UNSIGNED:
|
||||
case PF_BC7_UNORM:
|
||||
case PF_BC7_SRGB: return ((( width + 3 ) / 4 ) * (( height + 3 ) / 4 ) * depth * 16 );
|
||||
case PF_LUMINANCE: return ( width * height * depth );
|
||||
case PF_BGR_24:
|
||||
case PF_RGB_24: return ( width * height * depth * 3 );
|
||||
case PF_BGRA_32:
|
||||
case PF_RGBA_32: return ( width * height * depth * 4 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ Searches the string for the given
|
||||
key and returns the associated value, or an empty string.
|
||||
===============
|
||||
*/
|
||||
const char *GAME_EXPORT Info_ValueForKey( const char *s, const char *key )
|
||||
const char *Info_ValueForKey( const char *s, const char *key )
|
||||
{
|
||||
char pkey[MAX_KV_SIZE];
|
||||
static char value[4][MAX_KV_SIZE]; // use two buffers so compares work without stomping on each other
|
||||
|
||||
@@ -177,9 +177,7 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
{
|
||||
// Next thing must be a quad, or end of input. Is it a quad?
|
||||
int quadDigit = ParseIPv6Addr_HexDigitVal( *s );
|
||||
const char *pszStartQuad;
|
||||
int quad;
|
||||
|
||||
if ( quadDigit < 0 )
|
||||
{
|
||||
if ( bQuadMustFollow )
|
||||
@@ -191,7 +189,6 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
if ( d >= pEndIP )
|
||||
return false;
|
||||
|
||||
pszStartQuad = s;
|
||||
++s;
|
||||
quad = quadDigit;
|
||||
|
||||
@@ -217,60 +214,6 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we hit a period, which would happen if we
|
||||
// have an IPv4 dotted decimal. For example, "::ffff:192.168.1.210"
|
||||
if ( *s == '.' )
|
||||
{
|
||||
// Make sure we would have room to store four more bytes.
|
||||
unsigned char *pEndDottedDecimal = d+4;
|
||||
if ( pEndDottedDecimal > pEndIP )
|
||||
return false;
|
||||
|
||||
// Parse 4 octets
|
||||
s = pszStartQuad;
|
||||
for (;;)
|
||||
{
|
||||
|
||||
// Parse 1-3 decimal digits
|
||||
int octet = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
int dig;
|
||||
|
||||
if ( octet < 0 )
|
||||
return false;
|
||||
++s;
|
||||
dig = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( dig >= 0 )
|
||||
{
|
||||
++s;
|
||||
octet = octet*10 + dig;
|
||||
dig = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( dig >= 0 )
|
||||
{
|
||||
++s;
|
||||
octet = octet*10 + dig;
|
||||
|
||||
// Make sure value is in range.
|
||||
if ( octet > 255 )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*(d++) = (unsigned char)octet;
|
||||
|
||||
// All done?
|
||||
if ( d >= pEndDottedDecimal )
|
||||
break;
|
||||
|
||||
// Next thing must be dot dot separator
|
||||
if ( *s != '.' )
|
||||
return false;
|
||||
|
||||
// Eat dot
|
||||
++s;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Stash it in the next slot, ignoring for now the issue
|
||||
// of compressed zeros
|
||||
*(d++) = (unsigned char)( quad >> 8 );
|
||||
@@ -345,7 +288,7 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
int nScopeDigit;
|
||||
|
||||
++s;
|
||||
|
||||
|
||||
nScopeDigit = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( nScopeDigit < 0 )
|
||||
return false;
|
||||
|
||||
@@ -25,10 +25,8 @@ extern "C" {
|
||||
extern void IPv6IPToString( char *pszOutText, const unsigned char *ip );
|
||||
|
||||
/// Format IPv6 IP and port to string. This uses the recommended
|
||||
/// bracket notation, eg [1234::1]:12345. Your buffer MUST be
|
||||
/// bracket notation, eg [1234::1]:12345. Your buffer must be
|
||||
/// at least k_ncchMaxIPV6AddrStringWithPort bytes.
|
||||
///
|
||||
/// If the scope is zero, it is not printed.
|
||||
extern void IPv6AddrToString( char *pszOutText, const unsigned char *ip, uint16_t port, uint32_t scope );
|
||||
|
||||
/// Parse IPv6 address string. Returns true if parsed OK. Returns false
|
||||
@@ -43,7 +41,7 @@ extern void IPv6AddrToString( char *pszOutText, const unsigned char *ip, uint16_
|
||||
///
|
||||
/// Leading and trailing whitespace is OK around the entire string,
|
||||
/// but not internal whitespace. The different methods for separating the
|
||||
/// port in RFC5952 section 6 are supported, except the ambiguous case
|
||||
/// port in RFC5952 are supported section 6, except the ambiguous case
|
||||
/// of a colon to separate the port, when the IP contains a double-colon.
|
||||
/// Brackets around an IP are OK, even if there is no port.
|
||||
///
|
||||
|
||||
@@ -23,6 +23,15 @@ GNU General Public License for more details.
|
||||
|
||||
#if XASH_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
#elif XASH_WIN32
|
||||
extern "C"
|
||||
{
|
||||
// Enable NVIDIA High Performance Graphics while using Integrated Graphics.
|
||||
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||
|
||||
// Enable AMD High Performance Graphics while using Integrated Graphics.
|
||||
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define E_GAME "XASH3D_GAME" // default env dir to start from
|
||||
@@ -30,10 +39,6 @@ GNU General Public License for more details.
|
||||
#define XASH_GAMEDIR "valve"
|
||||
#endif
|
||||
|
||||
#if XASH_WIN32
|
||||
#error "Single-binary or dedicated builds aren't supported for Windows!"
|
||||
#endif
|
||||
|
||||
static char szGameDir[128]; // safe place to keep gamedir
|
||||
static int szArgc;
|
||||
static char **szArgv;
|
||||
@@ -42,7 +47,7 @@ static void Sys_ChangeGame( const char *progname )
|
||||
{
|
||||
// a1ba: may never be called within engine
|
||||
// if platform supports execv() function
|
||||
Q_strncpy( szGameDir, progname, sizeof( szGameDir ));
|
||||
Q_strncpy( szGameDir, progname, sizeof( szGameDir ) - 1 );
|
||||
Host_Shutdown( );
|
||||
exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) );
|
||||
}
|
||||
@@ -83,6 +88,7 @@ _inline int Sys_Start( void )
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !XASH_WIN32
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
#if XASH_PSVITA
|
||||
@@ -94,4 +100,36 @@ int main( int argc, char **argv )
|
||||
#endif // XASH_PSVITA
|
||||
return Sys_Start();
|
||||
}
|
||||
#endif // SINGLE_BINARY
|
||||
#else
|
||||
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int nShow)
|
||||
{
|
||||
LPWSTR* lpArgv;
|
||||
int ret, i;
|
||||
|
||||
lpArgv = CommandLineToArgvW( GetCommandLineW(), &szArgc );
|
||||
szArgv = ( char** )malloc( (szArgc + 1) * sizeof( char* ));
|
||||
|
||||
for( i = 0; i < szArgc; ++i )
|
||||
{
|
||||
size_t size = wcslen(lpArgv[i]) + 1;
|
||||
|
||||
// just in case, allocate some more memory
|
||||
szArgv[i] = ( char * )malloc( size * sizeof( wchar_t ));
|
||||
wcstombs( szArgv[i], lpArgv[i], size );
|
||||
}
|
||||
szArgv[szArgc] = 0;
|
||||
|
||||
LocalFree( lpArgv );
|
||||
|
||||
ret = Sys_Start();
|
||||
|
||||
for( ; i < szArgc; ++i )
|
||||
free( szArgv[i] );
|
||||
free( szArgv );
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif // XASH_WIN32
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -419,6 +419,5 @@ void NET_InitMasters( void )
|
||||
|
||||
// keep main master always there
|
||||
NET_AddMaster( MASTERSERVER_ADR, false );
|
||||
NET_AddMaster( MASTERSERVER_ADR_TEST, false );
|
||||
NET_LoadMasters( );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -113,16 +113,15 @@ typedef struct world_static_s
|
||||
// tree visualization stuff
|
||||
int recursion_level;
|
||||
int max_recursion;
|
||||
|
||||
uint32_t version; // BSP version
|
||||
} world_static_t;
|
||||
|
||||
#ifndef REF_DLL
|
||||
extern world_static_t world;
|
||||
extern poolhandle_t com_studiocache;
|
||||
extern convar_t mod_studiocache;
|
||||
extern convar_t r_wadtextures;
|
||||
extern convar_t r_showhull;
|
||||
extern model_t *loadmodel;
|
||||
extern convar_t *mod_studiocache;
|
||||
extern convar_t *r_wadtextures;
|
||||
extern convar_t *r_showhull;
|
||||
|
||||
//
|
||||
// model.c
|
||||
@@ -157,7 +156,7 @@ int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
|
||||
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
|
||||
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
|
||||
int Mod_SampleSizeForFace( const msurface_t *surf );
|
||||
int Mod_SampleSizeForFace( msurface_t *surf );
|
||||
byte *Mod_GetPVSForPoint( const vec3_t p );
|
||||
void Mod_UnloadBrushModel( model_t *mod );
|
||||
void Mod_PrintWorldStats_f( void );
|
||||
@@ -165,7 +164,7 @@ void Mod_PrintWorldStats_f( void );
|
||||
//
|
||||
// mod_dbghulls.c
|
||||
//
|
||||
void Mod_InitDebugHulls( model_t *mod );
|
||||
void Mod_InitDebugHulls( void );
|
||||
void Mod_CreatePolygonsForHull( int hullnum );
|
||||
void Mod_ReleaseHullPolygons( void );
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
|
||||
bSkipShield = false;
|
||||
*numhitboxes = 0; // assume error
|
||||
|
||||
if( mod_studiocache.value )
|
||||
if( mod_studiocache->value )
|
||||
{
|
||||
bonecache = Mod_CheckStudioCache( model, frame, sequence, angles, origin, size, pcontroller, pblending );
|
||||
|
||||
@@ -286,7 +286,7 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
|
||||
// tell trace code about hitbox count
|
||||
*numhitboxes = (bSkipShield) ? (mod_studiohdr->numhitboxes - 1) : (mod_studiohdr->numhitboxes);
|
||||
|
||||
if( mod_studiocache.value )
|
||||
if( mod_studiocache->value )
|
||||
Mod_AddToStudioCache( frame, sequence, angles, origin, size, pcontroller, pblending, model, studio_hull, *numhitboxes );
|
||||
|
||||
return studio_hull;
|
||||
@@ -851,11 +851,11 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
char poolname[MAX_VA_STRING];
|
||||
studiohdr_t *phdr;
|
||||
|
||||
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name );
|
||||
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", loadmodel->name );
|
||||
|
||||
if( loaded ) *loaded = false;
|
||||
mod->mempool = Mem_AllocPool( poolname );
|
||||
mod->type = mod_studio;
|
||||
loadmodel->mempool = Mem_AllocPool( poolname );
|
||||
loadmodel->type = mod_studio;
|
||||
|
||||
phdr = R_StudioLoadHeader( mod, buffer );
|
||||
if( !phdr ) return; // bad model
|
||||
@@ -886,9 +886,9 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
// give space for textures and skinrefs
|
||||
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
|
||||
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
|
||||
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length + size1 + size2 );
|
||||
memcpy( mod->cache.data, buffer, phdr->length ); // copy main mdl buffer
|
||||
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
|
||||
mod->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length + size1 + size2 );
|
||||
memcpy( loadmodel->cache.data, buffer, phdr->length ); // copy main mdl buffer
|
||||
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
|
||||
phdr->numskinfamilies = thdr->numskinfamilies;
|
||||
phdr->numtextures = thdr->numtextures;
|
||||
phdr->numskinref = thdr->numskinref;
|
||||
@@ -905,52 +905,52 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
else
|
||||
{
|
||||
// NOTE: don't modify source buffer because it's used for CRC computing
|
||||
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length );
|
||||
memcpy( mod->cache.data, buffer, phdr->length );
|
||||
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
|
||||
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length );
|
||||
memcpy( loadmodel->cache.data, buffer, phdr->length );
|
||||
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
|
||||
#if !XASH_DEDICATED
|
||||
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
|
||||
#endif
|
||||
|
||||
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
|
||||
mod->cache.data = Mem_Realloc( mod->mempool, mod->cache.data, phdr->texturedataindex );
|
||||
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
|
||||
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex );
|
||||
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
|
||||
phdr->length = phdr->texturedataindex; // update model size
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// just copy model into memory
|
||||
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length );
|
||||
memcpy( mod->cache.data, buffer, phdr->length );
|
||||
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length );
|
||||
memcpy( loadmodel->cache.data, buffer, phdr->length );
|
||||
|
||||
phdr = mod->cache.data;
|
||||
phdr = loadmodel->cache.data;
|
||||
}
|
||||
|
||||
// setup bounding box
|
||||
if( !VectorCompare( vec3_origin, phdr->bbmin ))
|
||||
{
|
||||
// clipping bounding box
|
||||
VectorCopy( phdr->bbmin, mod->mins );
|
||||
VectorCopy( phdr->bbmax, mod->maxs );
|
||||
VectorCopy( phdr->bbmin, loadmodel->mins );
|
||||
VectorCopy( phdr->bbmax, loadmodel->maxs );
|
||||
}
|
||||
else if( !VectorCompare( vec3_origin, phdr->min ))
|
||||
{
|
||||
// movement bounding box
|
||||
VectorCopy( phdr->min, mod->mins );
|
||||
VectorCopy( phdr->max, mod->maxs );
|
||||
VectorCopy( phdr->min, loadmodel->mins );
|
||||
VectorCopy( phdr->max, loadmodel->maxs );
|
||||
}
|
||||
else
|
||||
{
|
||||
// well compute bounds from vertices and round to nearest even values
|
||||
Mod_StudioComputeBounds( phdr, mod->mins, mod->maxs, true );
|
||||
RoundUpHullSize( mod->mins );
|
||||
RoundUpHullSize( mod->maxs );
|
||||
Mod_StudioComputeBounds( phdr, loadmodel->mins, loadmodel->maxs, true );
|
||||
RoundUpHullSize( loadmodel->mins );
|
||||
RoundUpHullSize( loadmodel->maxs );
|
||||
}
|
||||
|
||||
mod->numframes = Mod_StudioBodyVariations( mod );
|
||||
mod->radius = RadiusFromBounds( mod->mins, mod->maxs );
|
||||
mod->flags = phdr->flags; // copy header flags
|
||||
loadmodel->numframes = Mod_StudioBodyVariations( loadmodel );
|
||||
loadmodel->radius = RadiusFromBounds( loadmodel->mins, loadmodel->maxs );
|
||||
loadmodel->flags = phdr->flags; // copy header flags
|
||||
|
||||
if( loaded ) *loaded = true;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@ static model_info_t mod_crcinfo[MAX_MODELS];
|
||||
static model_t mod_known[MAX_MODELS];
|
||||
static int mod_numknown = 0;
|
||||
poolhandle_t com_studiocache; // cache for submodels
|
||||
CVAR_DEFINE( mod_studiocache, "r_studiocache", "1", FCVAR_ARCHIVE, "enables studio cache for speedup tracing hitboxes" );
|
||||
CVAR_DEFINE_AUTO( r_wadtextures, "0", 0, "completely ignore textures in the bsp-file if enabled" );
|
||||
CVAR_DEFINE_AUTO( r_showhull, "0", 0, "draw collision hulls 1-3" );
|
||||
convar_t *mod_studiocache;
|
||||
convar_t *r_wadtextures;
|
||||
convar_t *r_showhull;
|
||||
model_t *loadmodel;
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
@@ -111,7 +112,6 @@ void Mod_FreeModel( model_t *mod )
|
||||
|
||||
if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) )
|
||||
{
|
||||
world.version = 0;
|
||||
world.shadowdata = NULL;
|
||||
world.deluxedata = NULL;
|
||||
}
|
||||
@@ -134,9 +134,9 @@ Mod_Init
|
||||
void Mod_Init( void )
|
||||
{
|
||||
com_studiocache = Mem_AllocPool( "Studio Cache" );
|
||||
Cvar_RegisterVariable( &mod_studiocache );
|
||||
Cvar_RegisterVariable( &r_wadtextures );
|
||||
Cvar_RegisterVariable( &r_showhull );
|
||||
mod_studiocache = Cvar_Get( "r_studiocache", "1", FCVAR_ARCHIVE, "enables studio cache for speedup tracing hitboxes" );
|
||||
r_wadtextures = Cvar_Get( "r_wadtextures", "0", 0, "completely ignore textures in the bsp-file if enabled" );
|
||||
r_showhull = Cvar_Get( "r_showhull", "0", 0, "draw collision hulls 1-3" );
|
||||
|
||||
Cmd_AddCommand( "mapstats", Mod_PrintWorldStats_f, "show stats for currently loaded map" );
|
||||
Cmd_AddCommand( "modellist", Mod_Modellist_f, "display loaded models list" );
|
||||
@@ -287,6 +287,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
Con_Reportf( "loading %s\n", mod->name );
|
||||
mod->needload = NL_PRESENT;
|
||||
mod->type = mod_bad;
|
||||
loadmodel = mod;
|
||||
|
||||
// call the apropriate loader
|
||||
switch( *(uint *)buf )
|
||||
@@ -402,7 +403,7 @@ static void Mod_PurgeStudioCache( void )
|
||||
int i;
|
||||
|
||||
// refresh hull data
|
||||
SetBits( r_showhull.flags, FCVAR_CHANGED );
|
||||
SetBits( r_showhull->flags, FCVAR_CHANGED );
|
||||
#if !XASH_DEDICATED
|
||||
Mod_ReleaseHullPolygons();
|
||||
#endif
|
||||
|
||||
@@ -23,8 +23,8 @@ GNU General Public License for more details.
|
||||
// precalculated bit masks for WriteUBitLong.
|
||||
// Using these tables instead of doing the calculations
|
||||
// gives a 33% speedup in WriteUBitLong.
|
||||
static uint32_t BitWriteMasks[32][33];
|
||||
static uint32_t ExtraMasks[32];
|
||||
static dword BitWriteMasks[32][33];
|
||||
static dword ExtraMasks[32];
|
||||
const char *svc_strings[svc_lastmsg+1] =
|
||||
{
|
||||
"svc_bad",
|
||||
@@ -119,7 +119,7 @@ void MSG_InitExt( sizebuf_t *sb, const char *pDebugName, void *pData, int nBytes
|
||||
void MSG_StartWriting( sizebuf_t *sb, void *pData, int nBytes, int iStartBit, int nBits )
|
||||
{
|
||||
// make sure it's dword aligned and padded.
|
||||
Assert(((uint32_t)pData & 3 ) == 0 );
|
||||
Assert(((dword)pData & 3 ) == 0 );
|
||||
|
||||
sb->pDebugName = "Unnamed";
|
||||
sb->pData = (byte *)pData;
|
||||
@@ -219,14 +219,14 @@ void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
||||
int nBitsLeft = numbits;
|
||||
int iCurBit = sb->iCurBit;
|
||||
uint iDWord = iCurBit >> 5; // Mask in a dword.
|
||||
uint32_t iCurBitMasked;
|
||||
dword iCurBitMasked;
|
||||
int nBitsWritten;
|
||||
|
||||
Assert(( iDWord * 4 + sizeof( int )) <= (uint)MSG_GetMaxBytes( sb ));
|
||||
|
||||
iCurBitMasked = iCurBit & 31;
|
||||
((uint32_t *)sb->pData)[iDWord] &= BitWriteMasks[iCurBitMasked][nBitsLeft];
|
||||
((uint32_t *)sb->pData)[iDWord] |= curData << iCurBitMasked;
|
||||
((dword *)sb->pData)[iDWord] &= BitWriteMasks[iCurBitMasked][nBitsLeft];
|
||||
((dword *)sb->pData)[iDWord] |= curData << iCurBitMasked;
|
||||
|
||||
// did it span a dword?
|
||||
nBitsWritten = 32 - iCurBitMasked;
|
||||
@@ -238,8 +238,8 @@ void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
||||
curData >>= nBitsWritten;
|
||||
|
||||
iCurBitMasked = iCurBit & 31;
|
||||
((uint32_t *)sb->pData)[iDWord+1] &= BitWriteMasks[iCurBitMasked][nBitsLeft];
|
||||
((uint32_t *)sb->pData)[iDWord+1] |= curData << iCurBitMasked;
|
||||
((dword *)sb->pData)[iDWord+1] &= BitWriteMasks[iCurBitMasked][nBitsLeft];
|
||||
((dword *)sb->pData)[iDWord+1] |= curData << iCurBitMasked;
|
||||
}
|
||||
sb->iCurBit += numbits;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ qboolean MSG_WriteBits( sizebuf_t *sb, const void *pData, int nBits )
|
||||
int nBitsLeft = nBits;
|
||||
|
||||
// get output dword-aligned.
|
||||
while((( uint32_t )pOut & 3 ) != 0 && nBitsLeft >= 8 )
|
||||
while((( dword )pOut & 3 ) != 0 && nBitsLeft >= 8 )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, *pOut, 8 );
|
||||
|
||||
@@ -295,9 +295,9 @@ qboolean MSG_WriteBits( sizebuf_t *sb, const void *pData, int nBits )
|
||||
// read dwords.
|
||||
while( nBitsLeft >= 32 )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, *(( uint32_t *)pOut ), 32 );
|
||||
MSG_WriteUBitLong( sb, *(( dword *)pOut ), 32 );
|
||||
|
||||
pOut += sizeof( uint32_t );
|
||||
pOut += sizeof( dword );
|
||||
nBitsLeft -= 32;
|
||||
}
|
||||
|
||||
@@ -383,37 +383,37 @@ void MSG_WriteCmdExt( sizebuf_t *sb, int cmd, netsrc_t type, const char *name )
|
||||
}
|
||||
}
|
||||
#endif
|
||||
MSG_WriteUBitLong( sb, cmd, sizeof( uint8_t ) << 3 );
|
||||
MSG_WriteUBitLong( sb, cmd, sizeof( byte ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteChar( sizebuf_t *sb, int val )
|
||||
{
|
||||
MSG_WriteSBitLong( sb, val, sizeof( int8_t ) << 3 );
|
||||
MSG_WriteSBitLong( sb, val, sizeof( char ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteByte( sizebuf_t *sb, int val )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, val, sizeof( uint8_t ) << 3 );
|
||||
MSG_WriteUBitLong( sb, val, sizeof( byte ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteShort( sizebuf_t *sb, int val )
|
||||
{
|
||||
MSG_WriteSBitLong( sb, val, sizeof( int16_t ) << 3 );
|
||||
MSG_WriteSBitLong( sb, val, sizeof(short ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteWord( sizebuf_t *sb, int val )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, val, sizeof( uint16_t ) << 3 );
|
||||
MSG_WriteUBitLong( sb, val, sizeof( word ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteLong( sizebuf_t *sb, int val )
|
||||
{
|
||||
MSG_WriteSBitLong( sb, val, sizeof( int32_t ) << 3 );
|
||||
MSG_WriteSBitLong( sb, val, sizeof( int ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteDword( sizebuf_t *sb, uint val )
|
||||
void MSG_WriteDword( sizebuf_t *sb, dword val )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, val, sizeof( uint32_t ) << 3 );
|
||||
MSG_WriteUBitLong( sb, val, sizeof( dword ) << 3 );
|
||||
}
|
||||
|
||||
void MSG_WriteFloat( sizebuf_t *sb, float val )
|
||||
@@ -518,7 +518,7 @@ qboolean MSG_ReadBits( sizebuf_t *sb, void *pOutData, int nBits )
|
||||
int nBitsLeft = nBits;
|
||||
|
||||
// get output dword-aligned.
|
||||
while((( uint32_t )pOut & 3) != 0 && nBitsLeft >= 8 )
|
||||
while((( dword )pOut & 3) != 0 && nBitsLeft >= 8 )
|
||||
{
|
||||
*pOut = (byte)MSG_ReadUBitLong( sb, 8 );
|
||||
++pOut;
|
||||
@@ -528,8 +528,8 @@ qboolean MSG_ReadBits( sizebuf_t *sb, void *pOutData, int nBits )
|
||||
// read dwords.
|
||||
while( nBitsLeft >= 32 )
|
||||
{
|
||||
*((uint32_t *)pOut) = MSG_ReadUBitLong( sb, 32 );
|
||||
pOut += sizeof( uint32_t );
|
||||
*((dword *)pOut) = MSG_ReadUBitLong( sb, 32 );
|
||||
pOut += sizeof( dword );
|
||||
nBitsLeft -= 32;
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ uint MSG_ReadBitLong( sizebuf_t *sb, int numbits, qboolean bSigned )
|
||||
|
||||
int MSG_ReadCmd( sizebuf_t *sb, netsrc_t type )
|
||||
{
|
||||
int cmd = MSG_ReadUBitLong( sb, sizeof( uint8_t ) << 3 );
|
||||
int cmd = MSG_ReadUBitLong( sb, sizeof( byte ) << 3 );
|
||||
|
||||
#ifdef DEBUG_NET_MESSAGES_READ
|
||||
if( type == NS_SERVER )
|
||||
@@ -608,22 +608,22 @@ int MSG_ReadCmd( sizebuf_t *sb, netsrc_t type )
|
||||
|
||||
int MSG_ReadChar( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadSBitLong( sb, sizeof( int8_t ) << 3 );
|
||||
return MSG_ReadSBitLong( sb, sizeof( char ) << 3 );
|
||||
}
|
||||
|
||||
int MSG_ReadByte( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadUBitLong( sb, sizeof( uint8_t ) << 3 );
|
||||
return MSG_ReadUBitLong( sb, sizeof( byte ) << 3 );
|
||||
}
|
||||
|
||||
int MSG_ReadShort( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadSBitLong( sb, sizeof( int16_t ) << 3 );
|
||||
return MSG_ReadSBitLong( sb, sizeof( short ) << 3 );
|
||||
}
|
||||
|
||||
int MSG_ReadWord( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadUBitLong( sb, sizeof( uint16_t ) << 3 );
|
||||
return MSG_ReadUBitLong( sb, sizeof( word ) << 3 );
|
||||
}
|
||||
|
||||
float MSG_ReadCoord( sizebuf_t *sb )
|
||||
@@ -650,12 +650,12 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa )
|
||||
|
||||
int MSG_ReadLong( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadSBitLong( sb, sizeof( int32_t ) << 3 );
|
||||
return MSG_ReadSBitLong( sb, sizeof( int ) << 3 );
|
||||
}
|
||||
|
||||
uint MSG_ReadDword( sizebuf_t *sb )
|
||||
dword MSG_ReadDword( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadUBitLong( sb, sizeof( uint32_t ) << 3 );
|
||||
return MSG_ReadUBitLong( sb, sizeof( dword ) << 3 );
|
||||
}
|
||||
|
||||
float MSG_ReadFloat( sizebuf_t *sb )
|
||||
|
||||
@@ -94,7 +94,7 @@ void MSG_WriteByte( sizebuf_t *sb, int val );
|
||||
void MSG_WriteShort( sizebuf_t *sb, int val );
|
||||
void MSG_WriteWord( sizebuf_t *sb, int val );
|
||||
void MSG_WriteLong( sizebuf_t *sb, int val );
|
||||
void MSG_WriteDword( sizebuf_t *sb, uint val );
|
||||
void MSG_WriteDword( sizebuf_t *sb, dword val );
|
||||
void MSG_WriteCoord( sizebuf_t *sb, float val );
|
||||
void MSG_WriteFloat( sizebuf_t *sb, float val );
|
||||
void MSG_WriteVec3Coord( sizebuf_t *sb, const float *fa );
|
||||
@@ -131,7 +131,7 @@ int MSG_ReadByte( sizebuf_t *sb );
|
||||
int MSG_ReadShort( sizebuf_t *sb );
|
||||
int MSG_ReadWord( sizebuf_t *sb );
|
||||
int MSG_ReadLong( sizebuf_t *sb );
|
||||
uint MSG_ReadDword( sizebuf_t *sb );
|
||||
dword MSG_ReadDword( sizebuf_t *sb );
|
||||
float MSG_ReadCoord( sizebuf_t *sb );
|
||||
float MSG_ReadFloat( sizebuf_t *sb );
|
||||
void MSG_ReadVec3Coord( sizebuf_t *sb, vec3_t fa );
|
||||
|
||||
@@ -84,10 +84,10 @@ such as during the connection stage while waiting for the client to load,
|
||||
then a packet only needs to be delivered if there is something in the
|
||||
unacknowledged reliable
|
||||
*/
|
||||
CVAR_DEFINE_AUTO( net_showpackets, "0", 0, "show network packets" );
|
||||
CVAR_DEFINE_AUTO( net_chokeloop, "0", 0, "apply bandwidth choke to loopback packets" );
|
||||
CVAR_DEFINE_AUTO( net_showdrop, "0", 0, "show packets that are dropped" );
|
||||
CVAR_DEFINE_AUTO( net_qport, "0", FCVAR_READ_ONLY, "current quake netport" );
|
||||
convar_t *net_showpackets;
|
||||
convar_t *net_chokeloopback;
|
||||
convar_t *net_showdrop;
|
||||
convar_t *net_qport;
|
||||
|
||||
int net_drop;
|
||||
netadr_t net_from;
|
||||
@@ -243,18 +243,15 @@ Netchan_Init
|
||||
*/
|
||||
void Netchan_Init( void )
|
||||
{
|
||||
char buf[32];
|
||||
int port;
|
||||
|
||||
// pick a port value that should be nice and random
|
||||
port = COM_RandomLong( 1, 65535 );
|
||||
Q_snprintf( buf, sizeof( buf ), "%i", port );
|
||||
|
||||
Cvar_RegisterVariable( &net_showpackets );
|
||||
Cvar_RegisterVariable( &net_chokeloop );
|
||||
Cvar_RegisterVariable( &net_showdrop );
|
||||
Cvar_RegisterVariable( &net_qport );
|
||||
Cvar_FullSet( net_qport.name, buf, net_qport.flags );
|
||||
net_showpackets = Cvar_Get ("net_showpackets", "0", 0, "show network packets" );
|
||||
net_chokeloopback = Cvar_Get( "net_chokeloop", "0", 0, "apply bandwidth choke to loopback packets" );
|
||||
net_showdrop = Cvar_Get( "net_showdrop", "0", 0, "show packets that are dropped" );
|
||||
net_qport = Cvar_Getf( "net_qport", FCVAR_READ_ONLY, "current quake netport", "%i", port );
|
||||
|
||||
net_mempool = Mem_AllocPool( "Network Pool" );
|
||||
|
||||
@@ -352,7 +349,7 @@ Returns true if the bandwidth choke isn't active
|
||||
qboolean Netchan_CanPacket( netchan_t *chan, qboolean choke )
|
||||
{
|
||||
// never choke loopback packets.
|
||||
if( !choke || ( !net_chokeloop.value && NET_IsLocalAddress( chan->remote_address ) ))
|
||||
if( !choke || ( !net_chokeloopback->value && NET_IsLocalAddress( chan->remote_address ) ))
|
||||
{
|
||||
chan->cleartime = host.realtime;
|
||||
return true;
|
||||
@@ -1334,7 +1331,7 @@ void Netchan_UpdateProgress( netchan_t *chan )
|
||||
|
||||
if( host.downloadcount == 0 )
|
||||
{
|
||||
scr_download.value = -1.0f;
|
||||
scr_download->value = -1.0f;
|
||||
host.downloadfile[0] = '\0';
|
||||
}
|
||||
|
||||
@@ -1402,7 +1399,7 @@ void Netchan_UpdateProgress( netchan_t *chan )
|
||||
|
||||
}
|
||||
|
||||
scr_download.value = bestpercent;
|
||||
scr_download->value = bestpercent;
|
||||
#endif // XASH_DEDICATED
|
||||
}
|
||||
|
||||
@@ -1702,7 +1699,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
|
||||
chan->cleartime += ( MSG_GetNumBytesWritten( &send ) + UDP_HEADER_SIZE ) * fRate;
|
||||
|
||||
if( net_showpackets.value && net_showpackets.value != 2.0f )
|
||||
if( net_showpackets->value && net_showpackets->value != 2.0f )
|
||||
{
|
||||
Con_Printf( " %s --> sz=%i seq=%i ack=%i rel=%i tm=%f\n"
|
||||
, ns_strings[chan->sock]
|
||||
@@ -1772,7 +1769,7 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
sequence_ack &= ~BIT( 30 );
|
||||
sequence_ack &= ~BIT( 31 );
|
||||
|
||||
if( net_showpackets.value && net_showpackets.value != 3.0f )
|
||||
if( net_showpackets->value && net_showpackets->value != 3.0f )
|
||||
{
|
||||
Con_Printf( " %s <-- sz=%i seq=%i ack=%i rel=%i tm=%f\n"
|
||||
, ns_strings[chan->sock]
|
||||
@@ -1786,7 +1783,7 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
// discard stale or duplicated packets
|
||||
if( sequence <= (uint)chan->incoming_sequence )
|
||||
{
|
||||
if( net_showdrop.value )
|
||||
if( net_showdrop->value )
|
||||
{
|
||||
const char *adr = NET_AdrToString( chan->remote_address );
|
||||
|
||||
@@ -1799,7 +1796,7 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
|
||||
// dropped packets don't keep the message from being used
|
||||
net_drop = sequence - ( chan->incoming_sequence + 1 );
|
||||
if( net_drop > 0 && net_showdrop.value )
|
||||
if( net_drop > 0 && net_showdrop->value )
|
||||
Con_Printf( "%s:dropped %i packets at %i\n", NET_AdrToString( chan->remote_address ), net_drop, sequence );
|
||||
|
||||
// if the current outgoing reliable message has been acknowledged
|
||||
|
||||
@@ -315,28 +315,16 @@ static const delta_field_t ent_fields[] =
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DT_EVENT_T = 0,
|
||||
DT_MOVEVARS_T,
|
||||
DT_USERCMD_T,
|
||||
DT_CLIENTDATA_T,
|
||||
DT_WEAPONDATA_T,
|
||||
DT_ENTITY_STATE_T,
|
||||
DT_ENTITY_STATE_PLAYER_T,
|
||||
DT_CUSTOM_ENTITY_STATE_T,
|
||||
};
|
||||
|
||||
static delta_info_t dt_info[] =
|
||||
{
|
||||
[DT_EVENT_T] = { "event_t", ev_fields, NUM_FIELDS( ev_fields ) },
|
||||
[DT_MOVEVARS_T] = { "movevars_t", pm_fields, NUM_FIELDS( pm_fields ) },
|
||||
[DT_USERCMD_T] = { "usercmd_t", cmd_fields, NUM_FIELDS( cmd_fields ) },
|
||||
[DT_CLIENTDATA_T] = { "clientdata_t", cd_fields, NUM_FIELDS( cd_fields ) },
|
||||
[DT_WEAPONDATA_T] = { "weapon_data_t", wd_fields, NUM_FIELDS( wd_fields ) },
|
||||
[DT_ENTITY_STATE_T] = { "entity_state_t", ent_fields, NUM_FIELDS( ent_fields ) },
|
||||
[DT_ENTITY_STATE_PLAYER_T] = { "entity_state_player_t", ent_fields, NUM_FIELDS( ent_fields ) },
|
||||
[DT_CUSTOM_ENTITY_STATE_T] = { "custom_entity_state_t", ent_fields, NUM_FIELDS( ent_fields ) },
|
||||
{ "event_t", ev_fields, NUM_FIELDS( ev_fields ) },
|
||||
{ "movevars_t", pm_fields, NUM_FIELDS( pm_fields ) },
|
||||
{ "usercmd_t", cmd_fields, NUM_FIELDS( cmd_fields ) },
|
||||
{ "clientdata_t", cd_fields, NUM_FIELDS( cd_fields ) },
|
||||
{ "weapon_data_t", wd_fields, NUM_FIELDS( wd_fields ) },
|
||||
{ "entity_state_t", ent_fields, NUM_FIELDS( ent_fields ) },
|
||||
{ "entity_state_player_t", ent_fields, NUM_FIELDS( ent_fields ) },
|
||||
{ "custom_entity_state_t", ent_fields, NUM_FIELDS( ent_fields ) },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
@@ -359,13 +347,16 @@ static delta_info_t *Delta_FindStruct( const char *name )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int Delta_NumTables( void )
|
||||
int Delta_NumTables( void )
|
||||
{
|
||||
return NUM_FIELDS( dt_info );
|
||||
}
|
||||
|
||||
static delta_info_t *Delta_FindStructByIndex( int index )
|
||||
delta_info_t *Delta_FindStructByIndex( int index )
|
||||
{
|
||||
if( index < 0 || index >= NUM_FIELDS( dt_info ))
|
||||
return NULL;
|
||||
|
||||
return &dt_info[index];
|
||||
}
|
||||
|
||||
@@ -444,12 +435,17 @@ static int Delta_IndexForFieldInfo( const delta_field_t *pInfo, const char *fiel
|
||||
return -1;
|
||||
}
|
||||
|
||||
static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags, int bits, float mul, float post_mul )
|
||||
static qboolean Delta_AddField( const char *pStructName, const char *pName, int flags, int bits, float mul, float post_mul )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
delta_field_t *pFieldInfo;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
|
||||
// get the delta struct
|
||||
dt = Delta_FindStruct( pStructName );
|
||||
Assert( dt != NULL );
|
||||
|
||||
// check for coexisting field
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
@@ -468,13 +464,13 @@ static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags,
|
||||
pFieldInfo = Delta_FindFieldInfo( dt->pInfo, pName );
|
||||
if( !pFieldInfo )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "Delta_Add: couldn't find description for %s->%s\n", dt->pName, pName );
|
||||
Con_DPrintf( S_ERROR "Delta_Add: couldn't find description for %s->%s\n", pStructName, pName );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( dt->numFields + 1 > dt->maxFields )
|
||||
{
|
||||
Con_DPrintf( S_WARN "Delta_Add: can't add %s->%s encoder list is full\n", dt->pName, pName );
|
||||
Con_DPrintf( S_WARN "Delta_Add: can't add %s->%s encoder list is full\n", pStructName, pName );
|
||||
return false; // too many fields specified (duplicated ?)
|
||||
}
|
||||
|
||||
@@ -495,7 +491,7 @@ static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pField )
|
||||
void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pField )
|
||||
{
|
||||
int nameIndex;
|
||||
delta_info_t *dt;
|
||||
@@ -576,7 +572,7 @@ void Delta_ParseTableField( sizebuf_t *msg )
|
||||
Delta_Shutdown();
|
||||
|
||||
// add field to table
|
||||
Delta_AddField( dt, pName, flags, bits, mul, post_mul );
|
||||
Delta_AddField( dt->pName, pName, flags, bits, mul, post_mul );
|
||||
}
|
||||
|
||||
static qboolean Delta_ParseField( char **delta_script, const delta_field_t *pInfo, delta_t *pField, qboolean bPost )
|
||||
@@ -824,43 +820,43 @@ void Delta_Init( void )
|
||||
Delta_InitFields (); // initialize fields
|
||||
delta_init = true;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
dt = Delta_FindStruct( "movevars_t" );
|
||||
|
||||
Assert( dt != NULL );
|
||||
if( dt->bInitialized ) return; // "movevars_t" already specified by user
|
||||
|
||||
// create movevars_t delta internal
|
||||
Delta_AddField( dt, "gravity", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "stopspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "maxspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "spectatormaxspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "accelerate", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "airaccelerate", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "wateraccelerate", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "friction", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "edgefriction", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "waterfriction", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "bounce", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "stepsize", DT_FLOAT|DT_SIGNED, 16, 16.0f, 1.0f );
|
||||
Delta_AddField( dt, "maxvelocity", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "gravity", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "stopspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "maxspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "spectatormaxspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "accelerate", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "airaccelerate", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "wateraccelerate", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "friction", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "edgefriction", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "waterfriction", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "bounce", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "stepsize", DT_FLOAT|DT_SIGNED, 16, 16.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "maxvelocity", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
|
||||
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
|
||||
Delta_AddField( dt, "zmax", DT_FLOAT|DT_SIGNED, 18, 1.0f, 1.0f );
|
||||
else Delta_AddField( dt, "zmax", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "zmax", DT_FLOAT|DT_SIGNED, 18, 1.0f, 1.0f );
|
||||
else Delta_AddField( "movevars_t", "zmax", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
|
||||
|
||||
Delta_AddField( dt, "waveHeight", DT_FLOAT|DT_SIGNED, 16, 16.0f, 1.0f );
|
||||
Delta_AddField( dt, "skyName", DT_STRING, 1, 1.0f, 1.0f );
|
||||
Delta_AddField( dt, "footsteps", DT_INTEGER, 1, 1.0f, 1.0f );
|
||||
Delta_AddField( dt, "rollangle", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( dt, "rollspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( dt, "skycolor_r", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f ); // 0 - 264
|
||||
Delta_AddField( dt, "skycolor_g", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
|
||||
Delta_AddField( dt, "skycolor_b", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
|
||||
Delta_AddField( dt, "skyvec_x", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f ); // 0 - 1
|
||||
Delta_AddField( dt, "skyvec_y", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( dt, "skyvec_z", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( dt, "wateralpha", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( dt, "fog_settings", DT_INTEGER, 32, 1.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "waveHeight", DT_FLOAT|DT_SIGNED, 16, 16.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "skyName", DT_STRING, 1, 1.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "footsteps", DT_INTEGER, 1, 1.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "rollangle", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "rollspeed", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "skycolor_r", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f ); // 0 - 264
|
||||
Delta_AddField( "movevars_t", "skycolor_g", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "skycolor_b", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "skyvec_x", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f ); // 0 - 1
|
||||
Delta_AddField( "movevars_t", "skyvec_y", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "skyvec_z", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "wateralpha", DT_FLOAT|DT_SIGNED, 16, 32.0f, 1.0f );
|
||||
Delta_AddField( "movevars_t", "fog_settings", DT_INTEGER, 32, 1.0f, 1.0f );
|
||||
dt->numFields = NUM_FIELDS( pm_fields ) - 4;
|
||||
|
||||
// now done
|
||||
@@ -918,7 +914,7 @@ Delta_ClampIntegerField
|
||||
prevent data to out of range
|
||||
=====================
|
||||
*/
|
||||
static int Delta_ClampIntegerField( delta_t *pField, int iValue, int signbit, int numbits )
|
||||
static int Delta_ClampIntegerField( delta_t *pField, int iValue, qboolean bSigned, int numbits )
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if( numbits < 32 && abs( iValue ) >= (uint)BIT( numbits ))
|
||||
@@ -926,13 +922,10 @@ static int Delta_ClampIntegerField( delta_t *pField, int iValue, int signbit, in
|
||||
#endif
|
||||
if( numbits < 32 )
|
||||
{
|
||||
int signbits = numbits - signbit;
|
||||
int signbits = bSigned ? ( numbits - 1 ) : numbits;
|
||||
int maxnum = BIT( signbits ) - 1;
|
||||
|
||||
if( iValue > maxnum )
|
||||
iValue = maxnum;
|
||||
else if( signbit && iValue < -maxnum - 1 )
|
||||
iValue = -maxnum - 1;
|
||||
int minnum = bSigned ? ( -maxnum - 1 ) : 0;
|
||||
iValue = bound( minnum, iValue, maxnum );
|
||||
}
|
||||
|
||||
return iValue; // clamped;
|
||||
@@ -948,7 +941,7 @@ assume from and to is valid
|
||||
*/
|
||||
static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, double timebase )
|
||||
{
|
||||
int signbit = ( pField->flags & DT_SIGNED ) ? 1 : 0;
|
||||
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
|
||||
float val_a, val_b;
|
||||
int fromF, toF;
|
||||
|
||||
@@ -963,67 +956,65 @@ static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, doubl
|
||||
|
||||
if( pField->flags & DT_BYTE )
|
||||
{
|
||||
if( signbit )
|
||||
if( pField->flags & DT_SIGNED )
|
||||
{
|
||||
fromF = *(int8_t *)((int8_t *)from + pField->offset );
|
||||
toF = *(int8_t *)((int8_t *)to + pField->offset );
|
||||
fromF = *(signed char *)((byte *)from + pField->offset );
|
||||
toF = *(signed char *)((byte *)to + pField->offset );
|
||||
}
|
||||
else
|
||||
{
|
||||
fromF = *(uint8_t *)((int8_t *)from + pField->offset );
|
||||
toF = *(uint8_t *)((int8_t *)to + pField->offset );
|
||||
fromF = *(byte *)((byte *)from + pField->offset );
|
||||
toF = *(byte *)((byte *)to + pField->offset );
|
||||
}
|
||||
|
||||
fromF = Delta_ClampIntegerField( pField, fromF, signbit, pField->bits );
|
||||
toF = Delta_ClampIntegerField( pField, toF, signbit, pField->bits );
|
||||
fromF = Delta_ClampIntegerField( pField, fromF, bSigned, pField->bits );
|
||||
toF = Delta_ClampIntegerField( pField, toF, bSigned, pField->bits );
|
||||
|
||||
if( !Q_equal(pField->multiplier, 1.0f ))
|
||||
if( !Q_equal(pField->multiplier, 1.0) )
|
||||
fromF *= pField->multiplier;
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0f ))
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
toF *= pField->multiplier;
|
||||
}
|
||||
else if( pField->flags & DT_SHORT )
|
||||
{
|
||||
if( signbit )
|
||||
if( pField->flags & DT_SIGNED )
|
||||
{
|
||||
fromF = *(int16_t *)((int8_t *)from + pField->offset );
|
||||
toF = *(int16_t *)((int8_t *)to + pField->offset );
|
||||
fromF = *(short *)((byte *)from + pField->offset );
|
||||
toF = *(short *)((byte *)to + pField->offset );
|
||||
}
|
||||
else
|
||||
{
|
||||
fromF = *(uint16_t *)((int8_t *)from + pField->offset );
|
||||
toF = *(uint16_t *)((int8_t *)to + pField->offset );
|
||||
fromF = *(word *)((byte *)from + pField->offset );
|
||||
toF = *(word *)((byte *)to + pField->offset );
|
||||
}
|
||||
|
||||
fromF = Delta_ClampIntegerField( pField, fromF, signbit, pField->bits );
|
||||
toF = Delta_ClampIntegerField( pField, toF, signbit, pField->bits );
|
||||
fromF = Delta_ClampIntegerField( pField, fromF, bSigned, pField->bits );
|
||||
toF = Delta_ClampIntegerField( pField, toF, bSigned, pField->bits );
|
||||
|
||||
if( !Q_equal(pField->multiplier, 1.0f ))
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
fromF *= pField->multiplier;
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0f ))
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
toF *= pField->multiplier;
|
||||
}
|
||||
else if( pField->flags & DT_INTEGER )
|
||||
{
|
||||
if( signbit )
|
||||
if( pField->flags & DT_SIGNED )
|
||||
{
|
||||
fromF = *(int32_t *)((int8_t *)from + pField->offset );
|
||||
toF = *(int32_t *)((int8_t *)to + pField->offset );
|
||||
fromF = *(int *)((byte *)from + pField->offset );
|
||||
toF = *(int *)((byte *)to + pField->offset );
|
||||
}
|
||||
else
|
||||
{
|
||||
fromF = *(uint32_t *)((int8_t *)from + pField->offset );
|
||||
toF = *(uint32_t *)((int8_t *)to + pField->offset );
|
||||
fromF = *(uint *)((byte *)from + pField->offset );
|
||||
toF = *(uint *)((byte *)to + pField->offset );
|
||||
}
|
||||
fromF = Delta_ClampIntegerField( pField, fromF, signbit, pField->bits );
|
||||
toF = Delta_ClampIntegerField( pField, toF, signbit, pField->bits );
|
||||
|
||||
if( !Q_equal(pField->multiplier, 1.0f ))
|
||||
fromF = Delta_ClampIntegerField( pField, fromF, bSigned, pField->bits );
|
||||
toF = Delta_ClampIntegerField( pField, toF, bSigned, pField->bits );
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
fromF *= pField->multiplier;
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0f ))
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
toF *= pField->multiplier;
|
||||
}
|
||||
else if( pField->flags & ( DT_ANGLE|DT_FLOAT ))
|
||||
@@ -1034,8 +1025,8 @@ static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, doubl
|
||||
}
|
||||
else if( pField->flags & DT_TIMEWINDOW_8 )
|
||||
{
|
||||
val_a = Q_rint((*(float *)((byte *)from + pField->offset )) * 100.0f );
|
||||
val_b = Q_rint((*(float *)((byte *)to + pField->offset )) * 100.0f );
|
||||
val_a = Q_rint((*(float *)((byte *)from + pField->offset )) * 100.0 );
|
||||
val_b = Q_rint((*(float *)((byte *)to + pField->offset )) * 100.0 );
|
||||
val_a -= Q_rint(timebase * 100.0);
|
||||
val_b -= Q_rint(timebase * 100.0);
|
||||
fromF = FloatAsInt( val_a );
|
||||
@@ -1046,7 +1037,7 @@ static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, doubl
|
||||
val_a = (*(float *)((byte *)from + pField->offset ));
|
||||
val_b = (*(float *)((byte *)to + pField->offset ));
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0f ))
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
{
|
||||
val_a *= pField->multiplier;
|
||||
val_b *= pField->multiplier;
|
||||
@@ -1072,7 +1063,7 @@ static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, doubl
|
||||
toF = Q_strcmp( s1, s2 );
|
||||
}
|
||||
|
||||
return fromF == toF;
|
||||
return ( fromF == toF ) ? true : false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1087,6 +1078,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
int i, countBits;
|
||||
int numChanges = 0;
|
||||
|
||||
countBits = MAX_ENTITY_BITS + 2;
|
||||
|
||||
@@ -1097,10 +1089,10 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
||||
}
|
||||
|
||||
if( FBitSet( to->entityType, ENTITY_BEAM ))
|
||||
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
||||
dt = Delta_FindStruct( "custom_entity_state_t" );
|
||||
else if( player )
|
||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_PLAYER_T );
|
||||
else dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
||||
dt = Delta_FindStruct( "entity_state_player_t" );
|
||||
else dt = Delta_FindStruct( "entity_state_t" );
|
||||
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
@@ -1120,7 +1112,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
||||
|
||||
if( !Delta_CompareField( pField, from, to, timebase ))
|
||||
{
|
||||
// strings are handled differently
|
||||
// strings are handled difference
|
||||
if( FBitSet( pField->flags, DT_STRING ))
|
||||
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
|
||||
else countBits += pField->bits;
|
||||
@@ -1141,7 +1133,7 @@ assume from and to is valid
|
||||
*/
|
||||
static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase )
|
||||
{
|
||||
int signbit = FBitSet( pField->flags, DT_SIGNED ) ? 1 : 0;
|
||||
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
|
||||
float flValue, flAngle;
|
||||
uint iValue;
|
||||
const char *pStr;
|
||||
@@ -1156,49 +1148,49 @@ static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, v
|
||||
|
||||
if( pField->flags & DT_BYTE )
|
||||
{
|
||||
if( signbit )
|
||||
if( bSigned )
|
||||
iValue = *(int8_t *)((int8_t *)to + pField->offset );
|
||||
else
|
||||
iValue = *(uint8_t *)((int8_t *)to + pField->offset );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, signbit, pField->bits );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
iValue *= pField->multiplier;
|
||||
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, signbit );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
|
||||
}
|
||||
else if( pField->flags & DT_SHORT )
|
||||
{
|
||||
if( signbit )
|
||||
if( bSigned )
|
||||
iValue = *(int16_t *)((int8_t *)to + pField->offset );
|
||||
else
|
||||
iValue = *(uint16_t *)((int8_t *)to + pField->offset );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, signbit, pField->bits );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
iValue *= pField->multiplier;
|
||||
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, signbit );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
|
||||
}
|
||||
else if( pField->flags & DT_INTEGER )
|
||||
{
|
||||
if( signbit )
|
||||
if( bSigned )
|
||||
iValue = *(int32_t *)((int8_t *)to + pField->offset );
|
||||
else
|
||||
iValue = *(uint32_t *)((int8_t *)to + pField->offset );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, signbit, pField->bits );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
|
||||
|
||||
if( !Q_equal( pField->multiplier, 1.0 ) )
|
||||
iValue *= pField->multiplier;
|
||||
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, signbit );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
|
||||
}
|
||||
else if( pField->flags & DT_FLOAT )
|
||||
{
|
||||
flValue = *(float *)((byte *)to + pField->offset );
|
||||
iValue = (int)((double)flValue * pField->multiplier);
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, signbit, pField->bits );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, signbit );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
|
||||
}
|
||||
else if( pField->flags & DT_ANGLE )
|
||||
{
|
||||
@@ -1210,19 +1202,19 @@ static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, v
|
||||
}
|
||||
else if( pField->flags & DT_TIMEWINDOW_8 )
|
||||
{
|
||||
signbit = 1; // timewindow is always signed
|
||||
bSigned = true; // timewindow is always signed
|
||||
flValue = *(float *)((byte *)to + pField->offset );
|
||||
iValue = (int)Q_rint( timebase * 100.0 ) - (int)Q_rint( flValue * 100.0 );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, signbit, pField->bits );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, signbit );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
|
||||
}
|
||||
else if( pField->flags & DT_TIMEWINDOW_BIG )
|
||||
{
|
||||
signbit = 1; // timewindow is always signed
|
||||
bSigned = true; // timewindow is always signed
|
||||
flValue = *(float *)((byte *)to + pField->offset );
|
||||
iValue = (int)Q_rint( timebase * pField->multiplier ) - (int)Q_rint( flValue * pField->multiplier );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, signbit, pField->bits );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, signbit );
|
||||
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
|
||||
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
|
||||
}
|
||||
else if( pField->flags & DT_STRING )
|
||||
{
|
||||
@@ -1404,7 +1396,7 @@ void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_USERCMD_T );
|
||||
dt = Delta_FindStruct( "usercmd_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1431,7 +1423,7 @@ void MSG_ReadDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_USERCMD_T );
|
||||
dt = Delta_FindStruct( "usercmd_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1466,7 +1458,7 @@ void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_EVENT_T );
|
||||
dt = Delta_FindStruct( "event_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1493,7 +1485,7 @@ void MSG_ReadDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_EVENT_T );
|
||||
dt = Delta_FindStruct( "event_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1522,7 +1514,7 @@ qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *t
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
dt = Delta_FindStruct( "movevars_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1557,7 +1549,7 @@ void MSG_ReadDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to )
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
dt = Delta_FindStruct( "movevars_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1594,7 +1586,7 @@ void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to,
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_CLIENTDATA_T );
|
||||
dt = Delta_FindStruct( "clientdata_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1635,7 +1627,7 @@ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, d
|
||||
int i;
|
||||
qboolean noChanges;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_CLIENTDATA_T );
|
||||
dt = Delta_FindStruct( "clientdata_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1675,7 +1667,7 @@ void MSG_WriteWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_WEAPONDATA_T );
|
||||
dt = Delta_FindStruct( "weapon_data_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1713,7 +1705,7 @@ void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to,
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_WEAPONDATA_T );
|
||||
dt = Delta_FindStruct( "weapon_data_t" );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
@@ -1796,15 +1788,15 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *
|
||||
|
||||
if( FBitSet( to->entityType, ENTITY_BEAM ))
|
||||
{
|
||||
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
||||
dt = Delta_FindStruct( "custom_entity_state_t" );
|
||||
}
|
||||
else if( delta_type == DELTA_PLAYER )
|
||||
{
|
||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_PLAYER_T );
|
||||
dt = Delta_FindStruct( "entity_state_player_t" );
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
||||
dt = Delta_FindStruct( "entity_state_t" );
|
||||
}
|
||||
|
||||
Assert( dt && dt->bInitialized );
|
||||
@@ -1914,15 +1906,15 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
||||
|
||||
if( cls.legacymode ? ( to->entityType == ENTITY_BEAM ) : FBitSet( to->entityType, ENTITY_BEAM ))
|
||||
{
|
||||
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
||||
dt = Delta_FindStruct( "custom_entity_state_t" );
|
||||
}
|
||||
else if( delta_type == DELTA_PLAYER )
|
||||
{
|
||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_PLAYER_T );
|
||||
dt = Delta_FindStruct( "entity_state_player_t" );
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
||||
dt = Delta_FindStruct( "entity_state_t" );
|
||||
}
|
||||
|
||||
Assert( dt && dt->bInitialized );
|
||||
@@ -1940,27 +1932,6 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Delta_WriteDescriptionToClient
|
||||
|
||||
send delta communication encoding
|
||||
==================
|
||||
*/
|
||||
void Delta_WriteDescriptionToClient( sizebuf_t *msg )
|
||||
{
|
||||
int tableIndex;
|
||||
int fieldIndex;
|
||||
|
||||
for( tableIndex = 0; tableIndex < Delta_NumTables(); tableIndex++ )
|
||||
{
|
||||
delta_info_t *dt = Delta_FindStructByIndex( tableIndex );
|
||||
|
||||
for( fieldIndex = 0; fieldIndex < dt->numFields; fieldIndex++ )
|
||||
Delta_WriteTableField( msg, tableIndex, &dt->pFields[fieldIndex] );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ typedef struct
|
||||
void Delta_Init( void );
|
||||
void Delta_InitClient( void );
|
||||
void Delta_Shutdown( void );
|
||||
int Delta_NumTables( void );
|
||||
delta_info_t *Delta_FindStructByIndex( int index );
|
||||
void Delta_AddEncoder( char *name, pfnDeltaEncode encodeFunc );
|
||||
int Delta_FindField( delta_t *pFields, const char *fieldname );
|
||||
void Delta_SetField( delta_t *pFields, const char *fieldname );
|
||||
@@ -85,7 +87,7 @@ void Delta_SetFieldByIndex( delta_t *pFields, int fieldNumber );
|
||||
void Delta_UnsetFieldByIndex( delta_t *pFields, int fieldNumber );
|
||||
|
||||
// send table over network
|
||||
void Delta_WriteDescriptionToClient( sizebuf_t *msg );
|
||||
void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pField );
|
||||
void Delta_ParseTableField( sizebuf_t *msg );
|
||||
|
||||
|
||||
|
||||
@@ -108,24 +108,23 @@ typedef struct
|
||||
} net_state_t;
|
||||
|
||||
static net_state_t net;
|
||||
static CVAR_DEFINE_AUTO( net_address, "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "contain local address of current client" );
|
||||
static CVAR_DEFINE( net_ipname, "ip", "localhost", FCVAR_PRIVILEGED, "network ip address" );
|
||||
static CVAR_DEFINE( net_iphostport, "ip_hostport", "0", FCVAR_READ_ONLY, "network ip host port" );
|
||||
static CVAR_DEFINE( net_hostport, "hostport", "0", FCVAR_READ_ONLY, "network default host port" );
|
||||
static CVAR_DEFINE( net_ipclientport, "ip_clientport", "0", FCVAR_READ_ONLY, "network ip client port" );
|
||||
static CVAR_DEFINE( net_clientport, "clientport", "0", FCVAR_READ_ONLY, "network default client port" );
|
||||
static CVAR_DEFINE( net_fakelag, "fakelag", "0", FCVAR_PRIVILEGED, "lag all incoming network data (including loopback) by xxx ms." );
|
||||
static CVAR_DEFINE( net_fakeloss, "fakeloss", "0", FCVAR_PRIVILEGED, "act like we dropped the packet this % of the time." );
|
||||
CVAR_DEFINE( net_clockwindow, "clockwindow", "0.5", FCVAR_PRIVILEGED, "timewindow to execute client moves" );
|
||||
|
||||
static convar_t *net_ipname;
|
||||
static convar_t *net_hostport;
|
||||
static convar_t *net_iphostport;
|
||||
static convar_t *net_clientport;
|
||||
static convar_t *net_ipclientport;
|
||||
static convar_t *net_fakelag;
|
||||
static convar_t *net_fakeloss;
|
||||
static convar_t *net_address;
|
||||
convar_t *net_clockwindow;
|
||||
netadr_t net_local;
|
||||
netadr_t net6_local;
|
||||
|
||||
// cvars equivalents for IPv6
|
||||
static CVAR_DEFINE( net_ip6name, "ip6", "localhost", FCVAR_PRIVILEGED, "network ip6 address" );
|
||||
static CVAR_DEFINE( net_ip6hostport, "ip6_hostport", "0", FCVAR_READ_ONLY, "network ip6 host port" );
|
||||
static CVAR_DEFINE( net_ip6clientport, "ip6_clientport", "0", FCVAR_READ_ONLY, "network ip6 client port" );
|
||||
static CVAR_DEFINE_AUTO( net6_address, "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "contain local IPv6 address of current client" );
|
||||
static convar_t *net_ip6name;
|
||||
static convar_t *net_ip6hostport;
|
||||
static convar_t *net_ip6clientport;
|
||||
static convar_t *net6_address;
|
||||
|
||||
/*
|
||||
====================
|
||||
@@ -274,8 +273,8 @@ static void NET_NetadrToSockadr( netadr_t *a, struct sockaddr_storage *s )
|
||||
else if( a->type == NA_IP )
|
||||
{
|
||||
((struct sockaddr_in *)s)->sin_family = AF_INET;
|
||||
((struct sockaddr_in *)s)->sin_addr.s_addr = *(uint32_t *)&a->ip;
|
||||
((struct sockaddr_in *)s)->sin_port = a->port;
|
||||
((struct sockaddr_in *)s)->sin_addr.s_addr = a->ip4;
|
||||
}
|
||||
else if( a->type6 == NA_IP6 )
|
||||
{
|
||||
@@ -314,7 +313,7 @@ static void NET_SockadrToNetadr( const struct sockaddr_storage *s, netadr_t *a )
|
||||
if( s->ss_family == AF_INET )
|
||||
{
|
||||
a->type = NA_IP;
|
||||
a->ip4 = ((struct sockaddr_in *)s)->sin_addr.s_addr;
|
||||
*(int *)&a->ip = ((struct sockaddr_in *)s)->sin_addr.s_addr;
|
||||
a->port = ((struct sockaddr_in *)s)->sin_port;
|
||||
}
|
||||
else if( s->ss_family == AF_INET6 )
|
||||
@@ -444,7 +443,6 @@ static void NET_InitializeCriticalSections( void )
|
||||
void NET_ResolveThread( void )
|
||||
{
|
||||
struct sockaddr_storage addr;
|
||||
qboolean res;
|
||||
|
||||
RESOLVE_DBG( "[resolve thread] starting resolve for " );
|
||||
RESOLVE_DBG( nsthread.hostname );
|
||||
@@ -454,14 +452,13 @@ void NET_ResolveThread( void )
|
||||
RESOLVE_DBG( " with gethostbyname\n" );
|
||||
#endif
|
||||
|
||||
if(( res = NET_GetHostByName( nsthread.hostname, nsthread.family, &addr )))
|
||||
if( NET_GetHostByName( nsthread.hostname, nsthread.family, &addr ))
|
||||
RESOLVE_DBG( "[resolve thread] success\n" );
|
||||
else
|
||||
RESOLVE_DBG( "[resolve thread] failed\n" );
|
||||
mutex_lock( &nsthread.mutexres );
|
||||
nsthread.addr = addr;
|
||||
nsthread.busy = false;
|
||||
nsthread.result = res ? NET_EAI_OK : NET_EAI_NONAME;
|
||||
RESOLVE_DBG( "[resolve thread] returning result\n" );
|
||||
mutex_unlock( &nsthread.mutexres );
|
||||
RESOLVE_DBG( "[resolve thread] exiting thread\n" );
|
||||
@@ -546,7 +543,6 @@ static net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_stor
|
||||
memset( &nsthread.addr, 0, sizeof( nsthread.addr ));
|
||||
|
||||
detach_thread( nsthread.thread );
|
||||
asyncfailed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -726,7 +722,7 @@ const char *NET_AdrToString( const netadr_t a )
|
||||
|
||||
if( a.type == NA_LOOPBACK )
|
||||
return "loopback";
|
||||
if( a.type6 == NA_IP6 || a.type6 == NA_MULTICAST_IP6 )
|
||||
if( a.type6 == NA_IP6 )
|
||||
{
|
||||
uint8_t ip6[16];
|
||||
|
||||
@@ -753,7 +749,7 @@ const char *NET_BaseAdrToString( const netadr_t a )
|
||||
|
||||
if( a.type == NA_LOOPBACK )
|
||||
return "loopback";
|
||||
if( a.type6 == NA_IP6 || a.type6 == NA_MULTICAST_IP6 )
|
||||
if( a.type6 == NA_IP6 )
|
||||
{
|
||||
uint8_t ip6[16];
|
||||
|
||||
@@ -1069,7 +1065,7 @@ net_gai_state_t NET_StringToAdrNB( const char *string, netadr_t *adr )
|
||||
if( !Q_stricmp( string, "localhost" ) || !Q_stricmp( string, "loopback" ))
|
||||
{
|
||||
adr->type = NA_LOOPBACK;
|
||||
return NET_EAI_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
res = NET_StringToSockaddr( string, &s, true, AF_UNSPEC );
|
||||
@@ -1247,11 +1243,11 @@ static void NET_AdjustLag( void )
|
||||
dt = bound( 0.0, dt, 0.1 );
|
||||
lasttime = host.realtime;
|
||||
|
||||
if( host_developer.value || !net_fakelag.value )
|
||||
if( host_developer.value || !net_fakelag->value )
|
||||
{
|
||||
if( net_fakelag.value != net.fakelag )
|
||||
if( net_fakelag->value != net.fakelag )
|
||||
{
|
||||
diff = net_fakelag.value - net.fakelag;
|
||||
diff = net_fakelag->value - net.fakelag;
|
||||
converge = dt * 200.0f;
|
||||
if( fabs( diff ) < converge )
|
||||
converge = fabs( diff );
|
||||
@@ -1292,14 +1288,14 @@ static qboolean NET_LagPacket( qboolean newdata, netsrc_t sock, netadr_t *from,
|
||||
|
||||
if( newdata )
|
||||
{
|
||||
if( net_fakeloss.value != 0.0f )
|
||||
if( net_fakeloss->value != 0.0f )
|
||||
{
|
||||
if( host_developer.value )
|
||||
{
|
||||
net.losscount[sock]++;
|
||||
if( net_fakeloss.value <= 0.0f )
|
||||
if( net_fakeloss->value <= 0.0f )
|
||||
{
|
||||
ninterval = fabs( net_fakeloss.value );
|
||||
ninterval = fabs( net_fakeloss->value );
|
||||
if( ninterval < 2 ) ninterval = 2;
|
||||
|
||||
if(( net.losscount[sock] % ninterval ) == 0 )
|
||||
@@ -1307,7 +1303,7 @@ static qboolean NET_LagPacket( qboolean newdata, netsrc_t sock, netadr_t *from,
|
||||
}
|
||||
else
|
||||
{
|
||||
if( COM_RandomLong( 0, 100 ) <= net_fakeloss.value )
|
||||
if( COM_RandomLong( 0, 100 ) <= net_fakeloss->value )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1396,7 +1392,7 @@ qboolean NET_GetLong( byte *pData, int size, size_t *outSize, int splitsize )
|
||||
for( i = 0; i < NET_MAX_FRAGMENTS; i++ )
|
||||
net.split_flags[i] = -1;
|
||||
|
||||
if( net_showpackets.value == 4.0f )
|
||||
if( net_showpackets && net_showpackets->value == 4.0f )
|
||||
Con_Printf( "<-- Split packet restart %i count %i seq\n", net.split.split_count, sequence_number );
|
||||
}
|
||||
|
||||
@@ -1410,7 +1406,7 @@ qboolean NET_GetLong( byte *pData, int size, size_t *outSize, int splitsize )
|
||||
net.split.split_count--;
|
||||
net.split_flags[packet_number] = sequence_number;
|
||||
|
||||
if( net_showpackets.value == 4.0f )
|
||||
if( net_showpackets && net_showpackets->value == 4.0f )
|
||||
Con_Printf( "<-- Split packet %i of %i, %i bytes %i seq\n", packet_number + 1, packet_count, size, sequence_number );
|
||||
}
|
||||
else
|
||||
@@ -1581,7 +1577,7 @@ int NET_SendLong( netsrc_t sock, int net_socket, const char *buf, size_t len, in
|
||||
pPacket->packet_id = (packet_number << 8) + packet_count;
|
||||
memcpy( packet + sizeof( SPLITPACKET ), buf + ( packet_number * body_size ), size );
|
||||
|
||||
if( net_showpackets.value == 3.0f )
|
||||
if( net_showpackets && net_showpackets->value == 3.0f )
|
||||
{
|
||||
netadr_t adr;
|
||||
|
||||
@@ -1817,14 +1813,14 @@ static void NET_OpenIP( qboolean change_port, int *sockets, const char *net_ifac
|
||||
qboolean sv_nat = Cvar_VariableInteger("sv_nat");
|
||||
qboolean cl_nat = Cvar_VariableInteger("cl_nat");
|
||||
|
||||
if( change_port && ( FBitSet( net_hostport.flags, FCVAR_CHANGED ) || sv_nat ))
|
||||
if( change_port && ( FBitSet( net_hostport->flags, FCVAR_CHANGED ) || sv_nat ))
|
||||
{
|
||||
// reopen socket to set random port
|
||||
if( NET_IsSocketValid( sockets[NS_SERVER] ))
|
||||
closesocket( sockets[NS_SERVER] );
|
||||
|
||||
sockets[NS_SERVER] = INVALID_SOCKET;
|
||||
ClearBits( net_hostport.flags, FCVAR_CHANGED );
|
||||
ClearBits( net_hostport->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( !NET_IsSocketValid( sockets[NS_SERVER] ))
|
||||
@@ -1832,7 +1828,7 @@ static void NET_OpenIP( qboolean change_port, int *sockets, const char *net_ifac
|
||||
port = hostport;
|
||||
if( !port )
|
||||
{
|
||||
port = sv_nat ? PORT_ANY : net_hostport.value;
|
||||
port = sv_nat ? PORT_ANY : net_hostport->value;
|
||||
|
||||
if( !port )
|
||||
port = PORT_SERVER; // forcing to default
|
||||
@@ -1846,14 +1842,14 @@ static void NET_OpenIP( qboolean change_port, int *sockets, const char *net_ifac
|
||||
// dedicated servers don't need client ports
|
||||
if( Host_IsDedicated( )) return;
|
||||
|
||||
if( change_port && ( FBitSet( net_clientport.flags, FCVAR_CHANGED ) || cl_nat ))
|
||||
if( change_port && ( FBitSet( net_clientport->flags, FCVAR_CHANGED ) || cl_nat ))
|
||||
{
|
||||
// reopen socket to set random port
|
||||
if( NET_IsSocketValid( sockets[NS_CLIENT] ))
|
||||
closesocket( sockets[NS_CLIENT] );
|
||||
|
||||
sockets[NS_CLIENT] = INVALID_SOCKET;
|
||||
ClearBits( net_clientport.flags, FCVAR_CHANGED );
|
||||
ClearBits( net_clientport->flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( !NET_IsSocketValid( sockets[NS_CLIENT] ))
|
||||
@@ -1861,7 +1857,7 @@ static void NET_OpenIP( qboolean change_port, int *sockets, const char *net_ifac
|
||||
port = clientport;
|
||||
if( !port )
|
||||
{
|
||||
port = cl_nat ? PORT_ANY : net_clientport.value;
|
||||
port = cl_nat ? PORT_ANY : net_clientport->value;
|
||||
|
||||
if( !port )
|
||||
port = PORT_ANY; // forcing to default
|
||||
@@ -1869,7 +1865,7 @@ static void NET_OpenIP( qboolean change_port, int *sockets, const char *net_ifac
|
||||
sockets[NS_CLIENT] = NET_IPSocket( net_iface, port, family );
|
||||
|
||||
if( !NET_IsSocketValid( sockets[NS_CLIENT] ))
|
||||
sockets[NS_CLIENT] = NET_IPSocket( net_ipname.string, PORT_ANY, family );
|
||||
sockets[NS_CLIENT] = NET_IPSocket( net_ipname->string, PORT_ANY, family );
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -1905,8 +1901,8 @@ void NET_GetLocalAddress( void )
|
||||
if( net.allow_ip )
|
||||
{
|
||||
// If we have changed the ip var from the command line, use that instead.
|
||||
if( Q_stricmp( net_ipname.string, "localhost" ))
|
||||
Q_strncpy( buff, net_ipname.string, sizeof( buff ));
|
||||
if( Q_stricmp( net_ipname->string, "localhost" ))
|
||||
Q_strncpy( buff, net_ipname->string, sizeof( buff ));
|
||||
else Q_strncpy( buff, hostname, sizeof( buff ));
|
||||
|
||||
if( NET_StringToAdrEx( buff, &net_local, AF_INET ))
|
||||
@@ -1918,7 +1914,7 @@ void NET_GetLocalAddress( void )
|
||||
net_local.port = ((struct sockaddr_in *)&address)->sin_port;
|
||||
net_addr_string = NET_AdrToString( net_local );
|
||||
Con_Printf( "Server IPv4 address %s\n", net_addr_string );
|
||||
Cvar_FullSet( "net_address", net_addr_string, net_address.flags );
|
||||
Cvar_FullSet( "net_address", net_addr_string, net_address->flags );
|
||||
}
|
||||
else Con_DPrintf( S_ERROR "Could not get TCP/IPv4 address. Reason: %s\n", NET_ErrorString( ));
|
||||
}
|
||||
@@ -1928,8 +1924,8 @@ void NET_GetLocalAddress( void )
|
||||
if( net.allow_ip6 )
|
||||
{
|
||||
// If we have changed the ip var from the command line, use that instead.
|
||||
if( Q_stricmp( net_ip6name.string, "localhost" ))
|
||||
Q_strncpy( buff, net_ip6name.string, sizeof( buff ));
|
||||
if( Q_stricmp( net_ip6name->string, "localhost" ))
|
||||
Q_strncpy( buff, net_ip6name->string, sizeof( buff ));
|
||||
else Q_strncpy( buff, hostname, sizeof( buff ));
|
||||
|
||||
if( NET_StringToAdrEx( buff, &net6_local, AF_INET6 ))
|
||||
@@ -1941,7 +1937,7 @@ void NET_GetLocalAddress( void )
|
||||
net6_local.port = ((struct sockaddr_in6 *)&address)->sin6_port;
|
||||
net_addr_string = NET_AdrToString( net6_local );
|
||||
Con_Printf( "Server IPv6 address %s\n", net_addr_string );
|
||||
Cvar_FullSet( "net6_address", net_addr_string, net6_address.flags );
|
||||
Cvar_FullSet( "net6_address", net_addr_string, net6_address->flags );
|
||||
}
|
||||
else Con_DPrintf( S_ERROR "Could not get TCP/IPv6 address. Reason: %s\n", NET_ErrorString( ));
|
||||
}
|
||||
@@ -1973,10 +1969,10 @@ void NET_Config( qboolean multiplayer, qboolean changeport )
|
||||
{
|
||||
// open sockets
|
||||
if( net.allow_ip )
|
||||
NET_OpenIP( changeport, net.ip_sockets, net_ipname.string, net_iphostport.value, net_ipclientport.value, AF_INET );
|
||||
NET_OpenIP( changeport, net.ip_sockets, net_ipname->string, net_iphostport->value, net_ipclientport->value, AF_INET );
|
||||
|
||||
if( net.allow_ip6 )
|
||||
NET_OpenIP( changeport, net.ip6_sockets, net_ip6name.string, net_ip6hostport.value, net_ip6clientport.value, AF_INET6 );
|
||||
NET_OpenIP( changeport, net.ip6_sockets, net_ip6name->string, net_ip6hostport->value, net_ip6clientport->value, AF_INET6 );
|
||||
|
||||
// validate sockets for dedicated
|
||||
if( Host_IsDedicated( ))
|
||||
@@ -2104,23 +2100,21 @@ void NET_Init( void )
|
||||
|
||||
if( net.initialized ) return;
|
||||
|
||||
Cvar_RegisterVariable( &net_address );
|
||||
Cvar_RegisterVariable( &net_ipname );
|
||||
Cvar_RegisterVariable( &net_iphostport );
|
||||
Cvar_RegisterVariable( &net_hostport );
|
||||
Cvar_RegisterVariable( &net_ipclientport );
|
||||
Cvar_RegisterVariable( &net_clientport );
|
||||
Cvar_RegisterVariable( &net_fakelag );
|
||||
Cvar_RegisterVariable( &net_fakeloss );
|
||||
|
||||
Q_snprintf( cmd, sizeof( cmd ), "%i", PORT_SERVER );
|
||||
Cvar_FullSet( "hostport", cmd, FCVAR_READ_ONLY );
|
||||
net_clockwindow = Cvar_Get( "clockwindow", "0.5", FCVAR_PRIVILEGED, "timewindow to execute client moves" );
|
||||
net_address = Cvar_Get( "net_address", "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "contain local address of current client" );
|
||||
net_ipname = Cvar_Get( "ip", "localhost", FCVAR_PRIVILEGED, "network ip address" );
|
||||
net_iphostport = Cvar_Get( "ip_hostport", "0", FCVAR_READ_ONLY, "network ip host port" );
|
||||
net_hostport = Cvar_Getf( "hostport", FCVAR_READ_ONLY, "network default host port", "%i", PORT_SERVER );
|
||||
net_ipclientport = Cvar_Get( "ip_clientport", "0", FCVAR_READ_ONLY, "network ip client port" );
|
||||
net_clientport = Cvar_Getf( "clientport", FCVAR_READ_ONLY, "network default client port", "%i", PORT_CLIENT );
|
||||
net_fakelag = Cvar_Get( "fakelag", "0", FCVAR_PRIVILEGED, "lag all incoming network data (including loopback) by xxx ms." );
|
||||
net_fakeloss = Cvar_Get( "fakeloss", "0", FCVAR_PRIVILEGED, "act like we dropped the packet this % of the time." );
|
||||
|
||||
// cvar equivalents for IPv6
|
||||
Cvar_RegisterVariable( &net_ip6name );
|
||||
Cvar_RegisterVariable( &net_ip6hostport );
|
||||
Cvar_RegisterVariable( &net_ip6clientport );
|
||||
Cvar_RegisterVariable( &net6_address );
|
||||
net_ip6name = Cvar_Get( "ip6", "localhost", FCVAR_PRIVILEGED, "network ip6 address" );
|
||||
net_ip6hostport = Cvar_Get( "ip6_hostport", "0", FCVAR_READ_ONLY, "network ip6 host port" );
|
||||
net_ip6clientport = Cvar_Get( "ip6_clientport", "0", FCVAR_READ_ONLY, "network ip6 client port" );
|
||||
net6_address = Cvar_Get( "net6_address", "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "contain local IPv6 address of current client" );
|
||||
|
||||
// prepare some network data
|
||||
for( i = 0; i < NS_COUNT; i++ )
|
||||
@@ -2156,11 +2150,11 @@ void NET_Init( void )
|
||||
|
||||
// specify custom ip
|
||||
if( Sys_GetParmFromCmdLine( "-ip", cmd ))
|
||||
Cvar_FullSet( "ip", cmd, net_ipname.flags );
|
||||
Cvar_FullSet( "ip", cmd, net_ipname->flags );
|
||||
|
||||
// specify custom ip6
|
||||
if( Sys_GetParmFromCmdLine( "-ip6", cmd ))
|
||||
Cvar_FullSet( "ip6", cmd, net_ip6name.flags );
|
||||
Cvar_FullSet( "ip6", cmd, net_ip6name->flags );
|
||||
|
||||
// adjust clockwindow
|
||||
if( Sys_GetParmFromCmdLine( "-clockwindow", cmd ))
|
||||
@@ -2200,8 +2194,6 @@ HTTP downloader
|
||||
=================================================
|
||||
*/
|
||||
|
||||
#define MAX_HTTP_BUFFER_SIZE (BIT( 13 ))
|
||||
|
||||
typedef struct httpserver_s
|
||||
{
|
||||
char host[256];
|
||||
@@ -2242,7 +2234,7 @@ typedef struct httpfile_s
|
||||
qboolean process;
|
||||
|
||||
// query or response
|
||||
char buf[MAX_HTTP_BUFFER_SIZE+1];
|
||||
char buf[BUFSIZ+1];
|
||||
int header_size, query_length, bytes_sent;
|
||||
} httpfile_t;
|
||||
|
||||
@@ -2254,10 +2246,10 @@ static struct http_static_s
|
||||
} http;
|
||||
|
||||
|
||||
static CVAR_DEFINE_AUTO( http_useragent, "", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "User-Agent string" );
|
||||
static CVAR_DEFINE_AUTO( http_autoremove, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "remove broken files" );
|
||||
static CVAR_DEFINE_AUTO( http_timeout, "45", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "timeout for http downloader" );
|
||||
static CVAR_DEFINE_AUTO( http_maxconnections, "4", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "maximum http connection number" );
|
||||
static convar_t *http_useragent;
|
||||
static convar_t *http_autoremove;
|
||||
static convar_t *http_timeout;
|
||||
static convar_t *http_maxconnections;
|
||||
|
||||
/*
|
||||
========================
|
||||
@@ -2312,7 +2304,7 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error )
|
||||
}
|
||||
|
||||
// Called because there was no servers to download, free file now
|
||||
if( http_autoremove.value == 1 ) // remove broken file
|
||||
if( http_autoremove->value == 1 ) // remove broken file
|
||||
FS_Delete( incname );
|
||||
else // autoremove disabled, keep file
|
||||
Con_Printf( "cannot download %s from any server. "
|
||||
@@ -2387,18 +2379,18 @@ process incoming data
|
||||
*/
|
||||
static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
{
|
||||
char buf[sizeof( curfile->buf )];
|
||||
char buf[BUFSIZ+1];
|
||||
char *begin = 0;
|
||||
int res;
|
||||
|
||||
if( curfile->header_size >= sizeof( buf ))
|
||||
if( curfile->header_size >= BUFSIZ )
|
||||
{
|
||||
Con_Reportf( S_ERROR "Header too big, the size is %s\n", curfile->header_size );
|
||||
Con_Reportf( S_ERROR "Header to big\n");
|
||||
HTTP_FreeFile( curfile, true );
|
||||
return false;
|
||||
}
|
||||
|
||||
while( ( res = recv( curfile->socket, buf, sizeof( buf ) - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
|
||||
while( ( res = recv( curfile->socket, buf, BUFSIZ - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
|
||||
{
|
||||
curfile->blocktime = 0;
|
||||
|
||||
@@ -2411,7 +2403,7 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
if( begin ) // Got full header
|
||||
{
|
||||
int cutheadersize = begin - curfile->buf + 4; // after that begin of data
|
||||
char *content_length_line;
|
||||
char *length;
|
||||
|
||||
Con_Reportf( "HTTP: Got response!\n" );
|
||||
|
||||
@@ -2430,13 +2422,10 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
||||
}
|
||||
|
||||
// print size
|
||||
content_length_line = Q_stristr( curfile->buf, "Content-Length: " );
|
||||
if( content_length_line )
|
||||
length = Q_stristr( curfile->buf, "Content-Length: " );
|
||||
if( length )
|
||||
{
|
||||
int size;
|
||||
|
||||
content_length_line += sizeof( "Content-Length: " ) - 1;
|
||||
size = Q_atoi( content_length_line );
|
||||
int size = Q_atoi( length += 16 );
|
||||
|
||||
Con_Reportf( "HTTP: File size is %d\n", size );
|
||||
|
||||
@@ -2536,7 +2525,7 @@ void HTTP_Run( void )
|
||||
{
|
||||
char name[MAX_SYSPATH];
|
||||
|
||||
if( iActiveCount > http_maxconnections.value )
|
||||
if( iActiveCount > http_maxconnections->value )
|
||||
continue;
|
||||
|
||||
if( !curfile->server )
|
||||
@@ -2635,14 +2624,14 @@ void HTTP_Run( void )
|
||||
{
|
||||
string useragent;
|
||||
|
||||
if( !COM_CheckStringEmpty( http_useragent.string ) || !Q_strcmp( http_useragent.string, "xash3d" ))
|
||||
if( !COM_CheckStringEmpty( http_useragent->string ) || !Q_strcmp( http_useragent->string, "xash3d" ))
|
||||
{
|
||||
Q_snprintf( useragent, sizeof( useragent ), "%s/%s (%s-%s; build %d; %s)",
|
||||
XASH_ENGINE_NAME, XASH_VERSION, Q_buildos( ), Q_buildarch( ), Q_buildnum( ), Q_buildcommit( ));
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( useragent, http_useragent.string, sizeof( useragent ));
|
||||
Q_strncpy( useragent, http_useragent->string, sizeof( useragent ));
|
||||
}
|
||||
|
||||
curfile->query_length = Q_snprintf( curfile->buf, sizeof( curfile->buf ),
|
||||
@@ -2677,7 +2666,7 @@ void HTTP_Run( void )
|
||||
curfile->blocktime += host.frametime;
|
||||
wait = true;
|
||||
|
||||
if( curfile->blocktime > http_timeout.value )
|
||||
if( curfile->blocktime > http_timeout->value )
|
||||
{
|
||||
Con_Printf( S_ERROR "timeout on request send:\n%s\n", curfile->buf );
|
||||
HTTP_FreeFile( curfile, true );
|
||||
@@ -2719,7 +2708,7 @@ void HTTP_Run( void )
|
||||
else
|
||||
curfile->blocktime += host.frametime;
|
||||
|
||||
if( curfile->blocktime > http_timeout.value )
|
||||
if( curfile->blocktime > http_timeout->value )
|
||||
{
|
||||
Con_Printf( S_ERROR "timeout on receiving data!\n");
|
||||
HTTP_FreeFile( curfile, true );
|
||||
@@ -2878,10 +2867,6 @@ static void HTTP_AddCustomServer_f( void )
|
||||
{
|
||||
HTTP_AddCustomServer( Cmd_Argv( 1 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( S_USAGE "http_addcustomserver <url>\n" );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3001,11 +2986,10 @@ void HTTP_Init( void )
|
||||
Cmd_AddRestrictedCommand( "http_clear", HTTP_Clear_f, "cancel all downloads" );
|
||||
Cmd_AddRestrictedCommand( "http_list", HTTP_List_f, "list all queued downloads" );
|
||||
Cmd_AddCommand( "http_addcustomserver", HTTP_AddCustomServer_f, "add custom fastdl server");
|
||||
|
||||
Cvar_RegisterVariable( &http_useragent );
|
||||
Cvar_RegisterVariable( &http_autoremove );
|
||||
Cvar_RegisterVariable( &http_timeout );
|
||||
Cvar_RegisterVariable( &http_maxconnections );
|
||||
http_useragent = Cvar_Get( "http_useragent", "", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "User-Agent string" );
|
||||
http_autoremove = Cvar_Get( "http_autoremove", "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "remove broken files" );
|
||||
http_timeout = Cvar_Get( "http_timeout", "45", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "timeout for http downloader" );
|
||||
http_maxconnections = Cvar_Get( "http_maxconnections", "4", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "maximum http connection number" );
|
||||
|
||||
// Read servers from fastdl.txt
|
||||
line = serverfile = (char *)FS_LoadFile( "fastdl.txt", 0, false );
|
||||
|
||||
@@ -50,8 +50,8 @@ typedef enum
|
||||
|
||||
#include "netadr.h"
|
||||
|
||||
extern convar_t net_showpackets;
|
||||
extern convar_t net_clockwindow;
|
||||
extern convar_t *net_showpackets;
|
||||
extern convar_t *net_clockwindow;
|
||||
|
||||
void NET_Init( void );
|
||||
void NET_Shutdown( void );
|
||||
|
||||
@@ -70,10 +70,10 @@ GNU General Public License for more details.
|
||||
#define NET_MAX_MESSAGE PAD_NUMBER(( NET_MAX_PAYLOAD + HEADER_BYTES ), 16 )
|
||||
|
||||
#define MASTERSERVER_ADR "mentality.rip:27010"
|
||||
#define MASTERSERVER_ADR_TEST "mentality.rip:27011"
|
||||
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0"
|
||||
|
||||
#define PORT_MASTER 27010
|
||||
#define PORT_CLIENT 27005
|
||||
#define PORT_SERVER 27015
|
||||
|
||||
#define MULTIPLAYER_BACKUP 64 // how many data slots to use when in multiplayer (must be power of 2)
|
||||
|
||||
@@ -138,7 +138,7 @@ PM_HullPointContents
|
||||
|
||||
==================
|
||||
*/
|
||||
int GAME_EXPORT PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
int PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
{
|
||||
mplane_t *plane;
|
||||
|
||||
|
||||
1782
engine/common/sequence.c
Normal file
1782
engine/common/sequence.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -85,7 +85,7 @@ static qboolean Sound_ParseID3Frame( const did3v2_frame_t *frame, const byte *bu
|
||||
string key, value;
|
||||
int32_t key_len, value_len;
|
||||
|
||||
if( buffer[0] == 0x00 || buffer[0] == 0x03 )
|
||||
if( buffer[0] == 0x00 || buffer[1] == 0x03 )
|
||||
{
|
||||
key_len = Q_strncpy( key, &buffer[1], sizeof( key ));
|
||||
value_len = frame_length - (1 + key_len + 1);
|
||||
@@ -129,7 +129,7 @@ static qboolean Sound_ParseID3Tag( const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
// old id3v1 header found
|
||||
if( CHECK_IDENT( header->ident, 'T', 'A', 'G' ))
|
||||
Con_Printf( S_ERROR "Sound_ParseID3Tag: ID3v1 is not supported! Convert to ID3v2.4!\n" );
|
||||
Con_Printf( S_ERROR "Sound_ParseID3Tag: ID3v1 is not supported! Convert to ID3v2.4!\n", header->major_ver );
|
||||
|
||||
return true; // missing tag header is not an error
|
||||
}
|
||||
|
||||
@@ -95,16 +95,12 @@ byte *Sound_Copy( size_t size )
|
||||
|
||||
uint GAME_EXPORT Sound_GetApproxWavePlayLen( const char *filepath )
|
||||
{
|
||||
string name;
|
||||
file_t *f;
|
||||
wavehdr_t wav;
|
||||
size_t filesize;
|
||||
uint msecs;
|
||||
|
||||
Q_strncpy( name, filepath, sizeof( name ));
|
||||
COM_FixSlashes( name );
|
||||
|
||||
f = FS_Open( name, "rb", false );
|
||||
f = FS_Open( filepath, "rb", false );
|
||||
if( !f )
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
snd_wav.c - wav format load & save
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
Copyright (C) 2023 FTEQW developers
|
||||
|
||||
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
|
||||
@@ -14,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "soundlib.h"
|
||||
|
||||
static const byte *iff_data;
|
||||
@@ -62,22 +60,27 @@ static int GetLittleLong( void )
|
||||
FindNextChunk
|
||||
=================
|
||||
*/
|
||||
static void FindNextChunk( const char *filename, const char *name )
|
||||
static void FindNextChunk( const char *name )
|
||||
{
|
||||
int remaining;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
ptrdiff_t remaining = iff_end - iff_lastChunk;
|
||||
iff_dataPtr = iff_lastChunk;
|
||||
remaining = iff_end - iff_dataPtr;
|
||||
|
||||
if( remaining < 8 )
|
||||
{
|
||||
// didn't find the chunk
|
||||
iff_dataPtr = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
iff_dataPtr = iff_lastChunk + 4;
|
||||
iff_dataPtr += 4;
|
||||
iff_chunkLen = GetLittleLong();
|
||||
|
||||
remaining -= 8;
|
||||
|
||||
iff_chunkLen = GetLittleLong();
|
||||
if( iff_chunkLen < 0 )
|
||||
{
|
||||
iff_dataPtr = NULL;
|
||||
@@ -86,17 +89,16 @@ static void FindNextChunk( const char *filename, const char *name )
|
||||
|
||||
if( iff_chunkLen > remaining )
|
||||
{
|
||||
Con_DPrintf( "%s: '%s' truncated by %i bytes\n", __func__, filename, iff_chunkLen - remaining );
|
||||
iff_chunkLen = remaining;
|
||||
}
|
||||
|
||||
remaining -= iff_chunkLen;
|
||||
iff_dataPtr -= 8;
|
||||
|
||||
iff_lastChunk = iff_dataPtr + 8 + iff_chunkLen;
|
||||
if ((iff_chunkLen&1) && remaining)
|
||||
iff_lastChunk++;
|
||||
if (!Q_strncmp(iff_dataPtr, name, 4))
|
||||
if( iff_chunkLen & 1 && remaining )
|
||||
iff_chunkLen++;
|
||||
|
||||
if( !Q_strncmp( (const char *)iff_dataPtr, name, 4 ))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -106,10 +108,10 @@ static void FindNextChunk( const char *filename, const char *name )
|
||||
FindChunk
|
||||
=================
|
||||
*/
|
||||
static void FindChunk( const char *filename, const char *name )
|
||||
static void FindChunk( const char *name )
|
||||
{
|
||||
iff_lastChunk = iff_data;
|
||||
FindNextChunk( filename, name );
|
||||
FindNextChunk( name );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -162,7 +164,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
iff_end = buffer + filesize;
|
||||
|
||||
// find "RIFF" chunk
|
||||
FindChunk( name, "RIFF" );
|
||||
FindChunk( "RIFF" );
|
||||
|
||||
if( !( iff_dataPtr && !Q_strncmp( (const char *)iff_dataPtr + 8, "WAVE", 4 )))
|
||||
{
|
||||
@@ -172,7 +174,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
|
||||
// get "fmt " chunk
|
||||
iff_data = iff_dataPtr + 12;
|
||||
FindChunk( name, "fmt " );
|
||||
FindChunk( "fmt " );
|
||||
|
||||
if( !iff_dataPtr )
|
||||
{
|
||||
@@ -217,13 +219,13 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
// get cue chunk
|
||||
FindChunk( name, "cue " );
|
||||
FindChunk( "cue " );
|
||||
|
||||
if( iff_dataPtr )
|
||||
{
|
||||
iff_dataPtr += 32;
|
||||
sound.loopstart = GetLittleLong();
|
||||
FindNextChunk( name, "LIST" ); // if the next chunk is a LIST chunk, look for a cue length marker
|
||||
FindNextChunk( "LIST" ); // if the next chunk is a LIST chunk, look for a cue length marker
|
||||
|
||||
if( iff_dataPtr )
|
||||
{
|
||||
@@ -242,7 +244,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
// find data chunk
|
||||
FindChunk( name, "data" );
|
||||
FindChunk( "data" );
|
||||
|
||||
if( !iff_dataPtr )
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user