Compare commits

..

6 Commits

223 changed files with 9546 additions and 9481 deletions

View File

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

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

View File

@@ -1,112 +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 |
| ----------------------- | ---------- | ------------------------ | ----------- |
| `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) |
| `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 |
| ----------------- | ------------------ | ---- |
| `edicts` | `max_edicts` | |
| `fallback_dir` | `fallback_dir` | |
| `game` | `title` | |
| `gamedir` | `gamedir` | |
| `gamedll` | `gamedll` | |
| `gamedll_linux` | `gamedll_linux` | |
| `gamedll_osx` | `gamedll_osx` | |
| `icon` | `icon` | |
| `mpentity` | `mp_entity` | |
| `mpfilter` | `mp_filter` | |
| `nomodels` | `nomodels` | |
| `secure` | `secure` | In GoldSrc it's used to mark the multiplayer game as anti-cheat enabled.<br>Original Xash3D misinterprets its value for disallowing console and developer mode.<br>FWGS ignores this key but preserves for compatibility. |
| `startmap` | `startmap` | |
| `size` | `size` | |
| `trainingmap` | `trainmap` | |
| `trainmap` | `trainmap` | |
| `type` | `type` & `gamemode`| In `liblist.gam` this key works as both `type` and `gamemode`.<br>If value is `singleplayer_only` or `multiplayer_only` the game is marked as SP or MP only, and `gameinfo.txt` type set to `Single` or `Multiplayer`.<br>Any custom value will mark the game as both SP and MP compatible, and type is set to whatever custom value. |
| `url_dl` | `url_update` | |
| `url_info` | `url_info` | |
| `version` | `version` | |

View File

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

View File

@@ -2,32 +2,38 @@ Xash3D FWGS is intended to be easily ported to specific platform, however main i
This page is about merged ports to main source tree and responsible for it developers.
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

View File

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

View File

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

View File

@@ -9,20 +9,7 @@ NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 ==
========================================================================
*/
#define ImageRAW( type ) (type == PF_RGBA_32 || type == PF_BGRA_32 || type == PF_RGB_24 || type == PF_BGR_24 || type == PF_LUMINANCE)
#define 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

View File

@@ -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,7 +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
#endif // DEFAULTS_H

View File

@@ -86,19 +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))
#elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#else
#define EXPORT
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#endif
#if ( __GNUC__ >= 3 )

View File

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

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

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

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

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

73
contrib/mittorn/wscript Normal file
View File

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

View File

@@ -206,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;
}
@@ -246,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;
}

View File

@@ -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' )
{

View File

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

View File

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

View File

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

View File

@@ -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 );
@@ -1140,7 +1140,7 @@ void CL_ClearEdicts( void )
// in case we stopped with error
clgame.maxEntities = 2;
CL_InitEdicts( cl.maxclients );
CL_InitEdicts();
}
/*
@@ -1322,7 +1322,7 @@ pfnSPR_Load
=========
*/
static HSPRITE GAME_EXPORT pfnSPR_Load( const char *szPicName )
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
{
model_t *spr;
@@ -1338,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;
@@ -1370,7 +1370,7 @@ pfnSPR_Frames
=========
*/
static int GAME_EXPORT pfnSPR_Frames( HSPRITE hPic )
int EXPORT pfnSPR_Frames( HSPRITE hPic )
{
int numFrames = 0;
@@ -1630,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
@@ -1685,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
@@ -1905,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 );
@@ -1920,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 );
@@ -1953,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 );
@@ -2001,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 );
@@ -2026,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 );
@@ -2138,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;
@@ -2194,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 );
@@ -2322,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 );
}
@@ -2333,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;
@@ -2370,7 +2354,7 @@ pfnIsLocal
=============
*/
static int GAME_EXPORT pfnIsLocal( int playernum )
int GAME_EXPORT pfnIsLocal( int playernum )
{
if( playernum == cl.playernum )
return true;
@@ -2383,7 +2367,7 @@ pfnLocalPlayerDucking
=============
*/
static int GAME_EXPORT pfnLocalPlayerDucking( void )
int GAME_EXPORT pfnLocalPlayerDucking( void )
{
return (cl.local.usehull == 1) ? true : false;
}
@@ -2394,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 );
}
@@ -2405,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 )
{
@@ -2420,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 )
@@ -2455,7 +2439,7 @@ pfnGetVisent
=============
*/
static physent_t *pfnGetVisent( int idx )
physent_t *pfnGetVisent( int idx )
{
if( idx >= 0 && idx < clgame.pmove->numvisent )
{
@@ -2471,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 );
}
@@ -2482,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 );
@@ -2494,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 );
@@ -2539,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 );
}
@@ -2564,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;
@@ -2581,7 +2565,7 @@ pfnGetGameDirectory
=============
*/
static const char *pfnGetGameDirectory( void )
const char *pfnGetGameDirectory( void )
{
static char szGetGameDir[MAX_SYSPATH];
@@ -2595,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 ));
}
@@ -2626,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;
}
@@ -2648,7 +2632,7 @@ pfnLoadMapSprite
=============
*/
static model_t *pfnLoadMapSprite( const char *filename )
model_t *pfnLoadMapSprite( const char *filename )
{
model_t *mod;
@@ -2666,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 ))
@@ -2684,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;
@@ -2710,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;
@@ -2730,7 +2714,7 @@ pfnGetTrackerIDForPlayer
obsolete, unused
=============
*/
static int GAME_EXPORT pfnGetTrackerIDForPlayer( int playerSlot )
int GAME_EXPORT pfnGetTrackerIDForPlayer( int playerSlot )
{
return 0;
}
@@ -2742,7 +2726,7 @@ pfnGetPlayerForTrackerID
obsolete, unused
=============
*/
static int GAME_EXPORT pfnGetPlayerForTrackerID( int trackerID )
int GAME_EXPORT pfnGetPlayerForTrackerID( int trackerID )
{
return 0;
}
@@ -2753,7 +2737,7 @@ pfnServerCmdUnreliable
=============
*/
static int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString )
int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString )
{
if( !COM_CheckString( szCmdString ))
return 0;
@@ -2770,7 +2754,7 @@ pfnGetMousePos
=============
*/
static void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt )
void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt )
{
if( !ppt )
return;
@@ -2785,7 +2769,7 @@ pfnSetMouseEnable
legacy of dinput code
=============
*/
static void GAME_EXPORT pfnSetMouseEnable( qboolean fEnable )
void GAME_EXPORT pfnSetMouseEnable( qboolean fEnable )
{
}
@@ -2904,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 );
@@ -2922,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 );
@@ -2999,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;
@@ -3061,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 );
}
@@ -3282,7 +3266,7 @@ NetAPI_InitNetworking
=================
*/
static void GAME_EXPORT NetAPI_InitNetworking( void )
void GAME_EXPORT NetAPI_InitNetworking( void )
{
NET_Config( true, false ); // allow remote
}
@@ -3293,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;
@@ -3312,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;
}
/*
@@ -3321,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;
@@ -3336,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++ )
{
@@ -3375,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 );
}
}
/*
@@ -3386,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;
@@ -3405,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;
}
@@ -3433,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;
}
/*
@@ -3441,7 +3450,7 @@ NetAPI_AdrToString
=================
*/
static const char *NetAPI_AdrToString( netadr_t *a )
const char *NetAPI_AdrToString( netadr_t *a )
{
return NET_AdrToString( *a );
}
@@ -3452,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 );
}
@@ -3463,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 );
}
@@ -3474,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 );
}
@@ -3485,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 );
}
@@ -3496,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 );
@@ -3516,7 +3525,7 @@ Voice_StartVoiceTweakMode
=================
*/
static int GAME_EXPORT Voice_StartVoiceTweakMode( void )
int GAME_EXPORT Voice_StartVoiceTweakMode( void )
{
return 0;
}
@@ -3527,7 +3536,7 @@ Voice_EndVoiceTweakMode
=================
*/
static void GAME_EXPORT Voice_EndVoiceTweakMode( void )
void GAME_EXPORT Voice_EndVoiceTweakMode( void )
{
}
@@ -3537,7 +3546,7 @@ Voice_SetControlFloat
=================
*/
static void GAME_EXPORT Voice_SetControlFloat( VoiceTweakControl iControl, float value )
void GAME_EXPORT Voice_SetControlFloat( VoiceTweakControl iControl, float value )
{
}
@@ -3547,7 +3556,7 @@ Voice_GetControlFloat
=================
*/
static float GAME_EXPORT Voice_GetControlFloat( VoiceTweakControl iControl )
float GAME_EXPORT Voice_GetControlFloat( VoiceTweakControl iControl )
{
return 1.0f;
}
@@ -3865,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 )
@@ -3913,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
{
@@ -3929,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
@@ -4012,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();
@@ -4029,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

View File

@@ -642,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
@@ -982,21 +971,28 @@ pfnCheckGameDll
*/
int GAME_EXPORT pfnCheckGameDll( void )
{
#if 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
}
/*
@@ -1222,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 )

View File

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

View File

@@ -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 ||
@@ -142,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;
}

View File

@@ -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();

View File

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

View File

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

View File

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

View File

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

View File

@@ -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++ )
{
@@ -295,9 +282,10 @@ void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int b
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'

View File

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

View File

@@ -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" );

View File

@@ -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->visents[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++ )

View File

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

View File

@@ -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
//
@@ -1019,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 );
@@ -1052,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 );

View File

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

View File

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

View File

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

View File

@@ -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
@@ -172,8 +173,6 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
{
if( newstate == oldstate )
return;
if( m_ignore.value )
return;
// since SetCursorType controls cursor visibility
// execute it first, and then check mouse grab state
@@ -181,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
@@ -189,6 +191,9 @@ 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
@@ -209,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 )
@@ -412,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() )
{
@@ -451,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 )
{
@@ -527,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 );
@@ -538,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;
@@ -596,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 )
{

View File

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

View File

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

View File

@@ -8,14 +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" );
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 )
{
@@ -98,6 +98,16 @@ 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 );
@@ -221,7 +231,7 @@ static ref_api_t gEngfuncs =
Cvar_VariableString,
Cvar_SetValue,
Cvar_Set,
Cvar_RegisterVariable,
(void*)Cvar_RegisterVariable,
Cvar_FullSet,
Cmd_AddRefCommand,
@@ -272,6 +282,8 @@ static ref_api_t gEngfuncs =
Mod_ForName,
pfnMod_Extradata,
CL_ModelHandle,
pfnMod_GetCurrentLoadingModel,
pfnMod_SetCurrentLoadingModel,
CL_GetRemapInfoForEntity,
CL_AllocRemapInfo,
@@ -367,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 )
@@ -537,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 )
@@ -602,14 +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 );
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" );
@@ -653,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 );
}
@@ -675,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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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
@@ -592,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 );
@@ -608,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 );
@@ -627,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 );
@@ -711,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 );
@@ -747,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 );

View File

@@ -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
}
/*

View File

@@ -334,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;
@@ -388,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;

View File

@@ -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 );
@@ -1240,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

View File

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

View File

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

View File

@@ -18,7 +18,6 @@ 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;
@@ -52,8 +51,6 @@ static fs_interface_t fs_memfuncs =
_Mem_Alloc,
_Mem_Realloc,
_Mem_Free,
Platform_GetNativeObject,
};
static void FS_UnloadProgs( void )

View File

@@ -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"
@@ -55,14 +54,15 @@ CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in d
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" );
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 )
{
@@ -116,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")
@@ -128,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"
@@ -280,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 )
@@ -601,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 );
}
@@ -683,8 +681,8 @@ qboolean Host_FilterTime( float time )
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;
@@ -1018,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 )))
{
@@ -1089,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();
@@ -1161,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();
@@ -1177,18 +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_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 );
@@ -1258,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( ))
@@ -1309,7 +1294,6 @@ void EXPORT Host_Shutdown( void )
#endif
SV_Shutdown( "Server shutdown\n" );
SV_UnloadProgs();
SV_ShutdownFilter();
CL_Shutdown();

View File

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

View File

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

View File

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

View File

@@ -1,204 +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->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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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( );
}

View File

@@ -2051,7 +2051,7 @@ static void Mod_LoadTextureData( dbspmodel_t *bmod, int textureIndex )
// 2. Internal from map
// Try WAD texture (force while r_wadtextures is 1)
if(( r_wadtextures.value && bmod->wadlist.count > 0 ) || mipTex->offsets[0] <= 0 )
if(( r_wadtextures->value && bmod->wadlist.count > 0 ) || mipTex->offsets[0] <= 0 )
{
char texpath[MAX_VA_STRING];
int wadIndex = Mod_FindTextureInWadList( &bmod->wadlist, mipTex->name, texpath, sizeof( texpath ));
@@ -2505,7 +2505,7 @@ static void Mod_LoadSurfaces( dbspmodel_t *bmod )
#if !XASH_DEDICATED // TODO: Do we need subdivide on server?
if( FBitSet( out->flags, SURF_DRAWTURB ) && !Host_IsDedicated() )
ref.dllFuncs.GL_SubdivideSurface( loadmodel, out ); // cut up polygon for warps
ref.dllFuncs.GL_SubdivideSurface( out ); // cut up polygon for warps
#endif
}
@@ -3174,7 +3174,7 @@ Mod_CheckLump
check lump for existing
==================
*/
int GAME_EXPORT Mod_CheckLump( const char *filename, const int lump, int *lumpsize )
int Mod_CheckLump( const char *filename, const int lump, int *lumpsize )
{
file_t *f = FS_Open( filename, "rb", false );
byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )];
@@ -3233,7 +3233,7 @@ Mod_ReadLump
reading random lump by user request
==================
*/
int GAME_EXPORT Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize )
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize )
{
file_t *f = FS_Open( filename, "rb", false );
byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )];
@@ -3315,7 +3315,7 @@ writing lump by user request
only empty lumps is allows
==================
*/
int GAME_EXPORT Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize )
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize )
{
byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )];
size_t prefetch_size = sizeof( buffer );

View File

@@ -119,9 +119,9 @@ typedef struct world_static_s
extern world_static_t world;
extern poolhandle_t com_studiocache;
extern model_t *loadmodel;
extern convar_t mod_studiocache;
extern convar_t r_wadtextures;
extern convar_t r_showhull;
extern convar_t *mod_studiocache;
extern convar_t *r_wadtextures;
extern convar_t *r_showhull;
//
// model.c

View File

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

View File

@@ -28,9 +28,9 @@ 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;
/*
@@ -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" );
@@ -403,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

View File

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

View File

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

View File

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

View File

@@ -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;
}
/*
@@ -1098,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 );
@@ -1142,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;
@@ -1157,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 )
{
@@ -1211,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 )
{
@@ -1405,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;
@@ -1432,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;
@@ -1467,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;
@@ -1494,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;
@@ -1523,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;
@@ -1558,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;
@@ -1595,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;
@@ -1636,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;
@@ -1676,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;
@@ -1714,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;
@@ -1797,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 );
@@ -1915,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 );
@@ -1941,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] );
}
}
/*
=============================================================================

View File

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

View File

@@ -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 ))
@@ -2252,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;
/*
========================
@@ -2310,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. "
@@ -2531,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 )
@@ -2630,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 ),
@@ -2672,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 );
@@ -2714,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 );
@@ -2992,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 );

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@@ -30,8 +30,8 @@ GNU General Public License for more details.
#if !XASH_WIN32 && !XASH_MOBILE_PLATFORM && !XASH_LOW_MEMORY
#define XASH_COLORIZE_CONSOLE true
// use with caution, running engine in Qt Creator may cause a freeze in read() call
// I have never encountered this bug anywhere else, so still enable by default
#define XASH_USE_SELECT 1
// I was never encountered this bug anywhere else, so still enable by default
// #define XASH_USE_SELECT 1
#else
#define XASH_COLORIZE_CONSOLE false
#endif
@@ -54,7 +54,6 @@ static LogData s_ld;
char *Sys_Input( void )
{
#if XASH_USE_SELECT
if( Host_IsDedicated( ))
{
fd_set rfds;
static char line[1024];
@@ -149,7 +148,7 @@ void Sys_InitLog( void )
s_ld.logfileno = fileno( s_ld.logfile );
fprintf( s_ld.logfile, "=================================================================================\n" );
fprintf( s_ld.logfile, "\t%s (build %i commit %s (%s-%s)) started at %s\n", s_ld.title, Q_buildnum(), Q_buildcommit(), Q_buildos(), Q_buildarch(), Q_timestamp( TIME_FULL ) );
fprintf( s_ld.logfile, "\t%s (build %i) started at %s\n", s_ld.title, Q_buildnum(), Q_timestamp( TIME_FULL ) );
fprintf( s_ld.logfile, "=================================================================================\n" );
}
}

View File

@@ -795,9 +795,9 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
return length;
}
#elif defined(__sgi)
#elif defined(__sgi) || defined(__SWITCH__) || defined(__vita__)
/*
/*
* These functions are stubbed for now to get the code compiling.
* In the future it may be possible to get these working in some way.
* Current ideas are checking the working directory for a binary with
@@ -813,29 +813,13 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
return -1;
return -1;
}
WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
return -1;
}
#elif defined(__SWITCH__) || defined(__vita__)
/* Not possible on this platform */
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
return -1;
}
WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
return -1;
return -1;
}
#else

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
#pragma once
#ifndef ANDROID_PRIV_H
#define ANDROID_PRIV_H
#include <EGL/egl.h>
#include <android/log.h>
#include <jni.h>
extern struct jnimethods_s
{
jclass actcls;
JavaVM *vm;
JNIEnv *env;
jmethodID enableTextInput;
jmethodID vibrate;
jmethodID messageBox;
jmethodID notify;
jmethodID setTitle;
jmethodID setIcon;
jmethodID getAndroidId;
jmethodID saveID;
jmethodID loadID;
jmethodID showMouse;
jmethodID shellExecute;
jmethodID swapBuffers;
jmethodID toggleEGL;
jmethodID createGLContext;
jmethodID getGLAttribute;
jmethodID deleteGLContext;
jmethodID getSelectedPixelFormat;
jmethodID getSurface;
int width, height;
} jni;
extern struct jnimouse_s
{
float x, y;
} jnimouse;
//
// vid_android.c
//
void Android_UpdateSurface( qboolean active );
#endif // ANDROID_PRIV_H

View File

@@ -43,7 +43,7 @@ void *ANDROID_LoadLibrary( const char *dllname )
}
// HACKHACK: keep old behaviour for compability
if( Q_strstr( dllname, "." OS_LIB_EXT ) || Q_strstr( dllname, "/" ))
if( Q_strstr( dllname, "." OS_LIB_EXT ) || Q_strstr( dllname, PATH_SPLITTER ))
{
pHandle = dlopen( dllname, RTLD_LAZY );
if( pHandle )

View File

@@ -140,10 +140,10 @@ struct soinfo {
#endif
#if defined(USE_RELA)
Elf_RelA* plt_rela;
Elf_Rela* plt_rela;
size_t plt_rela_count;
Elf_RelA* rela;
Elf_Rela* rela;
size_t rela_count;
#else
Elf_Rel* plt_rel;

View File

@@ -0,0 +1,277 @@
/*
Copyright (C) 2015 SiPlus, Chasseur de bots
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "common.h"
#include "platform/platform.h"
#if XASH_SOUND == SOUND_OPENSLES
#include <SLES/OpenSLES.h>
#include "pthread.h"
#include "sound.h"
extern dma_t dma;
static SLObjectItf snddma_android_engine = NULL;
static SLObjectItf snddma_android_outputMix = NULL;
static SLObjectItf snddma_android_player = NULL;
static SLBufferQueueItf snddma_android_bufferQueue;
static SLPlayItf snddma_android_play;
static pthread_mutex_t snddma_android_mutex = PTHREAD_MUTEX_INITIALIZER;
static int snddma_android_size;
static const SLInterfaceID *pSL_IID_ENGINE;
static const SLInterfaceID *pSL_IID_BUFFERQUEUE;
static const SLInterfaceID *pSL_IID_PLAY;
static SLresult SLAPIENTRY (*pslCreateEngine)(
SLObjectItf *pEngine,
SLuint32 numOptions,
const SLEngineOption *pEngineOptions,
SLuint32 numInterfaces,
const SLInterfaceID *pInterfaceIds,
const SLboolean * pInterfaceRequired
);
void SNDDMA_Activate( qboolean active )
{
if( !dma.initialized )
return;
if( active )
{
memset( dma.buffer, 0, snddma_android_size * 2 );
(*snddma_android_bufferQueue)->Enqueue( snddma_android_bufferQueue, dma.buffer, snddma_android_size );
(*snddma_android_play)->SetPlayState( snddma_android_play, SL_PLAYSTATE_PLAYING );
}
else
{
(*snddma_android_play)->SetPlayState( snddma_android_play, SL_PLAYSTATE_STOPPED );
(*snddma_android_bufferQueue)->Clear( snddma_android_bufferQueue );
}
}
static void SNDDMA_Android_Callback( SLBufferQueueItf bq, void *context )
{
uint8_t *buffer2;
pthread_mutex_lock( &snddma_android_mutex );
buffer2 = ( uint8_t * )dma.buffer + snddma_android_size;
(*bq)->Enqueue( bq, buffer2, snddma_android_size );
memcpy( buffer2, dma.buffer, snddma_android_size );
memset( dma.buffer, 0, snddma_android_size );
dma.samplepos += dma.samples;
pthread_mutex_unlock( &snddma_android_mutex );
}
static const char *SNDDMA_Android_Init( void )
{
SLresult result;
SLEngineItf engine;
int freq;
SLDataLocator_BufferQueue sourceLocator;
SLDataFormat_PCM sourceFormat;
SLDataSource source;
SLDataLocator_OutputMix sinkLocator;
SLDataSink sink;
SLInterfaceID interfaceID;
SLboolean interfaceRequired;
int samples;
void *handle = dlopen( "libOpenSLES.so", RTLD_LAZY );
if( !handle )
return "dlopen for libOpenSLES.so";
pslCreateEngine = dlsym( handle, "slCreateEngine" );
if( !pslCreateEngine )
return "resolve slCreateEngine";
pSL_IID_ENGINE = dlsym( handle, "SL_IID_ENGINE" );
if( !pSL_IID_ENGINE )
return "resolve SL_IID_ENGINE";
pSL_IID_PLAY = dlsym( handle, "SL_IID_PLAY" );
if( !pSL_IID_PLAY )
return "resolve SL_IID_PLAY";
pSL_IID_BUFFERQUEUE = dlsym( handle, "SL_IID_BUFFERQUEUE" );
if( !pSL_IID_BUFFERQUEUE )
return "resolve SL_IID_BUFFERQUEUE";
result = pslCreateEngine( &snddma_android_engine, 0, NULL, 0, NULL, NULL );
if( result != SL_RESULT_SUCCESS ) return "slCreateEngine";
result = (*snddma_android_engine)->Realize( snddma_android_engine, SL_BOOLEAN_FALSE );
if( result != SL_RESULT_SUCCESS ) return "engine->Realize";
result = (*snddma_android_engine)->GetInterface( snddma_android_engine, *pSL_IID_ENGINE, &engine );
if( result != SL_RESULT_SUCCESS ) return "engine->GetInterface(ENGINE)";
result = (*engine)->CreateOutputMix( engine, &snddma_android_outputMix, 0, NULL, NULL );
if( result != SL_RESULT_SUCCESS ) return "engine->CreateOutputMix";
result = (*snddma_android_outputMix)->Realize( snddma_android_outputMix, SL_BOOLEAN_FALSE );
if( result != SL_RESULT_SUCCESS ) return "outputMix->Realize";
freq = SOUND_DMA_SPEED;
sourceLocator.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
sourceLocator.numBuffers = 2;
sourceFormat.formatType = SL_DATAFORMAT_PCM;
sourceFormat.numChannels = 2; // always stereo, because engine supports only stereo
sourceFormat.samplesPerSec = freq * 1000;
sourceFormat.bitsPerSample = 16; // always 16 bit audio
sourceFormat.containerSize = sourceFormat.bitsPerSample;
sourceFormat.channelMask = SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT;
sourceFormat.endianness = SL_BYTEORDER_LITTLEENDIAN;
source.pLocator = &sourceLocator;
source.pFormat = &sourceFormat;
sinkLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX;
sinkLocator.outputMix = snddma_android_outputMix;
sink.pLocator = &sinkLocator;
sink.pFormat = NULL;
interfaceID = *pSL_IID_BUFFERQUEUE;
interfaceRequired = SL_BOOLEAN_TRUE;
result = (*engine)->CreateAudioPlayer( engine, &snddma_android_player, &source, &sink, 1, &interfaceID, &interfaceRequired );
if( result != SL_RESULT_SUCCESS ) return "engine->CreateAudioPlayer";
result = (*snddma_android_player)->Realize( snddma_android_player, SL_BOOLEAN_FALSE );
if( result != SL_RESULT_SUCCESS ) return "player->Realize";
result = (*snddma_android_player)->GetInterface( snddma_android_player, *pSL_IID_BUFFERQUEUE, &snddma_android_bufferQueue );
if( result != SL_RESULT_SUCCESS ) return "player->GetInterface(BUFFERQUEUE)";
result = (*snddma_android_player)->GetInterface( snddma_android_player, *pSL_IID_PLAY, &snddma_android_play );
if( result != SL_RESULT_SUCCESS ) return "player->GetInterface(PLAY)";
result = (*snddma_android_bufferQueue)->RegisterCallback( snddma_android_bufferQueue, SNDDMA_Android_Callback, NULL );
if( result != SL_RESULT_SUCCESS ) return "bufferQueue->RegisterCallback";
samples = s_samplecount.value;
if( !samples )
samples = 4096;
dma.format.channels = sourceFormat.numChannels;
dma.samples = samples * sourceFormat.numChannels;
dma.format.speed = freq;
snddma_android_size = dma.samples * ( sourceFormat.bitsPerSample >> 3 );
dma.buffer = Z_Malloc( snddma_android_size * 2 );
dma.samplepos = 0;
// dma.sampleframes = dma.samples / dma.format.channels;
dma.format.width = 2;
if( !dma.buffer ) return "malloc";
//snddma_android_mutex = trap_Mutex_Create();
dma.initialized = true;
SNDDMA_Activate( true );
return NULL;
}
qboolean SNDDMA_Init( void )
{
const char *initError;
Msg( "OpenSL ES audio device initializing...\n" );
initError = SNDDMA_Android_Init();
if( initError )
{
Msg( S_ERROR "SNDDMA_Init: %s failed.\n", initError );
SNDDMA_Shutdown();
return false;
}
Msg( "OpenSL ES audio initialized.\n" );
dma.backendName = "OpenSL ES";
return true;
}
void SNDDMA_Shutdown( void )
{
Msg( "Closing OpenSL ES audio device...\n" );
if( snddma_android_player )
{
(*snddma_android_player)->Destroy( snddma_android_player );
snddma_android_player = NULL;
}
if( snddma_android_outputMix )
{
(*snddma_android_outputMix)->Destroy( snddma_android_outputMix );
snddma_android_outputMix = NULL;
}
if( snddma_android_engine )
{
(*snddma_android_engine)->Destroy( snddma_android_engine );
snddma_android_engine = NULL;
}
if( dma.buffer )
{
Z_Free( dma.buffer );
dma.buffer = NULL;
}
//if( snddma_android_mutex )
//trap_Mutex_Destroy( &snddma_android_mutex );
Msg( "OpenSL ES audio device shut down.\n" );
}
void SNDDMA_Submit( void )
{
pthread_mutex_unlock( &snddma_android_mutex );
}
void SNDDMA_BeginPainting( void )
{
pthread_mutex_lock( &snddma_android_mutex );
}
qboolean VoiceCapture_Init( void )
{
return false;
}
qboolean VoiceCapture_Activate( qboolean activate )
{
return false;
}
qboolean VoiceCapture_Lock( qboolean lock )
{
return false;
}
void VoiceCapture_Shutdown( void )
{
}
#endif

View File

@@ -0,0 +1,665 @@
#include "platform/platform.h"
#include "input.h"
#include "client.h"
#include "filesystem.h"
#include "platform/android/android_priv.h"
#include "vid_common.h"
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
static struct vid_android_s
{
int gl_attribs[REF_GL_ATTRIBUTES_COUNT];
qboolean gl_attribs_set[REF_GL_ATTRIBUTES_COUNT];
EGLint gl_api;
qboolean gles1;
void *libgles1, *libgles2;
qboolean has_context;
ANativeWindow* window;
} vid_android;
static struct nw_s
{
void (*release)(ANativeWindow* window);
int32_t (*getWidth)(ANativeWindow* window);
int32_t (*getHeight)(ANativeWindow* window);
int32_t (*getFormat)(ANativeWindow* window);
int32_t (*setBuffersGeometry)(ANativeWindow* window, int32_t width, int32_t height, int32_t format);
int32_t (*lock)(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
int32_t (*unlockAndPost)(ANativeWindow* window);
ANativeWindow* (*fromSurface)(JNIEnv* env, jobject surface);
} nw;
#define NW_FF(x) {"ANativeWindow_"#x, (void*)&nw.x}
static dllfunc_t android_funcs[] =
{
NW_FF(release),
NW_FF(getWidth),
NW_FF(getHeight),
NW_FF(getFormat),
NW_FF(setBuffersGeometry),
NW_FF(lock),
NW_FF(unlockAndPost),
NW_FF(fromSurface),
{ NULL, NULL }
};
#undef NW_FF
dll_info_t android_info = { "libandroid.so", android_funcs, false };
static struct egl_s
{
EGLSurface (*GetCurrentSurface)(EGLint readdraw);
EGLDisplay (*GetCurrentDisplay)(void);
EGLint (*GetError)(void);
EGLBoolean (*SwapBuffers)(EGLDisplay dpy, EGLSurface surface);
EGLBoolean (*SwapInterval)(EGLDisplay dpy, EGLint interval);
void *(*GetProcAddress)(const char *procname);
} egl;
#undef GetProcAddress
#define EGL_FF(x) {"egl"#x, (void*)&egl.x}
static dllfunc_t egl_funcs[] =
{
EGL_FF(SwapInterval),
EGL_FF(SwapBuffers),
EGL_FF(GetError),
EGL_FF(GetCurrentDisplay),
EGL_FF(GetCurrentSurface),
EGL_FF(GetProcAddress),
{ NULL, NULL }
};
#undef EGL_FF
dll_info_t egl_info = { "libEGL.so", egl_funcs, false };
static struct nativeegl_s
{
qboolean valid;
void *window;
EGLDisplay dpy;
EGLSurface surface;
EGLContext context;
EGLConfig cfg;
EGLint numCfg;
const char *extensions;
} negl;
/*
========================
Android_SwapInterval
========================
*/
static void Android_SwapInterval( int interval )
{
if( negl.valid )
egl.SwapInterval( negl.dpy, interval );
}
/*
========================
Android_SetTitle
========================
*/
static void Android_SetTitle( const char *title )
{
(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.setTitle, (*jni.env)->NewStringUTF( jni.env, title ) );
}
/*
========================
Android_SetIcon
========================
*/
static void Android_SetIcon( const char *path )
{
(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.setIcon, (*jni.env)->NewStringUTF( jni.env, path ) );
}
/*
========================
Android_GetScreenRes
Resolution got from last resize event
========================
*/
static void Android_GetScreenRes( int *width, int *height )
{
*width=jni.width, *height=jni.height;
}
/*
========================
Android_SwapBuffers
Update screen. Use native EGL if possible
========================
*/
void GL_SwapBuffers( void )
{
if( negl.valid )
{
egl.SwapBuffers( negl.dpy, negl.surface );
}
else
{
(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.swapBuffers );
}
}
/*
========================
Android_UpdateSurface
Check if we may use native EGL without jni calls
========================
*/
void Android_UpdateSurface( qboolean active )
{
negl.valid = false;
if( nw.release )
{
if( vid_android.window && !active )
{
nw.release( vid_android.window );
vid_android.window = NULL;
}
if( active )
{
jobject surf;
if( vid_android.window )
nw.release( vid_android.window );
surf = (*jni.env)->CallStaticObjectMethod(jni.env, jni.actcls, jni.getSurface);
Con_Printf("s %p\n", surf);
vid_android.window = nw.fromSurface(jni.env, surf);
Con_Printf("w %p\n", vid_android.window);
nw.setBuffersGeometry(vid_android.window, 0, 0, WINDOW_FORMAT_RGB_565 );
(*jni.env)->DeleteLocalRef( jni.env, surf );
}
return;
}
if( !vid_android.has_context )
return;
if( ( active && host.status == HOST_FRAME ) || !active )
(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.toggleEGL, 0 );
if( active )
(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.toggleEGL, 1 );
if( !Sys_CheckParm("-nativeegl") || !active )
return; // enabled by user
if( !egl.GetCurrentDisplay )
return;
negl.dpy = egl.GetCurrentDisplay();
if( negl.dpy == EGL_NO_DISPLAY )
return;
negl.surface = egl.GetCurrentSurface(EGL_DRAW);
if( negl.surface == EGL_NO_SURFACE )
return;
// now check if swapBuffers does not give error
if( egl.SwapBuffers( negl.dpy, negl.surface ) == EGL_FALSE )
return;
// double check
if( egl.GetError() != EGL_SUCCESS )
return;
__android_log_print( ANDROID_LOG_VERBOSE, "Xash", "native EGL enabled" );
negl.valid = true;
}
/*
========================
Android_GetGLAttribute
========================
*/
static int Android_GetGLAttribute( int eglAttr )
{
int ret = (*jni.env)->CallStaticIntMethod( jni.env, jni.actcls, jni.getGLAttribute, eglAttr );
// Con_Reportf( "Android_GetGLAttribute( %i ) => %i\n", eglAttr, ret );
return ret;
}
int Android_GetSelectedPixelFormat( void )
{
return (*jni.env)->CallStaticIntMethod( jni.env, jni.actcls, jni.getSelectedPixelFormat );
}
qboolean R_Init_Video( const int type )
{
char buf[MAX_VA_STRING];
qboolean retval;
switch( Android_GetSelectedPixelFormat() )
{
case 1:
refState.desktopBitsPixel = 16;
break;
case 2:
refState.desktopBitsPixel = 8;
break;
default:
refState.desktopBitsPixel = 32;
break;
}
if( FS_FileExists( GI->iconpath, true ) )
{
Q_snprintf( buf, sizeof( buf ), "%s/%s/%s", COM_CheckStringEmpty( host.rodir ) ? host.rodir : host.rootdir, GI->gamefolder, GI->iconpath );
Android_SetIcon( buf );
}
Android_SetTitle( GI->title );
VID_StartupGamma();
switch( type )
{
case REF_SOFTWARE:
glw_state.software = true;
break;
case REF_GL:
glw_state.software = false;
Sys_LoadLibrary( &egl_info );
if( !glw_state.safe && Sys_GetParmFromCmdLine( "-safegl", buf ) )
glw_state.safe = bound( SAFE_NO, Q_atoi( buf ), SAFE_DONTCARE );
break;
default:
Host_Error( "Can't initialize unknown context type %d!\n", type );
break;
}
if( glw_state.software )
{
uint arg;
// Con_Reportf( S_ERROR "Native software mode isn't supported on Android yet! :(\n" );
// return false;
Sys_LoadLibrary( &android_info );
Android_UpdateSurface( true );
if( !SW_CreateBuffer( jni.width, jni.height, &arg, &arg, &arg, &arg, &arg ) )
return false;
}
while( !(retval = VID_SetMode()) )
{
glw_state.safe++;
if( glw_state.safe > SAFE_LAST )
return false;
}
switch( type )
{
case REF_GL:
// refdll also can check extensions
ref.dllFuncs.GL_InitExtensions();
break;
case REF_SOFTWARE:
default:
break;
}
host.renderinfo_changed = false;
return true;
}
void R_Free_Video( void )
{
// (*jni.env)->CallStaticBooleanMethod( jni.env, jni.actcls, jni.deleteGLContext );
// VID_DestroyWindow ();
// R_FreeVideoModes();
Sys_FreeLibrary( &android_info );
Sys_FreeLibrary( &egl_info );
vid_android.has_context = false;
ref.dllFuncs.GL_ClearExtensions();
}
#define COPY_ATTR_IF_SET( refattr, attr ) \
if( vid_android.gl_attribs_set[refattr] ) \
{ \
attribs[i++] = attr; \
attribs[i++] = vid_android.gl_attribs[refattr]; \
}
static size_t VID_GenerateConfig( EGLint *attribs, size_t size )
{
size_t i = 0;
memset( attribs, 0, size * sizeof( EGLint ) );
vid_android.gles1 = false;
memset( vid_android.gl_attribs, 0, sizeof( vid_android.gl_attribs ));
memset( vid_android.gl_attribs_set, 0, sizeof( vid_android.gl_attribs_set ));
// refdll can request some attributes
ref.dllFuncs.GL_SetupAttributes( glw_state.safe );
COPY_ATTR_IF_SET( REF_GL_RED_SIZE, EGL_RED_SIZE );
COPY_ATTR_IF_SET( REF_GL_GREEN_SIZE, EGL_GREEN_SIZE );
COPY_ATTR_IF_SET( REF_GL_BLUE_SIZE, EGL_BLUE_SIZE );
COPY_ATTR_IF_SET( REF_GL_ALPHA_SIZE, EGL_ALPHA_SIZE );
COPY_ATTR_IF_SET( REF_GL_DEPTH_SIZE, EGL_DEPTH_SIZE );
COPY_ATTR_IF_SET( REF_GL_STENCIL_SIZE, EGL_STENCIL_SIZE );
COPY_ATTR_IF_SET( REF_GL_MULTISAMPLEBUFFERS, EGL_SAMPLE_BUFFERS );
COPY_ATTR_IF_SET( REF_GL_MULTISAMPLESAMPLES, EGL_SAMPLES );
if( vid_android.gl_attribs_set[REF_GL_ACCELERATED_VISUAL] )
{
attribs[i++] = EGL_CONFIG_CAVEAT;
attribs[i++] = vid_android.gl_attribs[REF_GL_ACCELERATED_VISUAL] ? EGL_NONE : EGL_DONT_CARE;
}
// BigGL support
attribs[i++] = EGL_RENDERABLE_TYPE;
vid_android.gl_api = EGL_OPENGL_ES_API;
if( vid_android.gl_attribs_set[REF_GL_CONTEXT_PROFILE_MASK] &&
!( vid_android.gl_attribs[REF_GL_CONTEXT_PROFILE_MASK] & REF_GL_CONTEXT_PROFILE_ES ))
{
attribs[i++] = EGL_OPENGL_BIT;
vid_android.gl_api = EGL_OPENGL_API;
}
else if( vid_android.gl_attribs_set[REF_GL_CONTEXT_MAJOR_VERSION] &&
vid_android.gl_attribs[REF_GL_CONTEXT_MAJOR_VERSION] >= 2 )
{
attribs[i++] = EGL_OPENGL_ES2_BIT;
}
else
{
i--; // erase EGL_RENDERABLE_TYPE
vid_android.gles1 = true;
}
attribs[i++] = EGL_NONE;
return i;
}
static size_t VID_GenerateContextConfig( EGLint *attribs, size_t size )
{
size_t i = 0;
memset( attribs, 0, size * sizeof( EGLint ));
/*if( Q_strcmp( negl.extensions, " EGL_KHR_create_context ") )
{
if( vid_android.gl_attribs_set[REF_GL_CONTEXT_FLAGS] )
{
attribs[i++] = 0x30FC; // EGL_CONTEXT_FLAGS_KHR
attribs[i++] = vid_android.gl_attribs[REF_GL_CONTEXT_FLAGS] & ((REF_GL_CONTEXT_ROBUST_ACCESS_FLAG << 1) - 1);
}
if( vid_android.gl_attribs_set[REF_GL_CONTEXT_PROFILE_MASK] )
{
int val = vid_android.gl_attribs[REF_GL_CONTEXT_PROFILE_MASK];
if( val & ( (REF_GL_CONTEXT_PROFILE_COMPATIBILITY << 1) - 1 ) )
{
attribs[i++] = 0x30FD; // EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
attribs[i++] = val;
}
}
COPY_ATTR_IF_SET( REF_GL_CONTEXT_MAJOR_VERSION, EGL_CONTEXT_CLIENT_VERSION );
COPY_ATTR_IF_SET( REF_GL_CONTEXT_MINOR_VERSION, 0x30FB );
}
else*/
{
// without extension we can set only major version
COPY_ATTR_IF_SET( REF_GL_CONTEXT_MAJOR_VERSION, EGL_CONTEXT_CLIENT_VERSION );
}
attribs[i++] = EGL_NONE;
return i;
}
qboolean VID_SetMode( void )
{
EGLint format;
jintArray attribs, contextAttribs;
static EGLint nAttribs[32+1], nContextAttribs[32+1];
const size_t attribsSize = ARRAYSIZE( nAttribs );
size_t s1, s2;
if( vid_android.has_context )
{
R_ChangeDisplaySettings( 0, 0, false ); // width and height are ignored anyway
return true;
}
s1 = VID_GenerateConfig(nAttribs, attribsSize);
s2 = VID_GenerateContextConfig(nContextAttribs, attribsSize);
attribs = (*jni.env)->NewIntArray( jni.env, s1 );
contextAttribs = (*jni.env)->NewIntArray( jni.env, s2 );
(*jni.env)->SetIntArrayRegion( jni.env, attribs, 0, s1, nAttribs );
(*jni.env)->SetIntArrayRegion( jni.env, contextAttribs, 0, s2, nContextAttribs );
R_ChangeDisplaySettings( 0, 0, false ); // width and height are ignored anyway
if( glw_state.software )
return true;
if( (*jni.env)->CallStaticBooleanMethod( jni.env, jni.actcls, jni.createGLContext, attribs, contextAttribs ) )
{
vid_android.has_context = true;
return true;
}
return false;
}
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
{
int render_w, render_h;
uint rotate = vid_rotate->value;
Android_GetScreenRes(&width, &height);
render_w = width;
render_h = height;
Con_Reportf( "R_ChangeDisplaySettings: forced resolution to %dx%d)\n", width, height);
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" );
}
R_SaveVideoMode( width, height, render_w, render_h );
refState.wideScreen = true; // V_AdjustFov will check for widescreen
return rserr_ok;
}
int GL_SetAttribute( int attr, int val )
{
if( attr < 0 || attr >= REF_GL_ATTRIBUTES_COUNT )
return -1;
vid_android.gl_attribs[attr] = val;
vid_android.gl_attribs_set[attr] = true;
return 0;
}
int GL_GetAttribute( int attr, int *val )
{
EGLBoolean ret;
if( attr < 0 || attr >= REF_GL_ATTRIBUTES_COUNT )
return -1;
if( !val )
return -1;
switch( attr )
{
case REF_GL_RED_SIZE:
*val = Android_GetGLAttribute( EGL_RED_SIZE );
return 0;
case REF_GL_GREEN_SIZE:
*val = Android_GetGLAttribute( EGL_GREEN_SIZE );
return 0;
case REF_GL_BLUE_SIZE:
*val = Android_GetGLAttribute( EGL_BLUE_SIZE );
return 0;
case REF_GL_ALPHA_SIZE:
*val = Android_GetGLAttribute( EGL_ALPHA_SIZE );
return 0;
case REF_GL_DEPTH_SIZE:
*val = Android_GetGLAttribute( EGL_DEPTH_SIZE );
return 0;
case REF_GL_STENCIL_SIZE:
*val = Android_GetGLAttribute( EGL_STENCIL_SIZE );
return 0;
case REF_GL_MULTISAMPLESAMPLES:
*val = Android_GetGLAttribute( EGL_SAMPLES );
return 0;
}
return -1;
}
int R_MaxVideoModes( void )
{
return 0;
}
vidmode_t* R_GetVideoMode( int num )
{
return NULL;
}
void* GL_GetProcAddress( const char *name ) // RenderAPI requirement
{
void *gles;
void *addr;
if( vid_android.gles1 )
{
if( !vid_android.libgles1 )
vid_android.libgles1 = dlopen("libGLESv1_CM.so", RTLD_NOW);
gles = vid_android.libgles1;
}
else
{
if( !vid_android.libgles2 )
vid_android.libgles2 = dlopen("libGLESv2.so", RTLD_NOW);
gles = vid_android.libgles2;
}
if( gles && ( addr = dlsym(gles, name ) ) )
return addr;
if( !egl.GetProcAddress )
return NULL;
return egl.GetProcAddress( name );
}
void GL_UpdateSwapInterval( void )
{
// disable VSync while level is loading
if( cls.state < ca_active )
{
Android_SwapInterval( 0 );
SetBits( gl_vsync->flags, FCVAR_CHANGED );
}
else if( FBitSet( gl_vsync->flags, FCVAR_CHANGED ))
{
ClearBits( gl_vsync->flags, FCVAR_CHANGED );
Android_SwapInterval( gl_vsync->value );
}
}
void *SW_LockBuffer( void )
{
ANativeWindow_Buffer buffer;
if( !nw.lock || !vid_android.window )
return NULL;
if( nw.lock( vid_android.window, &buffer, NULL ) )
return NULL;
if( buffer.width < refState.width || buffer.height < refState.height )
return NULL;
return buffer.bits;
}
void SW_UnlockBuffer( void )
{
if( nw.unlockAndPost )
nw.unlockAndPost( vid_android.window );
}
qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b )
{
ANativeWindow_Buffer buffer;
int lock;
if( !nw.lock || !vid_android.window )
return false;
nw.unlockAndPost( vid_android.window );
if( ( lock = nw.lock( vid_android.window, &buffer, NULL ) ) )
{
Con_Printf( "SW_CreateBuffer: lock %d\n", lock );
return false;
}
nw.unlockAndPost( vid_android.window );
Con_Printf( "SW_CreateBuffer: buffer %d %d %x %d %p\n", buffer.width, buffer.height, buffer.format, buffer.stride, buffer.bits );
if( width > buffer.width || height > buffer.height )
{
Con_Printf( "SW_CreateBuffer: buffer too small %d %d\n", width, height );
// resize event missed?
if( jni.width < buffer.width )
jni.width = buffer.width;
if( jni.height < buffer.height )
jni.width = buffer.height;
VID_SetMode();
Android_UpdateSurface( 1 );
return false;
}
if( buffer.format != WINDOW_FORMAT_RGB_565 )
{
Con_Printf( "SW_CreateBuffer: wrong format %d\n", buffer.format );
return false;
}
Con_Printf( "SW_CreateBuffer: ok\n" );
*stride = buffer.stride;
*bpp = 2;
*r = (((1 << 5) - 1) << (5+6));
*g = (((1 << 6) - 1) << (5));
*b = (((1 << 5) - 1) << (0));
return true;
}

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