mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 11:35:05 +08:00
Compare commits
207 Commits
abi2_proto
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98acbbad01 | ||
|
|
eb72b6baee | ||
|
|
422addcbb6 | ||
|
|
4a58be2aa0 | ||
|
|
562b54839c | ||
|
|
639eaa9416 | ||
|
|
6c6cb65b30 | ||
|
|
8ea8437e19 | ||
|
|
2656eb1aeb | ||
|
|
fa1e92b127 | ||
|
|
cff8ee13e6 | ||
|
|
3956e3863e | ||
|
|
9600218757 | ||
|
|
2db7cb0d64 | ||
|
|
267a70d621 | ||
|
|
667bedab82 | ||
|
|
49990a0859 | ||
|
|
f7c4cd9398 | ||
|
|
cd4f4d5ad4 | ||
|
|
fe429fe213 | ||
|
|
0a24ca3fe2 | ||
|
|
8c93a0d247 | ||
|
|
5c75dda864 | ||
|
|
55bdded6a4 | ||
|
|
25b2c0f7e3 | ||
|
|
ed522852cf | ||
|
|
224e42d345 | ||
|
|
128a1f59a9 | ||
|
|
40ffde0439 | ||
|
|
ec5578a437 | ||
|
|
1cf40a2d17 | ||
|
|
958ea0ac1d | ||
|
|
a9fdae28b2 | ||
|
|
3d9eb869b0 | ||
|
|
8162c6d42f | ||
|
|
48a9f17222 | ||
|
|
e381d04094 | ||
|
|
0e79326571 | ||
|
|
f7eb8cd913 | ||
|
|
a15c1f99b2 | ||
|
|
ba2191172d | ||
|
|
6ab2c9dbbf | ||
|
|
7da460d4b1 | ||
|
|
ffe7b1f4a1 | ||
|
|
6a1f502d25 | ||
|
|
434359ea01 | ||
|
|
ae2ad6ddf2 | ||
|
|
ec11683dc5 | ||
|
|
47318b0c14 | ||
|
|
60d6214ad7 | ||
|
|
a3e26a21a7 | ||
|
|
d0f3a6f74b | ||
|
|
fee236a050 | ||
|
|
e3e4bcc015 | ||
|
|
2d546ccbf7 | ||
|
|
b41804bb5b | ||
|
|
47a04df189 | ||
|
|
2efedaf46c | ||
|
|
49e43c830b | ||
|
|
763e101208 | ||
|
|
e39a62b1fd | ||
|
|
da76abda75 | ||
|
|
829d7d0a7e | ||
|
|
9f6372b305 | ||
|
|
12edd782c6 | ||
|
|
0b59fa9416 | ||
|
|
cc0f12ed26 | ||
|
|
f42553d0e1 | ||
|
|
e7564420c9 | ||
|
|
e81a0ded11 | ||
|
|
a32c702dbd | ||
|
|
23a5ed71de | ||
|
|
245dc97cfb | ||
|
|
ece204c30f | ||
|
|
1bd59096fd | ||
|
|
0b02c2c6a7 | ||
|
|
6a61a499e9 | ||
|
|
6b1c283082 | ||
|
|
5402a9611e | ||
|
|
43e06ccd45 | ||
|
|
f52c825bf5 | ||
|
|
bf8b709372 | ||
|
|
fdf82e5270 | ||
|
|
0224a1b66b | ||
|
|
505ad6d69b | ||
|
|
5bcd573821 | ||
|
|
c5a291d9c7 | ||
|
|
232a8c1148 | ||
|
|
663f6eaf5c | ||
|
|
9d3210259c | ||
|
|
4ec6c2f7cf | ||
|
|
8452bec877 | ||
|
|
0d4296e0e1 | ||
|
|
2b85da3bc9 | ||
|
|
17f194b9a3 | ||
|
|
ff47fbaedc | ||
|
|
87c88f7463 | ||
|
|
60fd5f7ab8 | ||
|
|
5ceab059dc | ||
|
|
67c898f9ad | ||
|
|
d903187eea | ||
|
|
653f0841e4 | ||
|
|
10bfadb556 | ||
|
|
0b2cc066dd | ||
|
|
60ab13d216 | ||
|
|
f90c658567 | ||
|
|
0c54895877 | ||
|
|
4eb54328f8 | ||
|
|
b1189db9c5 | ||
|
|
869578f1ba | ||
|
|
3320f776ce | ||
|
|
1d64635783 | ||
|
|
bbb076c0d4 | ||
|
|
fe2a4d0428 | ||
|
|
6bdc1941e6 | ||
|
|
9188905145 | ||
|
|
3f2fbb10d8 | ||
|
|
9c97235fe8 | ||
|
|
70a13b47db | ||
|
|
18afaf0eaf | ||
|
|
8b8c3d8116 | ||
|
|
514fc9fe43 | ||
|
|
5d8923d69c | ||
|
|
5db880af57 | ||
|
|
c05db9ce58 | ||
|
|
04079abe00 | ||
|
|
8054b69f73 | ||
|
|
b5ee777466 | ||
|
|
96f3061709 | ||
|
|
420c5a4ff3 | ||
|
|
e8f6476e8c | ||
|
|
65ec35b732 | ||
|
|
8d731b5d15 | ||
|
|
38c0dc4551 | ||
|
|
4d8cb0469f | ||
|
|
62cb8f5ba6 | ||
|
|
97c75d96d5 | ||
|
|
f5ae806b31 | ||
|
|
482dc3a5a5 | ||
|
|
a8539ac004 | ||
|
|
9970c56218 | ||
|
|
480218412a | ||
|
|
6ae09d2866 | ||
|
|
609680b328 | ||
|
|
ccbe370c8e | ||
|
|
9706e47643 | ||
|
|
d98361f782 | ||
|
|
ba7c789ec9 | ||
|
|
d128997d40 | ||
|
|
61342547ce | ||
|
|
c1a5f173b8 | ||
|
|
f5c5b7b2c8 | ||
|
|
057b47555d | ||
|
|
43299f6747 | ||
|
|
03bf6cb719 | ||
|
|
3a1bb12830 | ||
|
|
5efa68757e | ||
|
|
afaf5bf3ea | ||
|
|
50c805826f | ||
|
|
35ae9f4a64 | ||
|
|
d7d96c02a2 | ||
|
|
dd03723144 | ||
|
|
26f07196ea | ||
|
|
8c291fdfe3 | ||
|
|
d1e118f07c | ||
|
|
6c531c14e6 | ||
|
|
433213c915 | ||
|
|
ab0c0b18c2 | ||
|
|
29fd5f9fbe | ||
|
|
882d8afc93 | ||
|
|
e11635d15c | ||
|
|
5d79d93aac | ||
|
|
7ccf651fd0 | ||
|
|
67af41cce8 | ||
|
|
e2c96e62e1 | ||
|
|
2ecae442fc | ||
|
|
a1060b0eb5 | ||
|
|
ddd8de888f | ||
|
|
a758dffbc1 | ||
|
|
87775faeca | ||
|
|
ef0fc46ed8 | ||
|
|
138b4fa247 | ||
|
|
47d1f3459c | ||
|
|
4712aae834 | ||
|
|
2900ee1cde | ||
|
|
c6c4178dd2 | ||
|
|
a3ce0e6b1b | ||
|
|
0b1ad3b7f0 | ||
|
|
37fb46f092 | ||
|
|
bc8bf9a9fb | ||
|
|
9e28c98911 | ||
|
|
0a1269d52d | ||
|
|
2e5bc31c9e | ||
|
|
1b335fd945 | ||
|
|
0c8b2d007a | ||
|
|
9ee1b32e2d | ||
|
|
953ad98a16 | ||
|
|
1357057bd8 | ||
|
|
35c9323de6 | ||
|
|
13a0afef06 | ||
|
|
c7ad8e4bf6 | ||
|
|
f1754bdd5f | ||
|
|
c462a1c500 | ||
|
|
0bba184994 | ||
|
|
178602ea1f | ||
|
|
2eb8f88a20 | ||
|
|
96d11df06c |
@@ -5,6 +5,7 @@ packages:
|
||||
- freetype-dev
|
||||
- fontconfig-dev
|
||||
- opus-dev
|
||||
- bzip2-dev
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
|
||||
@@ -7,6 +7,7 @@ packages:
|
||||
- libfreetype-dev
|
||||
- libfontconfig-dev
|
||||
- libopus-dev
|
||||
- libbz2-dev
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
|
||||
@@ -6,6 +6,7 @@ packages:
|
||||
- libfreetype-dev
|
||||
- libfontconfig-dev
|
||||
- libopus-dev
|
||||
- libbz2-dev
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
|
||||
@@ -6,6 +6,7 @@ packages:
|
||||
- print/freetype2
|
||||
- x11-fonts/fontconfig
|
||||
- audio/opus
|
||||
- archivers/bzip2
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
|
||||
@@ -6,6 +6,7 @@ packages:
|
||||
- fontconfig
|
||||
- libopus
|
||||
- pkgconf
|
||||
- bzip2
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
|
||||
@@ -3,6 +3,7 @@ packages:
|
||||
- python3
|
||||
- sdl2
|
||||
- opus
|
||||
- bzip2
|
||||
sources:
|
||||
- https://git.sr.ht/~a1batross/xash3d-fwgs
|
||||
tasks:
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -342,3 +342,6 @@ enc_temp_folder/
|
||||
|
||||
# KDevelop4
|
||||
*.kdev4
|
||||
|
||||
# ccls langauge server
|
||||
.ccls-*
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -19,3 +19,9 @@
|
||||
[submodule "3rdparty/xash-extras"]
|
||||
path = 3rdparty/extras/xash-extras
|
||||
url = https://github.com/FWGS/xash-extras
|
||||
[submodule "3rdparty/bzip2/bzip2"]
|
||||
path = 3rdparty/bzip2/bzip2
|
||||
url = https://gitlab.com/bzip2/bzip2
|
||||
[submodule "3rdparty/MultiEmulator"]
|
||||
path = 3rdparty/MultiEmulator
|
||||
url = https://github.com/FWGS/MultiEmulator
|
||||
|
||||
1
3rdparty/MultiEmulator
vendored
Submodule
1
3rdparty/MultiEmulator
vendored
Submodule
Submodule 3rdparty/MultiEmulator added at 2f3c3a40cd
1
3rdparty/bzip2/bz_version.h
vendored
Normal file
1
3rdparty/bzip2/bz_version.h
vendored
Normal file
@@ -0,0 +1 @@
|
||||
#define BZ_VERSION "1.1.0-fwgs"
|
||||
1
3rdparty/bzip2/bzip2
vendored
Submodule
1
3rdparty/bzip2/bzip2
vendored
Submodule
Submodule 3rdparty/bzip2/bzip2 added at 66c46b8c94
34
3rdparty/bzip2/wscript
vendored
Normal file
34
3rdparty/bzip2/wscript
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
def options(opt):
|
||||
pass
|
||||
|
||||
def configure(conf):
|
||||
conf.define('_GNU_SOURCE', 1)
|
||||
conf.define('BZ_NO_STDIO', 1)
|
||||
|
||||
if conf.env.DEST_OS == 'win32':
|
||||
conf.define('BZ_LCCWIN32', 1)
|
||||
else:
|
||||
conf.define('BZ_UNIX', 1)
|
||||
|
||||
def build(bld):
|
||||
# doesn't work with CMake generator
|
||||
# bld(
|
||||
# features = 'subst',
|
||||
# source = 'bzip2/bz_version.h.in',
|
||||
# target = 'bz_version.h',
|
||||
# BZ_VERSION='1.1.0-fwgs'
|
||||
# )
|
||||
|
||||
bz_sources = ['bzip2/blocksort.c', 'bzip2/huffman.c', 'bzip2/crctable.c', 'bzip2/randtable.c', 'bzip2/compress.c', 'bzip2/decompress.c', 'bzip2/bzlib.c']
|
||||
|
||||
bld.stlib(
|
||||
source = bz_sources,
|
||||
target = 'bzip2',
|
||||
# use = 'bz_version.h',
|
||||
includes = ['.', 'bzip2/'],
|
||||
subsystem = bld.env.MSVC_SUBSYSTEM,
|
||||
export_includes = ['bzip2/']
|
||||
)
|
||||
2
3rdparty/extras/xash-extras
vendored
2
3rdparty/extras/xash-extras
vendored
Submodule 3rdparty/extras/xash-extras updated: f4ff263d42...9050d05a7b
2
3rdparty/gl-wes-v2
vendored
2
3rdparty/gl-wes-v2
vendored
Submodule 3rdparty/gl-wes-v2 updated: 2d9b5afe10...d4ed038d13
1
3rdparty/gl4es/wscript
vendored
1
3rdparty/gl4es/wscript
vendored
@@ -16,7 +16,6 @@ def build(bld):
|
||||
|
||||
bld.stlib(source = gl4es_srcdir.ant_glob(['gl/*.c', 'gl/*/*.c', 'glx/hardext.c']),
|
||||
target = 'gl4es',
|
||||
features = 'c',
|
||||
includes = ['gl4es/src', 'gl4es/src/gl', 'gl4es/src/glx', 'gl4es/include'],
|
||||
defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'NO_LOADER', 'STATICLIB'],
|
||||
cflags = ['-w', '-fvisibility=hidden', '-std=gnu99'],
|
||||
|
||||
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: b7edbaf2de...0bb921ea8d
2
3rdparty/nanogl
vendored
2
3rdparty/nanogl
vendored
Submodule 3rdparty/nanogl updated: e75792de03...6c0f341b7b
2
3rdparty/opus/opus
vendored
2
3rdparty/opus/opus
vendored
Submodule 3rdparty/opus/opus updated: 8cf872a186...82ac57d9f1
2
3rdparty/opus/wscript
vendored
2
3rdparty/opus/wscript
vendored
@@ -27,7 +27,7 @@ def build(bld):
|
||||
'opus/celt/opus_custom_demo.c'
|
||||
])
|
||||
includes = ['opus/include/', 'opus/celt/', 'opus/silk/', 'opus/silk/float/']
|
||||
defines = ['USE_ALLOCA', 'OPUS_BUILD', 'FLOAT_APPROX', 'PACKAGE_VERSION="1.3.1"', 'CUSTOM_MODES']
|
||||
defines = ['USE_ALLOCA', 'OPUS_BUILD', 'FLOAT_APPROX', 'PACKAGE_VERSION="1.4.0"', 'CUSTOM_MODES']
|
||||
|
||||
bld.stlib(
|
||||
source = sources,
|
||||
|
||||
2
3rdparty/vgui_support
vendored
2
3rdparty/vgui_support
vendored
Submodule 3rdparty/vgui_support updated: 7276993f3f...e0ab95229d
@@ -14,3 +14,4 @@ When `-bugcomp` is specified with argument, it interpreted as flags separated wi
|
||||
| ------- | ----------- | ---------------------------- |
|
||||
| `peoei` | Reverts `pfnPEntityOfEntIndex` behavior to GoldSrc, where it returns NULL for last player due to incorrect player index comparison | * Counter-Strike: Condition Zero - Deleted Scenes |
|
||||
| `gsmrf` | Rewrites message at the moment when Game DLL attempts to write an internal engine message, usually specific to GoldSrc protocol. Right now only supports `svc_spawnstaticsound`, more messages added by request. | * MetaMod/AMXModX based mods |
|
||||
| `sp_attn_none` | Makes sounds with attenuation zero spatialized, i.e. have a stereo effect. | Possibly, every game that was made for GoldSrc. |
|
||||
|
||||
14
Documentation/goldsrc-protocol-support.md
Normal file
14
Documentation/goldsrc-protocol-support.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Support for GoldSrc network protocol
|
||||
This feature is still work-in-progress, but for now it's available for all users, and we appreciate any bug-reports and contributions around it.
|
||||
|
||||
For connecting to GoldSrc-based servers, use this command:
|
||||
```
|
||||
connect ip:port gs
|
||||
```
|
||||
|
||||
But keep in mind, there are requirement for server to be able to accept connections from Xash3D-based clients: it should accept HLTV connections.
|
||||
Without this requirement, you will just get "Steam validation rejected" error on connecting.
|
||||
|
||||
That is because proper authorization with Steam API is not implemented in engine yet (but we have plans on it).
|
||||
|
||||
In case of ReHLDS with Reunion plugin, by default it rejects HLTV clients. But connections from HLTV can be easily enabled in `reunion.cfg` file.
|
||||
62
README.md
62
README.md
@@ -11,12 +11,12 @@ Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://ww
|
||||
If you like Xash3D FWGS, consider supporting individual engine maintainers. By supporting us, you help to continue developing this game engine further. The sponsorship links are available in [documentation](Documentation/donate.md).
|
||||
|
||||
## Fork features
|
||||
* Steam Half-Life (HLSDK 2.4) support.
|
||||
* Steam Half-Life (HLSDK 2.5) support.
|
||||
* Crossplatform and modern compilers support: supports Windows, Linux, BSD & Android on x86 & ARM and [many more](Documentation/ports.md).
|
||||
* Better multiplayer support: multiple master servers, headless dedicated server, voice chat and IPv6 support.
|
||||
* Better multiplayer: multiple master servers, headless dedicated server, voice chat, [GoldSrc protocol support](Documentation/goldsrc-protocol-support.md) and IPv6 support.
|
||||
* Multiple renderers support: OpenGL, GLESv1, GLESv2 and Software.
|
||||
* Advanced virtual filesystem: `.pk3` and `.pk3dir` support, compatibility with GoldSrc FS module, fast case-insensitivity emulation for crossplatform.
|
||||
* Mobility API: better game integration on mobile devices (vibration, touch controls)
|
||||
* Mobility API: better game integration on mobile devices (vibration, touch controls).
|
||||
* Different input methods: touch and gamepad in addition to mouse & keyboard.
|
||||
* TrueType font rendering, as a part of mainui_cpp.
|
||||
* External VGUI support module.
|
||||
@@ -35,17 +35,16 @@ You still needed to copy `valve` directory as all game resources located there.
|
||||
For additional info, run Xash3D with `-help` command line key.
|
||||
|
||||
## Contributing
|
||||
* Before sending an issue, check if someone already reported your issue. Make sure you're following "How To Ask Questions The Smart Way" guide by Eric Steven Raymond. Read more: http://www.catb.org/~esr/faqs/smart-questions.html
|
||||
* Issues are accepted in both English and Russian
|
||||
* Before sending an issue, check if someone already reported your issue. Make sure you're following "How To Ask Questions The Smart Way" guide by Eric Steven Raymond. Read more: http://www.catb.org/~esr/faqs/smart-questions.html.
|
||||
* Issues are accepted in both English and Russian.
|
||||
* Before sending a PR, check if you followed our contribution guide in CONTRIBUTING.md file.
|
||||
|
||||
## Build instructions
|
||||
We are using Waf build system. If you have some Waf-related questions, I recommend you to read https://waf.io/book/
|
||||
We are using Waf build system. If you have some Waf-related questions, I recommend you to read [Waf Book](https://waf.io/book/).
|
||||
|
||||
NOTE: NEVER USE GitHub's ZIP ARCHIVES. GitHub doesn't include external dependencies we're using!
|
||||
|
||||
### Prerequisites
|
||||
|
||||
If your CPU is x86 compatible and you're on Windows or Linux, we are building 32-bit code by default. This was done to maintain compatibility with Steam releases of Half-Life and based on it's engine games.
|
||||
Even if Xash3D FWGS does support targetting 64-bit, you can't load games without recompiling them from source code!
|
||||
|
||||
@@ -62,31 +61,40 @@ This repository contains our fork of HLSDK and restored source code for Half-Lif
|
||||
|
||||
#### GNU/Linux
|
||||
##### Debian/Ubuntu
|
||||
* Enable i386 on your system, if you're compiling 32-bit engine on amd64. If not, skip this
|
||||
* Only for 32-bit engine on 64-bit x86 operating system:
|
||||
* Enable i386 on your system: `$ sudo dpkg --add-architecture i386`.
|
||||
* Install `aptitude` ([why?](https://github.com/FWGS/xash3d-fwgs/issues/1828#issuecomment-2415131759)): `$ sudo apt update && sudo apt upgrade && sudo apt install aptitude`
|
||||
* Install development tools: `$ sudo aptitude --without-recommends install git build-essential gcc-multilib g++-multilib libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype-dev:i386 libopus-dev:i386 libbz2-dev:i386`.
|
||||
* Set PKG_CONFIG_PATH environment variable to point at 32-bit libraries: `$ export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig`.
|
||||
|
||||
`$ sudo dpkg --add-architecture i386`
|
||||
* Install development tools
|
||||
* For 32-bit engine on amd64: \
|
||||
`$ sudo apt install build-essential gcc-multilib g++-multilib python libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-dev:i386`
|
||||
* For everything else: \
|
||||
`$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev`
|
||||
* Clone this repostory:
|
||||
`$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`
|
||||
* For 64-bit engine on 64-bit x86 and other non-x86 systems:
|
||||
* Install development tools: `$ sudo apt install git build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev libopus-dev libbz2-dev`.
|
||||
|
||||
* Clone this repostory: `$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`.
|
||||
|
||||
##### RedHat/Fedora
|
||||
* Only for 32-bit engine on 64-bit x86 operating system:
|
||||
* Install development tools: `$ sudo dnf install git gcc gcc-c++ glibc-devel.i686 SDL2-devel.i686 opus-devel.i686 fontconfig-devel.i686 freetype-devel.i686 bzip2-devel.i686`.
|
||||
* Set PKG_CONFIG_PATH environment variable to point at 32-bit libraries: `$ export PKG_CONFIG_PATH=/usr/lib/pkgconfig`.
|
||||
|
||||
* For 64-bit engine on 64-bit x86 and other non-x86 systems:
|
||||
* Install development tools: `$ sudo dnf install git gcc gcc-c++ SDL2-devel opus-devel fontconfig-devel freetype-devel bzip2-devel`.
|
||||
|
||||
* Clone this repostory: `$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`.
|
||||
|
||||
### Building
|
||||
#### Windows (Visual Studio)
|
||||
0) Open command line
|
||||
0) Open command line.
|
||||
1) Navigate to `xash3d-fwgs` directory.
|
||||
2) Carefully examine which build options are available: `waf --help`
|
||||
3) Configure build: `waf configure -T release --sdl2=c:/path/to/SDL2`
|
||||
4) Compile: `waf build`
|
||||
5) Install: `waf install --destdir=c:/path/to/any/output/directory`
|
||||
2) (optional) Examine which build options are available: `waf --help`.
|
||||
3) Configure build: `waf configure --sdl2=c:/path/to/SDL2`.
|
||||
4) Compile: `waf build`.
|
||||
5) Install: `waf install --destdir=c:/path/to/any/output/directory`.
|
||||
|
||||
#### Linux
|
||||
If compiling 32-bit on amd64, you may need to supply `export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig` prior to running configure.
|
||||
If compiling 32-bit on amd64, make sure `PKG_CONFIG_PATH` from the previous step is set correctly, prior to running configure.
|
||||
|
||||
0) Examine which build options are available: `./waf --help`
|
||||
1) Configure build: `./waf configure -T release`
|
||||
(You need to pass `-8` to compile 64-bit engine on 64-bit x86 processor)
|
||||
2) Compile: `./waf build`
|
||||
3) Install(optional): `./waf install --destdir=/path/to/any/output/directory`
|
||||
0) (optional) Examine which build options are available: `./waf --help`.
|
||||
1) Configure build: `./waf configure` (you need to pass `-8` to compile 64-bit engine on 64-bit x86 processor).
|
||||
2) Compile: `./waf build`.
|
||||
3) Install: `./waf install --destdir=/path/to/any/output/directory`.
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
****/
|
||||
#ifndef CONST_H
|
||||
#define CONST_H
|
||||
|
||||
#include <stddef.h> // ptrdiff_t
|
||||
|
||||
//
|
||||
// Constants shared by the engine and dlls
|
||||
// This header file included by engine files and DLL files.
|
||||
@@ -724,7 +721,7 @@ enum
|
||||
};
|
||||
|
||||
typedef int func_t;
|
||||
typedef ptrdiff_t string_t;
|
||||
typedef int string_t;
|
||||
|
||||
typedef unsigned short word;
|
||||
|
||||
|
||||
@@ -79,11 +79,22 @@ typedef uint64_t longtime_t;
|
||||
#define GAME_EXPORT
|
||||
#endif
|
||||
|
||||
#define MALLOC __attribute__(( malloc ))
|
||||
|
||||
// added in GCC 11
|
||||
#if __GNUC__ >= 11
|
||||
// might want to set noclone due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116893
|
||||
// but it's easier to not force mismatched-dealloc to error yet
|
||||
#define MALLOC_LIKE( x, y ) __attribute__(( malloc( x, y )))
|
||||
#else
|
||||
#define MALLOC_LIKE( x, y ) MALLOC
|
||||
#endif
|
||||
#define NORETURN __attribute__(( noreturn ))
|
||||
#define NONNULL __attribute__(( nonnull ))
|
||||
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
|
||||
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
|
||||
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
|
||||
#define WARN_UNUSED_RESULT __attribute__(( warn_unused_result ))
|
||||
#define RENAME_SYMBOL( x ) asm( x )
|
||||
#else
|
||||
#if defined( _MSC_VER )
|
||||
@@ -99,6 +110,9 @@ typedef uint64_t longtime_t;
|
||||
#define _format( x )
|
||||
#define ALLOC_CHECK( x )
|
||||
#define RENAME_SYMBOL( x )
|
||||
#define MALLOC
|
||||
#define MALLOC_LIKE( x, y )
|
||||
#define WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
|
||||
@@ -146,7 +146,7 @@ void CL_PlayCDTrack_f( void )
|
||||
if( paused ) Con_Printf( "Paused %s track %u\n", looped ? "looping" : "playing", track );
|
||||
else Con_Printf( "Currently %s track %u\n", looped ? "looping" : "playing", track );
|
||||
}
|
||||
Con_Printf( "Volume is %f\n", Cvar_VariableValue( "MP3Volume" ));
|
||||
Con_Printf( "Volume is %f\n", s_musicvolume.value );
|
||||
return;
|
||||
}
|
||||
else Con_Printf( "%s: unknown command %s\n", Cmd_Argv( 0 ), command );
|
||||
@@ -274,6 +274,13 @@ void CL_GenericShot_f( void )
|
||||
string checkname;
|
||||
int i;
|
||||
|
||||
// allow overriding screenshot by users request
|
||||
if( Cmd_Argc() > 1 )
|
||||
{
|
||||
Q_strncpy( cls.shotname, Cmd_Argv( 1 ), sizeof( cls.shotname ));
|
||||
break;
|
||||
}
|
||||
|
||||
if( type == scrshot_snapshot )
|
||||
{
|
||||
fmt = "../%s_%04d.png";
|
||||
|
||||
@@ -50,7 +50,7 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
|
||||
|
||||
if( !cl_allow_download.value )
|
||||
{
|
||||
Con_Reportf( "Download refused, cl_allow_download is 0\n" );
|
||||
Con_Reportf( "Download refused, cl_allowdownload is 0\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
|
||||
|
||||
if( cl.http_download )
|
||||
{
|
||||
HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
|
||||
HTTP_AddDownload( filepath, pResource->nDownloadSize, true, pResource );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -40,6 +40,8 @@ GNU General Public License for more details.
|
||||
#define IDEMOHEADER (('M'<<24)+('E'<<16)+('D'<<8)+'I') // little-endian "IDEM"
|
||||
#define DEMO_PROTOCOL 3
|
||||
|
||||
#define PROTOCOL_GOLDSRC_VERSION_DEMO (PROTOCOL_GOLDSRC_VERSION | (BIT( 7 ))) // should be 48, only to differentiate it from PROTOCOL_LEGACY_VERSION
|
||||
|
||||
const char *demo_cmd[dem_lastcmd+1] =
|
||||
{
|
||||
"dem_unknown",
|
||||
@@ -120,7 +122,7 @@ static int CL_GetDemoNetProtocol( connprotocol_t proto )
|
||||
case PROTO_QUAKE:
|
||||
return PROTOCOL_VERSION_QUAKE;
|
||||
case PROTO_GOLDSRC:
|
||||
return PROTOCOL_GOLDSRC_VERSION;
|
||||
return PROTOCOL_GOLDSRC_VERSION_DEMO;
|
||||
}
|
||||
|
||||
return PROTOCOL_VERSION;
|
||||
@@ -136,7 +138,7 @@ static connprotocol_t CL_GetProtocolFromDemo( int net_protocol )
|
||||
return PROTO_LEGACY;
|
||||
case PROTOCOL_VERSION_QUAKE:
|
||||
return PROTO_QUAKE;
|
||||
case PROTOCOL_GOLDSRC_VERSION:
|
||||
case PROTOCOL_GOLDSRC_VERSION_DEMO:
|
||||
return PROTO_GOLDSRC;
|
||||
}
|
||||
|
||||
@@ -283,7 +285,7 @@ void CL_WriteDemoUserCmd( int cmdnumber )
|
||||
|
||||
// write usercmd_t
|
||||
MSG_Init( &buf, "UserCmd", data, sizeof( data ));
|
||||
CL_WriteUsercmd( &buf, -1, cmdnumber ); // always no delta
|
||||
CL_WriteUsercmd( PROTO_CURRENT, &buf, -1, cmdnumber ); // always no delta, always in current protocol
|
||||
|
||||
bytes = MSG_GetNumBytesWritten( &buf );
|
||||
|
||||
@@ -706,7 +708,7 @@ static void CL_DemoStartPlayback( int mode )
|
||||
|
||||
demo.starttime = CL_GetDemoPlaybackClock(); // for determining whether to read another message
|
||||
|
||||
Netchan_Setup( NS_CLIENT, &cls.netchan, net_from, Cvar_VariableInteger( "net_qport" ), NULL, CL_GetFragmentSize );
|
||||
CL_SetupNetchanForProtocol( cls.legacymode );
|
||||
|
||||
memset( demo.cmds, 0, sizeof( demo.cmds ));
|
||||
demo.angle_position = 1;
|
||||
@@ -1468,7 +1470,7 @@ static qboolean CL_ParseDemoHeader( const char *callee, const char *filename, fi
|
||||
return false;
|
||||
}
|
||||
|
||||
if( hdr->net_protocol != PROTOCOL_VERSION && hdr->net_protocol != PROTOCOL_LEGACY_VERSION )
|
||||
if( hdr->net_protocol != PROTOCOL_VERSION && hdr->net_protocol != PROTOCOL_LEGACY_VERSION && hdr->net_protocol != PROTOCOL_GOLDSRC_VERSION_DEMO )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: net protocol outdated (%i should be %i or %i)\n",
|
||||
callee, hdr->net_protocol, PROTOCOL_VERSION, PROTOCOL_LEGACY_VERSION );
|
||||
|
||||
@@ -25,13 +25,16 @@ 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" );
|
||||
|
||||
particle_t *cl_active_particles;
|
||||
particle_t *cl_active_tracers;
|
||||
particle_t *cl_free_particles;
|
||||
particle_t *cl_particles = NULL; // particle pool
|
||||
static particle_t *cl_active_particles;
|
||||
static particle_t *cl_active_tracers;
|
||||
static particle_t *cl_free_particles;
|
||||
static particle_t *cl_particles = NULL; // particle pool
|
||||
static vec3_t cl_avelocities[NUMVERTEXNORMALS];
|
||||
static float cl_lasttimewarn = 0.0f;
|
||||
|
||||
// expand debugging BBOX particle hulls by this many units.
|
||||
#define BOX_GAP 0.0f
|
||||
|
||||
/*
|
||||
================
|
||||
R_LookupColor
|
||||
@@ -262,9 +265,9 @@ VIEWBEAMS MANAGEMENT
|
||||
|
||||
==============================================================
|
||||
*/
|
||||
BEAM *cl_active_beams;
|
||||
BEAM *cl_free_beams;
|
||||
BEAM *cl_viewbeams = NULL; // beams pool
|
||||
static BEAM *cl_active_beams;
|
||||
static BEAM *cl_free_beams;
|
||||
static BEAM *cl_viewbeams = NULL; // beams pool
|
||||
|
||||
|
||||
/*
|
||||
@@ -1601,6 +1604,73 @@ void GAME_EXPORT R_RocketTrail( vec3_t start, vec3_t end, int type )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
PM_ParticleLine
|
||||
|
||||
draw line from particles
|
||||
================
|
||||
*/
|
||||
static void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel )
|
||||
{
|
||||
float len, curdist;
|
||||
vec3_t diff, pos;
|
||||
|
||||
// determine distance
|
||||
VectorSubtract( end, start, diff );
|
||||
len = VectorNormalizeLength( diff );
|
||||
curdist = 0;
|
||||
|
||||
while( curdist <= len )
|
||||
{
|
||||
VectorMA( start, curdist, diff, pos );
|
||||
CL_Particle( pos, pcolor, life, 0, zvel );
|
||||
curdist += 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
PM_DrawRectangle
|
||||
|
||||
================
|
||||
*/
|
||||
static void PM_DrawRectangle( const vec3_t tl, const vec3_t bl, const vec3_t tr, const vec3_t br, int pcolor, float life )
|
||||
{
|
||||
PM_ParticleLine( tl, bl, pcolor, life, 0 );
|
||||
PM_ParticleLine( bl, br, pcolor, life, 0 );
|
||||
PM_ParticleLine( br, tr, pcolor, life, 0 );
|
||||
PM_ParticleLine( tr, tl, pcolor, life, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
PM_DrawBBox
|
||||
|
||||
================
|
||||
*/
|
||||
static void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int pcolor, float life )
|
||||
{
|
||||
vec3_t p[8], tmp;
|
||||
float gap = BOX_GAP;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
tmp[0] = (i & 1) ? mins[0] - gap : maxs[0] + gap;
|
||||
tmp[1] = (i & 2) ? mins[1] - gap : maxs[1] + gap ;
|
||||
tmp[2] = (i & 4) ? mins[2] - gap : maxs[2] + gap ;
|
||||
|
||||
VectorAdd( tmp, origin, tmp );
|
||||
VectorCopy( tmp, p[i] );
|
||||
}
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
PM_DrawRectangle( p[boxpnt[i][1]], p[boxpnt[i][0]], p[boxpnt[i][2]], p[boxpnt[i][3]], pcolor, life );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_ParticleLine
|
||||
@@ -1764,25 +1834,6 @@ void GAME_EXPORT R_StreakSplash( const vec3_t pos, const vec3_t dir, int color,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_DebugParticle
|
||||
|
||||
just for debug purposes
|
||||
===============
|
||||
*/
|
||||
void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b )
|
||||
{
|
||||
particle_t *p;
|
||||
|
||||
p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
VectorCopy( pos, p->org );
|
||||
p->color = R_LookupColor( r, g, b );
|
||||
p->die = cl.time + 0.01f;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_Particle
|
||||
|
||||
@@ -380,7 +380,7 @@ CL_ParseReliableEvent
|
||||
|
||||
=============
|
||||
*/
|
||||
void CL_ParseReliableEvent( sizebuf_t *msg )
|
||||
void CL_ParseReliableEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int event_index;
|
||||
event_args_t nullargs, args;
|
||||
@@ -390,11 +390,19 @@ void CL_ParseReliableEvent( sizebuf_t *msg )
|
||||
|
||||
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
||||
|
||||
// reliable events not use delta-compression just null-compression
|
||||
MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
Delta_ReadGSFields( msg, DT_EVENT_T, &nullargs, &args, 0.0f );
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
||||
MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
||||
}
|
||||
|
||||
if( args.entindex > 0 && args.entindex <= cl.maxclients )
|
||||
args.angles[PITCH] *= -3.0f;
|
||||
@@ -409,33 +417,42 @@ CL_ParseEvent
|
||||
|
||||
=============
|
||||
*/
|
||||
void CL_ParseEvent( sizebuf_t *msg )
|
||||
void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int event_index;
|
||||
int i, num_events;
|
||||
int packet_index;
|
||||
event_args_t nullargs, args;
|
||||
const event_args_t nullargs = { 0 };
|
||||
event_args_t args = { 0 };
|
||||
entity_state_t *state;
|
||||
float delay;
|
||||
|
||||
memset( &nullargs, 0, sizeof( nullargs ));
|
||||
memset( &args, 0, sizeof( args ));
|
||||
int entity_bits;
|
||||
|
||||
num_events = MSG_ReadUBitLong( msg, 5 );
|
||||
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
entity_bits = MAX_GOLDSRC_ENTITY_BITS;
|
||||
else if( proto == PROTO_LEGACY )
|
||||
entity_bits = MAX_LEGACY_ENTITY_BITS;
|
||||
else entity_bits = MAX_ENTITY_BITS;
|
||||
|
||||
// parse events queue
|
||||
for( i = 0 ; i < num_events; i++ )
|
||||
{
|
||||
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
packet_index = MSG_ReadUBitLong( msg, cls.legacymode ? MAX_LEGACY_ENTITY_BITS : MAX_ENTITY_BITS );
|
||||
else packet_index = -1;
|
||||
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
{
|
||||
MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
||||
packet_index = MSG_ReadUBitLong( msg, entity_bits );
|
||||
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
{
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
Delta_ReadGSFields( msg, DT_EVENT_T, &nullargs, &args, 0.0f );
|
||||
else MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
||||
}
|
||||
}
|
||||
else packet_index = -1;
|
||||
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
||||
|
||||
@@ -174,7 +174,7 @@ static qboolean CL_EntityCustomLerp( cl_entity_t *e )
|
||||
// INTERPOLATION IN GRAVGUNMOD COOP
|
||||
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
|
||||
case MOVETYPE_TOSS:
|
||||
if( cls.legacymode && e->model && e->model->type == mod_studio )
|
||||
if( cls.legacymode == PROTO_LEGACY && e->model && e->model->type == mod_studio )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -669,9 +669,9 @@ FRAME PARSING
|
||||
|
||||
=========================================================================
|
||||
*/
|
||||
static qboolean CL_ParseEntityNumFromPacket( sizebuf_t *msg, int *newnum )
|
||||
static qboolean CL_ParseEntityNumFromPacket( sizebuf_t *msg, int *newnum, connprotocol_t proto )
|
||||
{
|
||||
if( cls.legacymode )
|
||||
if( proto == PROTO_LEGACY )
|
||||
{
|
||||
*newnum = MSG_ReadWord( msg );
|
||||
if( *newnum == 0 )
|
||||
@@ -694,7 +694,7 @@ CL_FlushEntityPacket
|
||||
Read and ignore whole entity packet.
|
||||
=================
|
||||
*/
|
||||
static void CL_FlushEntityPacket( sizebuf_t *msg )
|
||||
static void CL_FlushEntityPacket( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int newnum;
|
||||
entity_state_t from, to;
|
||||
@@ -707,7 +707,7 @@ static void CL_FlushEntityPacket( sizebuf_t *msg )
|
||||
// read it all, but ignore it
|
||||
while( 1 )
|
||||
{
|
||||
if( !CL_ParseEntityNumFromPacket( msg, &newnum ))
|
||||
if( !CL_ParseEntityNumFromPacket( msg, &newnum, proto ))
|
||||
break; // done
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
@@ -717,6 +717,47 @@ static void CL_FlushEntityPacket( sizebuf_t *msg )
|
||||
}
|
||||
}
|
||||
|
||||
qboolean CL_ValidateDeltaPacket( uint oldpacket, frame_t *oldframe )
|
||||
{
|
||||
int subtracted = ( cls.netchan.incoming_sequence - oldpacket ) & 0xFF;
|
||||
|
||||
if( subtracted == 0 )
|
||||
{
|
||||
Con_NPrintf( 2, "^3Warning:^1 update too old\n^7\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( subtracted >= CL_UPDATE_MASK )
|
||||
{
|
||||
// we can't use this, it is too old
|
||||
Con_NPrintf( 2, "^3Warning:^1 delta frame is too old^7\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if(( cls.next_client_entities - oldframe->first_entity ) > ( cls.num_client_entities - NUM_PACKET_ENTITIES ))
|
||||
{
|
||||
Con_NPrintf( 2, "^3Warning:^1 delta frame is too old^7\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CL_UpdateOldEntNum( int oldindex, frame_t *oldframe, entity_state_t **oldent )
|
||||
{
|
||||
if( !oldframe )
|
||||
{
|
||||
*oldent = NULL;
|
||||
return MAX_ENTNUMBER;
|
||||
}
|
||||
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
return MAX_ENTNUMBER;
|
||||
|
||||
*oldent = &cls.packet_entities[(oldframe->first_entity + oldindex) % cls.num_client_entities];
|
||||
return (*oldent)->number;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_DeltaEntity
|
||||
@@ -787,7 +828,7 @@ An svc_packetentities has just been parsed, deal with the
|
||||
rest of the data stream.
|
||||
==================
|
||||
*/
|
||||
int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta, connprotocol_t proto )
|
||||
{
|
||||
frame_t *newframe, *oldframe;
|
||||
int oldindex, newnum, oldnum;
|
||||
@@ -803,7 +844,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
CL_WriteDemoJumpTime();
|
||||
|
||||
// sentinel count. save it for debug checking
|
||||
if( cls.legacymode )
|
||||
if( proto == PROTO_LEGACY )
|
||||
count = MSG_ReadWord( msg );
|
||||
else count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1;
|
||||
|
||||
@@ -817,32 +858,12 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
|
||||
if( delta )
|
||||
{
|
||||
int subtracted;
|
||||
|
||||
oldpacket = MSG_ReadByte( msg );
|
||||
subtracted = ( cls.netchan.incoming_sequence - oldpacket ) & 0xFF;
|
||||
|
||||
if( subtracted == 0 )
|
||||
{
|
||||
Con_NPrintf( 2, "^3Warning:^1 update too old\n^7\n" );
|
||||
CL_FlushEntityPacket( msg );
|
||||
return playerbytes;
|
||||
}
|
||||
|
||||
if( subtracted >= CL_UPDATE_MASK )
|
||||
{
|
||||
// we can't use this, it is too old
|
||||
Con_NPrintf( 2, "^3Warning:^1 delta frame is too old^7\n" );
|
||||
CL_FlushEntityPacket( msg );
|
||||
return playerbytes;
|
||||
}
|
||||
|
||||
uint oldpacket = MSG_ReadByte( msg );
|
||||
oldframe = &cl.frames[oldpacket & CL_UPDATE_MASK];
|
||||
|
||||
if(( cls.next_client_entities - oldframe->first_entity ) > ( cls.num_client_entities - NUM_PACKET_ENTITIES ))
|
||||
if( !CL_ValidateDeltaPacket( oldpacket, oldframe ))
|
||||
{
|
||||
Con_NPrintf( 2, "^3Warning:^1 delta frame is too old^7\n" );
|
||||
CL_FlushEntityPacket( msg );
|
||||
CL_FlushEntityPacket( msg, proto );
|
||||
return playerbytes;
|
||||
}
|
||||
}
|
||||
@@ -860,27 +881,11 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
|
||||
oldent = NULL;
|
||||
oldindex = 0;
|
||||
|
||||
if( !oldframe )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
|
||||
oldnum = oldent->number;
|
||||
}
|
||||
}
|
||||
oldnum = CL_UpdateOldEntNum( oldindex, oldframe, &oldent );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if( !CL_ParseEntityNumFromPacket( msg, &newnum ))
|
||||
if( !CL_ParseEntityNumFromPacket( msg, &newnum, proto ))
|
||||
break; // done
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
@@ -892,17 +897,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
{
|
||||
// one or more entities from the old packet are unchanged
|
||||
CL_DeltaEntity( msg, newframe, oldnum, oldent, false );
|
||||
oldindex++;
|
||||
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
|
||||
oldnum = oldent->number;
|
||||
}
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
}
|
||||
|
||||
if( oldnum == newnum )
|
||||
@@ -911,17 +906,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
bufStart = MSG_GetNumBytesRead( msg );
|
||||
CL_DeltaEntity( msg, newframe, newnum, oldent, true );
|
||||
if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
oldindex++;
|
||||
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
|
||||
oldnum = oldent->number;
|
||||
}
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -940,17 +925,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
{
|
||||
// one or more entities from the old packet are unchanged
|
||||
CL_DeltaEntity( msg, newframe, oldnum, oldent, false );
|
||||
oldindex++;
|
||||
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
|
||||
oldnum = oldent->number;
|
||||
}
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
}
|
||||
|
||||
if( newframe->num_entities != count && newframe->num_entities != 0 )
|
||||
@@ -972,7 +947,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
|
||||
cls.signon = SIGNONS;
|
||||
|
||||
// Clear loading plaque.
|
||||
CL_SignonReply ();
|
||||
CL_SignonReply( proto );
|
||||
}
|
||||
|
||||
return playerbytes;
|
||||
@@ -1290,7 +1265,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
||||
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
|
||||
// INTERPOLATION IN GRAVGUNMOD COOP
|
||||
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
|
||||
else if( cls.legacymode && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
|
||||
else if( cls.legacymode == PROTO_LEGACY && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
|
||||
{
|
||||
if( !CL_InterpolateModel( ent ))
|
||||
continue;
|
||||
|
||||
@@ -34,10 +34,10 @@ GNU General Public License for more details.
|
||||
#define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
|
||||
#define TEXT_MSGNAME "TextMessage%i"
|
||||
|
||||
char cl_textbuffer[MAX_TEXTCHANNELS][2048];
|
||||
client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS];
|
||||
static char cl_textbuffer[MAX_TEXTCHANNELS][2048];
|
||||
static client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS];
|
||||
|
||||
static dllfunc_t cdll_exports[] =
|
||||
static const dllfunc_t cdll_exports[] =
|
||||
{
|
||||
{ "Initialize", (void **)&clgame.dllFuncs.pfnInitialize },
|
||||
{ "HUD_VidInit", (void **)&clgame.dllFuncs.pfnVidInit },
|
||||
@@ -80,7 +80,7 @@ static dllfunc_t cdll_exports[] =
|
||||
};
|
||||
|
||||
// optional exports
|
||||
static dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and higher
|
||||
static const dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and higher
|
||||
{
|
||||
{ "HUD_GetStudioModelInterface", (void **)&clgame.dllFuncs.pfnGetStudioModelInterface },
|
||||
{ "HUD_DirectorMessage", (void **)&clgame.dllFuncs.pfnDirectorMessage },
|
||||
@@ -140,11 +140,7 @@ returns true if thirdperson is enabled
|
||||
*/
|
||||
qboolean CL_IsThirdPerson( void )
|
||||
{
|
||||
cl.local.thirdperson = clgame.dllFuncs.CL_IsThirdPerson();
|
||||
|
||||
if( cl.local.thirdperson )
|
||||
return true;
|
||||
return false;
|
||||
return clgame.dllFuncs.CL_IsThirdPerson() ? true : false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -252,18 +248,18 @@ static int CL_AdjustXPos( float x, int width, int totalWidth )
|
||||
|
||||
if( x == -1 )
|
||||
{
|
||||
xPos = ( refState.width - width ) * 0.5f;
|
||||
xPos = ( clgame.scrInfo.iWidth - width ) * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( x < 0 )
|
||||
xPos = (1.0f + x) * refState.width - totalWidth; // Alight right
|
||||
xPos = (1.0f + x) * clgame.scrInfo.iWidth - totalWidth; // Alight right
|
||||
else // align left
|
||||
xPos = x * refState.width;
|
||||
xPos = x * clgame.scrInfo.iWidth;
|
||||
}
|
||||
|
||||
if( xPos + width > refState.width )
|
||||
xPos = refState.width - width;
|
||||
if( xPos + width > clgame.scrInfo.iWidth )
|
||||
xPos = clgame.scrInfo.iWidth - width;
|
||||
else if( xPos < 0 )
|
||||
xPos = 0;
|
||||
|
||||
@@ -283,19 +279,19 @@ static int CL_AdjustYPos( float y, int height )
|
||||
|
||||
if( y == -1 ) // centered?
|
||||
{
|
||||
yPos = ( refState.height - height ) * 0.5f;
|
||||
yPos = ( clgame.scrInfo.iHeight - height ) * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Alight bottom?
|
||||
if( y < 0 )
|
||||
yPos = (1.0f + y) * refState.height - height; // Alight bottom
|
||||
yPos = (1.0f + y) * clgame.scrInfo.iHeight - height; // Alight bottom
|
||||
else // align top
|
||||
yPos = y * refState.height;
|
||||
yPos = y * clgame.scrInfo.iHeight;
|
||||
}
|
||||
|
||||
if( yPos + height > refState.height )
|
||||
yPos = refState.height - height;
|
||||
if( yPos + height > clgame.scrInfo.iHeight )
|
||||
yPos = clgame.scrInfo.iHeight - height;
|
||||
else if( yPos < 0 )
|
||||
yPos = 0;
|
||||
|
||||
@@ -1019,7 +1015,8 @@ void CL_DrawHUD( int state )
|
||||
CL_DrawCrosshair ();
|
||||
CL_DrawCenterPrint ();
|
||||
clgame.dllFuncs.pfnRedraw( cl.time, cl.intermission );
|
||||
CL_DrawLoadingOrPaused( cls.pauseIcon );
|
||||
if( showpause.value )
|
||||
CL_DrawLoadingOrPaused( cls.pauseIcon );
|
||||
break;
|
||||
case CL_LOADING:
|
||||
CL_DrawLoadingOrPaused( cls.loadingBar );
|
||||
@@ -3488,7 +3485,7 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
|
||||
nr->flags = flags;
|
||||
|
||||
// local servers request
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "netinfo %i %i %i", FBitSet( flags, FNETAPI_LEGACY_PROTOCOL ) ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION, context, request );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, A2A_NETINFO" %i %i %i", FBitSet( flags, FNETAPI_LEGACY_PROTOCOL ) ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION, context, request );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1303,6 +1303,16 @@ static gameinfo2_t *pfnGetModInfo( int gi_version, int i )
|
||||
return &gameui.modsInfo[i];
|
||||
}
|
||||
|
||||
static int pfnIsCvarReadOnly( const char *name )
|
||||
{
|
||||
convar_t *cv = Cvar_FindVar( name );
|
||||
|
||||
if( !cv )
|
||||
return -1;
|
||||
|
||||
return FBitSet( cv->flags, FCVAR_READ_ONLY ) ? 1 : 0;
|
||||
}
|
||||
|
||||
static ui_extendedfuncs_t gExtendedfuncs =
|
||||
{
|
||||
pfnEnableTextInput,
|
||||
@@ -1318,6 +1328,7 @@ static ui_extendedfuncs_t gExtendedfuncs =
|
||||
&gNetApi,
|
||||
pfnGetGameInfo,
|
||||
pfnGetModInfo,
|
||||
pfnIsCvarReadOnly,
|
||||
};
|
||||
|
||||
void UI_UnloadProgs( void )
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -63,9 +63,9 @@ static byte netcolors[NETGRAPH_NET_COLORS+NETGRAPH_LERP_HEIGHT][4] =
|
||||
// other will be generated through NetGraph_InitColors()
|
||||
};
|
||||
|
||||
static byte sendcolor[4] = { 88, 29, 130, 255 };
|
||||
static byte holdcolor[4] = { 255, 0, 0, 200 };
|
||||
static byte extrap_base_color[4] = { 255, 255, 255, 255 };
|
||||
static const byte sendcolor[4] = { 88, 29, 130, 255 };
|
||||
static const byte holdcolor[4] = { 255, 0, 0, 200 };
|
||||
static const byte extrap_base_color[4] = { 255, 255, 255, 255 };
|
||||
static netbandwidthgraph_t netstat_graph[NET_TIMINGS];
|
||||
static float packet_loss;
|
||||
static float packet_choke;
|
||||
@@ -79,7 +79,7 @@ NetGraph_DrawRect
|
||||
NetGraph_FillRGBA shortcut
|
||||
==========
|
||||
*/
|
||||
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
|
||||
static void NetGraph_DrawRect( const wrect_t *rect, const byte colors[4] )
|
||||
{
|
||||
ref.dllFuncs.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -137,12 +137,7 @@ static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
|
||||
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
|
||||
@@ -269,7 +264,7 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg )
|
||||
|
||||
if( !cl_allow_download.value )
|
||||
{
|
||||
Con_DPrintf( "Refusing new resource, cl_allow_download set to 0\n" );
|
||||
Con_DPrintf( "Refusing new resource, cl_allowdownload set to 0\n" );
|
||||
reslist.rescount = 0;
|
||||
}
|
||||
|
||||
@@ -300,7 +295,7 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg )
|
||||
continue; // already exists
|
||||
|
||||
host.downloadcount++;
|
||||
HTTP_AddDownload( path, -1, true );
|
||||
HTTP_AddDownload( path, -1, true, NULL );
|
||||
}
|
||||
|
||||
if( !host.downloadcount )
|
||||
@@ -320,7 +315,7 @@ dispatch messages
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
{
|
||||
size_t bufStart, playerbytes;
|
||||
int cmd, param1, param2;
|
||||
int cmd;
|
||||
int old_background;
|
||||
const char *s;
|
||||
|
||||
@@ -345,6 +340,9 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
// record command for debugging spew on parse problem
|
||||
CL_Parse_RecordCommand( cmd, bufStart );
|
||||
|
||||
if( CL_ParseCommonDLLMessage( msg, PROTO_LEGACY, cmd, bufStart ))
|
||||
continue;
|
||||
|
||||
// other commands
|
||||
switch( cmd )
|
||||
{
|
||||
@@ -359,7 +357,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
Host_AbortCurrentFrame ();
|
||||
break;
|
||||
case svc_legacy_event:
|
||||
CL_ParseEvent( msg );
|
||||
CL_ParseEvent( msg, PROTO_LEGACY );
|
||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_legacy_changing:
|
||||
@@ -421,7 +419,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
|
||||
break;
|
||||
case svc_time:
|
||||
CL_ParseServerTime( msg );
|
||||
CL_ParseServerTime( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_print:
|
||||
Con_Printf( "%s", MSG_ReadString( msg ));
|
||||
@@ -446,19 +444,19 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
break;
|
||||
case svc_serverdata:
|
||||
Cbuf_Execute(); // make sure any stuffed commands are done
|
||||
CL_ParseServerData( msg, true );
|
||||
CL_ParseServerData( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_lightstyle:
|
||||
CL_ParseLightStyle( msg );
|
||||
CL_ParseLightStyle( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_updateuserinfo:
|
||||
CL_UpdateUserinfo( msg, true );
|
||||
CL_UpdateUserinfo( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_deltatable:
|
||||
Delta_ParseTableField( msg );
|
||||
break;
|
||||
case svc_clientdata:
|
||||
CL_ParseClientData( msg );
|
||||
CL_ParseClientData( msg, PROTO_LEGACY );
|
||||
cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_resource:
|
||||
@@ -468,82 +466,58 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
CL_UpdateUserPings( msg );
|
||||
break;
|
||||
case svc_particle:
|
||||
CL_ParseParticles( msg );
|
||||
CL_ParseParticles( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_restoresound:
|
||||
CL_ParseRestoreSoundPacket( msg );
|
||||
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
Con_Printf( S_ERROR "%s: svc_restoresound: implement me!\n", __func__ );
|
||||
break;
|
||||
case svc_spawnstatic:
|
||||
CL_LegacyParseStaticEntity( msg );
|
||||
break;
|
||||
case svc_event_reliable:
|
||||
CL_ParseReliableEvent( msg );
|
||||
CL_ParseReliableEvent( msg, PROTO_LEGACY );
|
||||
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;
|
||||
CL_ParseBaseline( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_setpause:
|
||||
cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
|
||||
break;
|
||||
case svc_signonnum:
|
||||
CL_ParseSignon( msg );
|
||||
CL_ParseSignon( msg, PROTO_LEGACY );
|
||||
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 );
|
||||
CL_RegisterUserMessage( msg, PROTO_LEGACY );
|
||||
break;
|
||||
case svc_packetentities:
|
||||
playerbytes = CL_ParsePacketEntities( msg, false );
|
||||
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_LEGACY );
|
||||
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 );
|
||||
playerbytes = CL_ParsePacketEntities( msg, true, PROTO_LEGACY );
|
||||
cl.frames[cl.parsecountmod].graphdata.players += playerbytes;
|
||||
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
|
||||
break;
|
||||
@@ -590,9 +564,6 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
case svc_hltv:
|
||||
CL_ParseHLTV( msg );
|
||||
break;
|
||||
case svc_director:
|
||||
CL_ParseDirector( msg );
|
||||
break;
|
||||
case svc_resourcelocation:
|
||||
CL_ParseResLocation( msg );
|
||||
break;
|
||||
@@ -603,7 +574,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||
CL_ParseCvarValue( msg, true, PROTO_LEGACY );
|
||||
break;
|
||||
default:
|
||||
CL_ParseUserMessage( msg, cmd );
|
||||
CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
|
||||
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
}
|
||||
@@ -615,7 +586,7 @@ void CL_LegacyPrecache_f( void )
|
||||
int spawncount, i;
|
||||
model_t *mod;
|
||||
|
||||
if( !cls.legacymode )
|
||||
if( cls.legacymode != PROTO_LEGACY )
|
||||
return;
|
||||
|
||||
spawncount = Q_atoi( Cmd_Argv( 1 ));
|
||||
@@ -658,8 +629,3 @@ void CL_LegacyPrecache_f( void )
|
||||
MSG_WriteStringf( &cls.netchan.message, "begin %i", spawncount );
|
||||
cls.signon = SIGNONS - 1;
|
||||
}
|
||||
|
||||
qboolean CL_LegacyMode( void )
|
||||
{
|
||||
return cls.legacymode == PROTO_LEGACY;
|
||||
}
|
||||
|
||||
762
engine/client/cl_parse_gs.c
Normal file
762
engine/client/cl_parse_gs.c
Normal file
@@ -0,0 +1,762 @@
|
||||
/*
|
||||
cl_parse.c - parse a message received from the server (GoldSrc 48 protocol)
|
||||
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"
|
||||
#include "server.h"
|
||||
|
||||
static void CL_ParseExtraInfo( sizebuf_t *msg )
|
||||
{
|
||||
string clientfallback;
|
||||
|
||||
Q_strncpy( clientfallback, MSG_ReadString( msg ), sizeof( clientfallback ));
|
||||
if( COM_CheckStringEmpty( clientfallback ))
|
||||
Con_Reportf( S_ERROR "%s: TODO: add fallback directory %s!\n", __func__, clientfallback );
|
||||
|
||||
if( MSG_ReadByte( msg ))
|
||||
{
|
||||
Cvar_FullSet( "sv_cheats", "1", FCVAR_READ_ONLY | FCVAR_SERVER );
|
||||
}
|
||||
else
|
||||
{
|
||||
Cvar_SetCheatState();
|
||||
Cvar_FullSet( "sv_cheats", "0", FCVAR_READ_ONLY | FCVAR_SERVER );
|
||||
}
|
||||
}
|
||||
|
||||
static void CL_ParseNewMovevars( sizebuf_t *msg )
|
||||
{
|
||||
Delta_InitClient(); // finalize client delta's
|
||||
|
||||
clgame.movevars.gravity = MSG_ReadFloat( msg );
|
||||
clgame.movevars.stopspeed = MSG_ReadFloat( msg );
|
||||
clgame.movevars.maxspeed = MSG_ReadFloat( msg );
|
||||
clgame.movevars.spectatormaxspeed = MSG_ReadFloat( msg );
|
||||
clgame.movevars.accelerate = MSG_ReadFloat( msg );
|
||||
clgame.movevars.airaccelerate = MSG_ReadFloat( msg );
|
||||
clgame.movevars.wateraccelerate = MSG_ReadFloat( msg );
|
||||
clgame.movevars.friction = MSG_ReadFloat( msg );
|
||||
clgame.movevars.edgefriction = MSG_ReadFloat( msg );
|
||||
clgame.movevars.waterfriction = MSG_ReadFloat( msg );
|
||||
clgame.movevars.entgravity = MSG_ReadFloat( msg );
|
||||
clgame.movevars.bounce = MSG_ReadFloat( msg );
|
||||
clgame.movevars.stepsize = MSG_ReadFloat( msg );
|
||||
clgame.movevars.maxvelocity = MSG_ReadFloat( msg );
|
||||
clgame.movevars.zmax = MSG_ReadFloat( msg );
|
||||
clgame.movevars.waveHeight = MSG_ReadFloat( msg );
|
||||
clgame.movevars.footsteps = MSG_ReadByte( msg );
|
||||
clgame.movevars.rollangle = MSG_ReadFloat( msg );
|
||||
clgame.movevars.rollspeed = MSG_ReadFloat( msg );
|
||||
clgame.movevars.skycolor_r = MSG_ReadFloat( msg );
|
||||
clgame.movevars.skycolor_g = MSG_ReadFloat( msg );
|
||||
clgame.movevars.skycolor_b = MSG_ReadFloat( msg );
|
||||
clgame.movevars.skyvec_x = MSG_ReadFloat( msg );
|
||||
clgame.movevars.skyvec_y = MSG_ReadFloat( msg );
|
||||
clgame.movevars.skyvec_z = MSG_ReadFloat( msg );
|
||||
|
||||
Q_strncpy( clgame.movevars.skyName, MSG_ReadString( msg ), sizeof( clgame.movevars.skyName ));
|
||||
|
||||
// water alpha is not allowed
|
||||
if( !FBitSet( world.flags, FWORLD_WATERALPHA ))
|
||||
clgame.movevars.wateralpha = 1.0f;
|
||||
|
||||
// update sky if changed
|
||||
if( Q_strcmp( clgame.oldmovevars.skyName, clgame.movevars.skyName ) && cl.video_prepped )
|
||||
R_SetupSky( clgame.movevars.skyName );
|
||||
|
||||
clgame.oldmovevars = clgame.movevars;
|
||||
clgame.entities->curstate.scale = clgame.movevars.waveHeight;
|
||||
|
||||
// keep features an actual!
|
||||
clgame.oldmovevars.features = clgame.movevars.features = host.features;
|
||||
}
|
||||
|
||||
typedef struct delta_header_t
|
||||
{
|
||||
qboolean remove : 1;
|
||||
qboolean custom : 1;
|
||||
qboolean instanced : 1;
|
||||
uint instanced_baseline_index : 6;
|
||||
uint offset : 6;
|
||||
} delta_header_t;
|
||||
|
||||
static int CL_ParseDeltaHeader( sizebuf_t *msg, qboolean delta, int oldnum, struct delta_header_t *hdr )
|
||||
{
|
||||
int entnum = oldnum;
|
||||
memset( hdr, 0, sizeof( *hdr ));
|
||||
|
||||
if( !delta )
|
||||
{
|
||||
// if we have one bit set, then it's a next entity in line
|
||||
// if we have next bit NON set, then it's a one of next 64 entities
|
||||
// if not, it's a new entity
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
entnum++;
|
||||
else if( MSG_ReadOneBit( msg ) == 0 )
|
||||
entnum += MSG_ReadUBitLong( msg, 6 );
|
||||
else
|
||||
entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
|
||||
}
|
||||
else
|
||||
{
|
||||
// does this packet encode entity deletion?
|
||||
hdr->remove = MSG_ReadOneBit( msg );
|
||||
|
||||
// same logic as above
|
||||
if( MSG_ReadOneBit( msg ) == 0 )
|
||||
entnum += MSG_ReadUBitLong( msg, 6 );
|
||||
else entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
|
||||
}
|
||||
|
||||
// if we are not removing this entity
|
||||
if( !hdr->remove )
|
||||
{
|
||||
hdr->custom = MSG_ReadOneBit( msg );
|
||||
|
||||
// do we got instanced baselines in svc_spawnbaselines?
|
||||
if( cl.instanced_baseline_count )
|
||||
{
|
||||
hdr->instanced = MSG_ReadOneBit( msg );
|
||||
if( hdr->instanced )
|
||||
hdr->instanced_baseline_index = MSG_ReadUBitLong( msg, 6 );
|
||||
}
|
||||
|
||||
if( !delta && !hdr->instanced )
|
||||
{
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
hdr->offset = MSG_ReadUBitLong( msg, 6 );
|
||||
}
|
||||
}
|
||||
|
||||
return entnum;
|
||||
}
|
||||
|
||||
static int CL_GetEntityDelta( const struct delta_header_t *hdr, int entnum )
|
||||
{
|
||||
if( hdr->custom )
|
||||
return DT_CUSTOM_ENTITY_STATE_T;
|
||||
|
||||
if( CL_IsPlayerIndex( entnum ))
|
||||
return DT_ENTITY_STATE_PLAYER_T;
|
||||
|
||||
return DT_ENTITY_STATE_T;
|
||||
}
|
||||
|
||||
static void CL_FlushEntityPacketGS( frame_t *frame, sizebuf_t *msg )
|
||||
{
|
||||
frame->valid = false;
|
||||
cl.validsequence = 0; // can't render a frame
|
||||
|
||||
// read it all but ignore it
|
||||
while( 1 )
|
||||
{
|
||||
int num = 0;
|
||||
entity_state_t from = { 0 }, to;
|
||||
delta_header_t hdr;
|
||||
|
||||
if( MSG_ReadWord( msg ) != 0 )
|
||||
{
|
||||
MSG_SeekToBit( msg, -16, SEEK_CUR );
|
||||
num = CL_ParseDeltaHeader( msg, false, num, &hdr );
|
||||
}
|
||||
else break;
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
|
||||
if( hdr.remove )
|
||||
continue;
|
||||
|
||||
Delta_ReadGSFields( msg, CL_GetEntityDelta( &hdr, num ), &from, &to, cl.mtime[0] );
|
||||
}
|
||||
}
|
||||
|
||||
static void CL_DeltaEntityGS( const delta_header_t *hdr, sizebuf_t *msg, frame_t *frame, int newnum, const entity_state_t *from )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
entity_state_t *to;
|
||||
qboolean newent = from == NULL;
|
||||
int pack = frame->num_entities;
|
||||
qboolean has_update = msg != NULL;
|
||||
|
||||
// alloc next slot to store update
|
||||
to = &cls.packet_entities[cls.next_client_entities % cls.num_client_entities];
|
||||
|
||||
if(( newnum < 0 ) || ( newnum >= clgame.maxEntities ))
|
||||
{
|
||||
Con_DPrintf( S_ERROR "CL_DeltaEntity: invalid newnum: %d\n", newnum );
|
||||
Host_Error( "%s: bad delta entity number: %i", __func__, newnum );
|
||||
return;
|
||||
}
|
||||
|
||||
ent = CL_EDICT_NUM( newnum );
|
||||
if( hdr->remove )
|
||||
{
|
||||
if( !newent )
|
||||
CL_KillDeadBeams( ent );
|
||||
else
|
||||
Con_Printf( S_WARN "%s: entity remove on non-delta update (%d)\n", __func__, newnum );
|
||||
return;
|
||||
}
|
||||
|
||||
ent->index = newnum; // enumerate entity index
|
||||
if( newent )
|
||||
{
|
||||
if( hdr->instanced )
|
||||
from = &cl.instanced_baseline[hdr->instanced_baseline_index];
|
||||
else if( hdr->offset != 0 )
|
||||
from = &cls.packet_entities[(cls.next_client_entities - hdr->offset) % cls.num_client_entities];
|
||||
else
|
||||
from = &ent->baseline;
|
||||
}
|
||||
|
||||
if( has_update )
|
||||
Delta_ReadGSFields( msg, CL_GetEntityDelta( hdr, newnum ), from, to, cl.mtime[0] );
|
||||
else memcpy( to, from, sizeof( entity_state_t ));
|
||||
|
||||
to->entityType = hdr->custom ? ENTITY_BEAM : ENTITY_NORMAL;
|
||||
to->number = newnum;
|
||||
|
||||
if( newent )
|
||||
{
|
||||
// interpolation must be reset
|
||||
SETVISBIT( frame->flags, pack );
|
||||
|
||||
// release beams from previous entity
|
||||
CL_KillDeadBeams( ent );
|
||||
}
|
||||
|
||||
// add entity to packet
|
||||
cls.next_client_entities++;
|
||||
frame->num_entities++;
|
||||
}
|
||||
|
||||
static void CL_CopyPacketEntity( frame_t *frame, int num, const entity_state_t *from )
|
||||
{
|
||||
delta_header_t fakehdr =
|
||||
{
|
||||
.custom = FBitSet( from->entityType, ENTITY_BEAM ) == ENTITY_BEAM,
|
||||
};
|
||||
CL_DeltaEntityGS( &fakehdr, NULL, frame, num, from );
|
||||
}
|
||||
|
||||
static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
|
||||
{
|
||||
frame_t *frame, *oldframe;
|
||||
int oldindex, newnum, oldnum, numbase = 0;
|
||||
entity_state_t *oldent;
|
||||
int count;
|
||||
int playerbytes = 0;
|
||||
|
||||
// save first uncompressed packet as timestamp
|
||||
if( cls.changelevel && !delta && cls.demorecording )
|
||||
CL_WriteDemoJumpTime();
|
||||
|
||||
count = MSG_ReadWord( msg );
|
||||
|
||||
frame = &cl.frames[cl.parsecountmod];
|
||||
memset( frame->flags, 0, sizeof( frame->flags ));
|
||||
frame->first_entity = cls.next_client_entities;
|
||||
frame->num_entities = 0;
|
||||
frame->valid = true;
|
||||
|
||||
if( delta )
|
||||
{
|
||||
uint oldpacket = MSG_ReadByte( msg );
|
||||
oldframe = &cl.frames[oldpacket & CL_UPDATE_MASK];
|
||||
|
||||
if( !CL_ValidateDeltaPacket( oldpacket, oldframe ))
|
||||
{
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_FlushEntityPacketGS( frame, msg );
|
||||
MSG_EndBitWriting( msg );
|
||||
return playerbytes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oldframe = NULL;
|
||||
cl.send_reply = true;
|
||||
cls.demowaiting = false;
|
||||
}
|
||||
|
||||
cl.validsequence = cls.netchan.incoming_sequence;
|
||||
|
||||
MSG_StartBitWriting( msg );
|
||||
|
||||
oldent = NULL;
|
||||
oldindex = 0;
|
||||
oldnum = CL_UpdateOldEntNum( oldindex, oldframe, &oldent );
|
||||
|
||||
// read it all but ignore it
|
||||
while( 1 )
|
||||
{
|
||||
int bufstart;
|
||||
qboolean player;
|
||||
delta_header_t hdr;
|
||||
int val = MSG_ReadWord( msg );
|
||||
|
||||
if( val )
|
||||
{
|
||||
MSG_SeekToBit( msg, -16, SEEK_CUR );
|
||||
numbase = newnum = CL_ParseDeltaHeader( msg, delta, numbase, &hdr );
|
||||
}
|
||||
else break;
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
|
||||
player = CL_IsPlayerIndex( newnum );
|
||||
|
||||
while( oldnum < newnum )
|
||||
{
|
||||
if( !delta )
|
||||
Con_Printf( S_WARN "%s: old frame copy on non-delta update (%d < %d)\n", __func__, oldnum, newnum );
|
||||
|
||||
// one or more entities from the old packet are unchanged
|
||||
CL_CopyPacketEntity( frame, oldnum, oldent );
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
}
|
||||
|
||||
bufstart = MSG_GetNumBytesRead( msg );
|
||||
|
||||
if( oldnum == newnum )
|
||||
{
|
||||
if( !delta )
|
||||
Con_Printf( S_WARN "%s: delta entity on non-delta update (%d)\n", __func__, oldnum );
|
||||
|
||||
// from delta
|
||||
CL_DeltaEntityGS( &hdr, msg, frame, newnum, oldent );
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
}
|
||||
else if( oldnum > newnum )
|
||||
{
|
||||
// from baseline
|
||||
CL_DeltaEntityGS( &hdr, msg, frame, newnum, NULL );
|
||||
}
|
||||
|
||||
if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufstart;
|
||||
}
|
||||
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
|
||||
// any remaining entities in the old frame are copied over
|
||||
while( oldnum != MAX_ENTNUMBER )
|
||||
{
|
||||
// one or more entities from the old packet are unchanged
|
||||
CL_CopyPacketEntity( frame, oldnum, oldent );
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
}
|
||||
|
||||
MSG_EndBitWriting( msg );
|
||||
|
||||
if( frame->num_entities != count )
|
||||
Con_Reportf( S_WARN "CL_Parse%sPacketEntitiesGS: (%i should be %i)\n", delta ? "Delta" : "", frame->num_entities, count );
|
||||
|
||||
if( !frame->valid )
|
||||
return playerbytes;
|
||||
|
||||
CL_ProcessPacket( frame );
|
||||
CL_SetSolidEntities();
|
||||
|
||||
// first update, received world, remove loading plaque
|
||||
if( cls.signon == ( SIGNONS - 1 ))
|
||||
{
|
||||
cls.signon = SIGNONS;
|
||||
CL_SignonReply( PROTO_GOLDSRC );
|
||||
}
|
||||
|
||||
return playerbytes;
|
||||
}
|
||||
|
||||
static float MSG_ReadGSBitCoord( sizebuf_t *sb )
|
||||
{
|
||||
float value = 0;
|
||||
int ival, fval;
|
||||
|
||||
ival = MSG_ReadOneBit( sb );
|
||||
fval = MSG_ReadOneBit( sb );
|
||||
|
||||
if( ival || fval )
|
||||
{
|
||||
int sign = MSG_ReadOneBit( sb );
|
||||
|
||||
if( ival )
|
||||
ival = MSG_ReadUBitLong( sb, 12 );
|
||||
if( fval )
|
||||
fval = MSG_ReadUBitLong( sb, 3 );
|
||||
|
||||
value = (float)( fval / 8.0 + ival );
|
||||
if( sign )
|
||||
value = -value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void MSG_ReadGSBitVec3Coord( sizebuf_t *sb, vec3_t fa )
|
||||
{
|
||||
qboolean x, y, z;
|
||||
|
||||
VectorClear( fa );
|
||||
|
||||
x = MSG_ReadOneBit( sb );
|
||||
y = MSG_ReadOneBit( sb );
|
||||
z = MSG_ReadOneBit( sb );
|
||||
if( x )
|
||||
fa[0] = MSG_ReadGSBitCoord( sb );
|
||||
if( y )
|
||||
fa[1] = MSG_ReadGSBitCoord( sb );
|
||||
if( z )
|
||||
fa[2] = MSG_ReadGSBitCoord( sb );
|
||||
}
|
||||
|
||||
static void CL_ParseSoundPacketGS( sizebuf_t *msg )
|
||||
{
|
||||
vec3_t pos;
|
||||
int chan, sound;
|
||||
float volume, attn;
|
||||
int flags, pitch, entnum;
|
||||
sound_t handle = 0;
|
||||
|
||||
MSG_StartBitWriting( msg );
|
||||
|
||||
flags = MSG_ReadUBitLong( msg, 9 );
|
||||
|
||||
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;
|
||||
|
||||
chan = MSG_ReadUBitLong( msg, 3 );
|
||||
entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
|
||||
if( FBitSet( flags, SND_LEGACY_LARGE_INDEX ))
|
||||
sound = MSG_ReadWord( msg );
|
||||
else sound = MSG_ReadByte( msg );
|
||||
MSG_ReadGSBitVec3Coord( msg, pos );
|
||||
|
||||
if( FBitSet( flags, SND_PITCH ))
|
||||
pitch = MSG_ReadByte( msg );
|
||||
else pitch = PITCH_NORM;
|
||||
|
||||
MSG_EndBitWriting( msg );
|
||||
|
||||
ClearBits( flags, SND_LEGACY_LARGE_INDEX );
|
||||
|
||||
if( FBitSet( flags, SND_SENTENCE ))
|
||||
{
|
||||
char sentenceName[32];
|
||||
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( chan == CHAN_STATIC )
|
||||
{
|
||||
S_AmbientSound( pos, entnum, handle, volume, attn, pitch, flags );
|
||||
}
|
||||
else
|
||||
{
|
||||
S_StartSound( pos, entnum, chan, handle, volume, attn, pitch, flags );
|
||||
}
|
||||
}
|
||||
|
||||
static void CL_ParseSpawnStaticSound( sizebuf_t *msg )
|
||||
{
|
||||
vec3_t pos;
|
||||
int handle, entnum, pitch, flags;
|
||||
float volume, attn;
|
||||
|
||||
MSG_ReadVec3Coord( msg, pos );
|
||||
handle = MSG_ReadShort( msg );
|
||||
volume = MSG_ReadByte( msg ) * ( 1.0f / 255.0f );
|
||||
attn = MSG_ReadByte( msg ) * ( 1.0f / 64.0f );
|
||||
entnum = MSG_ReadShort( msg );
|
||||
pitch = MSG_ReadByte( msg );
|
||||
flags = MSG_ReadByte( msg );
|
||||
|
||||
S_AmbientSound( pos, entnum, handle, volume, attn, pitch, flags );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================================================================
|
||||
|
||||
ACTION MESSAGES
|
||||
|
||||
=====================================================================
|
||||
*/
|
||||
/*
|
||||
=====================
|
||||
CL_ParseGoldSrcServerMessage
|
||||
|
||||
dispatch messages
|
||||
=====================
|
||||
*/
|
||||
void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
|
||||
{
|
||||
size_t bufStart, playerbytes;
|
||||
int cmd, param1;
|
||||
const char *s;
|
||||
|
||||
// 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 );
|
||||
|
||||
if( CL_ParseCommonDLLMessage( msg, PROTO_GOLDSRC, cmd, bufStart ))
|
||||
continue;
|
||||
|
||||
// other commands
|
||||
switch( cmd )
|
||||
{
|
||||
case svc_bad:
|
||||
Host_Error( "svc_bad\n" );
|
||||
break;
|
||||
case svc_nop:
|
||||
case svc_spawnstatic:
|
||||
case svc_goldsrc_damage:
|
||||
case svc_goldsrc_killedmonster:
|
||||
case svc_goldsrc_foundsecret:
|
||||
// this does nothing
|
||||
break;
|
||||
case svc_disconnect:
|
||||
s = MSG_ReadString( msg );
|
||||
if( COM_CheckStringEmpty( s ))
|
||||
Con_Printf( "Server issued disconnect. Reason: %s\n", s );
|
||||
CL_Drop ();
|
||||
Host_AbortCurrentFrame ();
|
||||
break;
|
||||
case svc_event:
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_ParseEvent( msg, PROTO_GOLDSRC );
|
||||
MSG_EndBitWriting( msg );
|
||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_goldsrc_version:
|
||||
param1 = MSG_ReadLong( msg );
|
||||
if( param1 != PROTOCOL_GOLDSRC_VERSION )
|
||||
Host_Error( "Server use invalid protocol (%i should be %i)\n", param1, PROTOCOL_GOLDSRC_VERSION );
|
||||
break;
|
||||
case svc_setview:
|
||||
CL_ParseViewEntity( msg );
|
||||
break;
|
||||
case svc_sound:
|
||||
CL_ParseSoundPacketGS( msg );
|
||||
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_time:
|
||||
CL_ParseServerTime( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_print:
|
||||
Con_Printf( "%s", MSG_ReadString( msg ));
|
||||
break;
|
||||
case svc_stufftext:
|
||||
s = MSG_ReadString( msg );
|
||||
if( cl_trace_stufftext.value )
|
||||
{
|
||||
size_t len = Q_strlen( s );
|
||||
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
|
||||
}
|
||||
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
// disable Cry Of Fear antisave protection
|
||||
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
|
||||
break; // too early
|
||||
#endif
|
||||
Cbuf_AddFilteredText( s );
|
||||
break;
|
||||
case svc_setangle:
|
||||
CL_ParseSetAngle( msg );
|
||||
break;
|
||||
case svc_goldsrc_serverinfo:
|
||||
Cbuf_Execute(); // make sure any stuffed commands are done
|
||||
CL_ParseServerData( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_lightstyle:
|
||||
CL_ParseLightStyle( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_updateuserinfo:
|
||||
CL_UpdateUserinfo( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_goldsrc_deltadescription:
|
||||
Delta_ParseTableField_GS( msg );
|
||||
break;
|
||||
case svc_clientdata:
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_ParseClientData( msg, PROTO_GOLDSRC );
|
||||
MSG_EndBitWriting( msg );
|
||||
cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_goldsrc_stopsound:
|
||||
param1 = MSG_ReadWord( msg );
|
||||
S_StopSound( param1 >> 3, param1 & 7, NULL );
|
||||
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_pings:
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_UpdateUserPings( msg );
|
||||
MSG_EndBitWriting( msg );
|
||||
break;
|
||||
case svc_particle:
|
||||
CL_ParseParticles( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_event_reliable:
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_ParseReliableEvent( msg, PROTO_GOLDSRC );
|
||||
MSG_EndBitWriting( msg );
|
||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_spawnbaseline:
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_ParseBaseline( msg, PROTO_GOLDSRC );
|
||||
MSG_EndBitWriting( msg );
|
||||
break;
|
||||
case svc_setpause:
|
||||
cl.paused = ( MSG_ReadByte( msg ) != 0 );
|
||||
break;
|
||||
case svc_signonnum:
|
||||
CL_ParseSignon( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_centerprint:
|
||||
CL_CenterPrint( MSG_ReadString( msg ), 0.25f );
|
||||
break;
|
||||
case svc_goldsrc_spawnstaticsound:
|
||||
CL_ParseSpawnStaticSound( msg );
|
||||
break;
|
||||
case svc_finale:
|
||||
CL_ParseFinaleCutscene( msg, 2 );
|
||||
break;
|
||||
case svc_restore:
|
||||
CL_ParseRestore( msg );
|
||||
break;
|
||||
case svc_cutscene:
|
||||
CL_ParseFinaleCutscene( msg, 3 );
|
||||
break;
|
||||
case svc_goldsrc_decalname:
|
||||
param1 = MSG_ReadByte( msg );
|
||||
s = MSG_ReadString( msg );
|
||||
Q_strncpy( host.draw_decals[param1], s, sizeof( host.draw_decals[param1] ));
|
||||
break;
|
||||
case svc_addangle:
|
||||
CL_ParseAddAngle( msg );
|
||||
break;
|
||||
case svc_goldsrc_newusermsg:
|
||||
CL_RegisterUserMessage( msg, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_packetentities:
|
||||
playerbytes = CL_ParsePacketEntitiesGS( 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_ParsePacketEntitiesGS( msg, true );
|
||||
cl.frames[cl.parsecountmod].graphdata.players += playerbytes;
|
||||
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
|
||||
break;
|
||||
case svc_choke:
|
||||
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:
|
||||
MSG_StartBitWriting( msg );
|
||||
CL_ParseResourceList( msg, PROTO_GOLDSRC );
|
||||
MSG_EndBitWriting( msg );
|
||||
break;
|
||||
case svc_goldsrc_newmovevars:
|
||||
CL_ParseNewMovevars( 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_voiceinit:
|
||||
CL_ParseVoiceInit( msg );
|
||||
break;
|
||||
case svc_voicedata:
|
||||
CL_ParseVoiceData( msg, PROTO_GOLDSRC );
|
||||
cl.frames[cl.parsecountmod].graphdata.voicebytes += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
case svc_resourcelocation:
|
||||
CL_ParseResLocation( msg );
|
||||
break;
|
||||
case svc_goldsrc_sendextrainfo:
|
||||
CL_ParseExtraInfo( msg );
|
||||
break;
|
||||
case svc_goldsrc_timescale:
|
||||
// we can set sys_timescale to anything we want but in GoldSrc it's locked for
|
||||
// HLTV and demoplayback. Do we really want to have it then if both are out of scope?
|
||||
Con_Reportf( S_ERROR "%s: svc_goldsrc_timescale: implement me!\n", __func__ );
|
||||
MSG_ReadFloat( msg );
|
||||
break;
|
||||
case svc_goldsrc_sendcvarvalue:
|
||||
CL_ParseCvarValue( msg, false, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_goldsrc_sendcvarvalue2:
|
||||
CL_ParseCvarValue( msg, true, PROTO_GOLDSRC );
|
||||
break;
|
||||
case svc_exec:
|
||||
CL_ParseExec( msg );
|
||||
break;
|
||||
default:
|
||||
CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
|
||||
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void GAME_EXPORT CL_PopPMStates( void )
|
||||
CL_IsPredicted
|
||||
===============
|
||||
*/
|
||||
qboolean CL_IsPredicted( void )
|
||||
static qboolean CL_IsPredicted( void )
|
||||
{
|
||||
if( cl_nopred.value || cl.intermission )
|
||||
return false;
|
||||
|
||||
@@ -431,7 +431,7 @@ static void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
|
||||
cls.signon = SIGNONS;
|
||||
|
||||
// Clear loading plaque.
|
||||
CL_SignonReply ();
|
||||
CL_SignonReply( PROTO_QUAKE );
|
||||
}
|
||||
|
||||
// alloc next slot to store update
|
||||
@@ -626,7 +626,7 @@ CL_ParseStaticEntity
|
||||
|
||||
===================
|
||||
*/
|
||||
static void CL_ParseStaticEntity( sizebuf_t *msg )
|
||||
static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
|
||||
{
|
||||
entity_state_t state;
|
||||
cl_entity_t *ent;
|
||||
@@ -950,7 +950,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
|
||||
break;
|
||||
case svc_time:
|
||||
Cbuf_AddText( "\n" ); // new frame was started
|
||||
CL_ParseServerTime( msg );
|
||||
CL_ParseServerTime( msg, PROTO_QUAKE );
|
||||
break;
|
||||
case svc_print:
|
||||
str = MSG_ReadString( msg );
|
||||
@@ -1006,7 +1006,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg )
|
||||
CL_ParseQuakeDamage( msg );
|
||||
break;
|
||||
case svc_spawnstatic:
|
||||
CL_ParseStaticEntity( msg );
|
||||
CL_ParseQuakeStaticEntity( msg );
|
||||
break;
|
||||
case svc_spawnbinary:
|
||||
// never used in Quake
|
||||
|
||||
@@ -853,7 +853,6 @@ void SCR_Shutdown( void )
|
||||
{
|
||||
if( !scr_init ) return;
|
||||
|
||||
Cmd_RemoveCommand( "timerefresh" );
|
||||
Cmd_RemoveCommand( "skyname" );
|
||||
Cmd_RemoveCommand( "viewpos" );
|
||||
UI_SetActiveMenu( false );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -77,7 +77,6 @@ void R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_t noise, int
|
||||
void R_FireField( float *org, int radius, int modelIndex, int count, int flags, float life );
|
||||
void R_PlayerSprites( int client, int modelIndex, int count, int size );
|
||||
void R_Sprite_WallPuff( struct tempent_s *pTemp, float scale );
|
||||
void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b );
|
||||
void R_RicochetSound( const vec3_t pos );
|
||||
struct dlight_s *CL_AllocDlight( int key );
|
||||
struct dlight_s *CL_AllocElight( int key );
|
||||
|
||||
@@ -129,7 +129,6 @@ typedef struct
|
||||
|
||||
// misc local info
|
||||
qboolean repredicting; // repredicting in progress
|
||||
qboolean thirdperson;
|
||||
qboolean apply_effects; // local player will not added but we should apply their effects: flashlight etc
|
||||
float idealpitch;
|
||||
int viewmodel;
|
||||
@@ -278,6 +277,8 @@ typedef struct
|
||||
int lostpackets; // count lost packets and show dialog in menu
|
||||
|
||||
double frametime_remainder;
|
||||
|
||||
uint worldmapCRC;
|
||||
} client_t;
|
||||
|
||||
/*
|
||||
@@ -309,14 +310,6 @@ typedef enum
|
||||
CL_CHANGELEVEL, // draw 'loading' during changelevel
|
||||
} scrstate_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PROTO_CURRENT = 0, // Xash3D 49
|
||||
PROTO_LEGACY = 1, // Xash3D 48
|
||||
PROTO_QUAKE = 2, // Quake 15
|
||||
PROTO_GOLDSRC = 3, // GoldSrc 48
|
||||
} connprotocol_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[32];
|
||||
@@ -567,7 +560,6 @@ typedef struct
|
||||
byte datagram_buf[MAX_DATAGRAM];
|
||||
|
||||
netchan_t netchan;
|
||||
int challenge; // from the server to use for connecting
|
||||
|
||||
float packet_loss;
|
||||
double packet_loss_recalc_time;
|
||||
@@ -660,6 +652,7 @@ extern gameui_static_t gameui;
|
||||
//
|
||||
// cvars
|
||||
//
|
||||
extern convar_t showpause;
|
||||
extern convar_t mp_decals;
|
||||
extern convar_t cl_logomaxdim;
|
||||
extern convar_t cl_allow_download;
|
||||
@@ -754,13 +747,13 @@ void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel );
|
||||
void CL_Init( void );
|
||||
void CL_Disconnect_f( void );
|
||||
void CL_ProcessFile( qboolean successfully_received, const char *filename );
|
||||
void CL_WriteUsercmd( sizebuf_t *msg, int from, int to );
|
||||
int CL_GetFragmentSize( void *unused , fragsize_t mode );
|
||||
void CL_WriteUsercmd( connprotocol_t proto, sizebuf_t *msg, int from, int to );
|
||||
void CL_SetupNetchanForProtocol( connprotocol_t proto );
|
||||
qboolean CL_PrecacheResources( void );
|
||||
void CL_SetupOverviewParams( void );
|
||||
void CL_UpdateFrameLerp( void );
|
||||
int CL_IsDevOverviewMode( void );
|
||||
void CL_SignonReply( void );
|
||||
void CL_SignonReply( connprotocol_t proto );
|
||||
void CL_ClearState( void );
|
||||
|
||||
//
|
||||
@@ -790,8 +783,8 @@ int CL_GetDemoComment( const char *demoname, char *comment );
|
||||
//
|
||||
// cl_events.c
|
||||
//
|
||||
void CL_ParseEvent( sizebuf_t *msg );
|
||||
void CL_ParseReliableEvent( sizebuf_t *msg );
|
||||
void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseReliableEvent( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_SetEventIndex( const char *szEvName, int ev_index );
|
||||
void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
|
||||
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
@@ -868,20 +861,21 @@ _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_ParseServerData( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseLightStyle( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_UpdateUserinfo( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseResource( sizebuf_t *msg );
|
||||
void CL_ParseClientData( sizebuf_t *msg );
|
||||
void CL_ParseClientData( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_UpdateUserPings( sizebuf_t *msg );
|
||||
void CL_ParseParticles( sizebuf_t *msg );
|
||||
void CL_ParseParticles( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseRestoreSoundPacket( sizebuf_t *msg );
|
||||
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy );
|
||||
void CL_ParseSignon( sizebuf_t *msg );
|
||||
void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseSignon( sizebuf_t *msg, connprotocol_t proto );
|
||||
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_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseResourceList( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseMovevars( sizebuf_t *msg );
|
||||
void CL_ParseResourceRequest( sizebuf_t *msg );
|
||||
void CL_ParseCustomization( sizebuf_t *msg );
|
||||
@@ -890,18 +884,22 @@ 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_ParseVoiceInit( sizebuf_t *msg );
|
||||
void CL_ParseVoiceData( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseResLocation( sizebuf_t *msg );
|
||||
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto );
|
||||
void CL_ParseServerMessage( sizebuf_t *msg );
|
||||
void CL_ParseTempEntity( sizebuf_t *msg );
|
||||
qboolean CL_ParseCommonDLLMessage( sizebuf_t *msg, connprotocol_t proto, int svc_num, int startoffset );
|
||||
void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto );
|
||||
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
|
||||
qboolean CL_RequestMissingResources( void );
|
||||
void CL_RegisterResources ( sizebuf_t *msg );
|
||||
void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseViewEntity( sizebuf_t *msg );
|
||||
void CL_ParseServerTime( sizebuf_t *msg );
|
||||
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
|
||||
void CL_ParseServerTime( sizebuf_t *msg, connprotocol_t proto );
|
||||
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num, connprotocol_t proto );
|
||||
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
|
||||
void CL_ParseTextMessage( sizebuf_t *msg );
|
||||
void CL_ParseExec( sizebuf_t *msg );
|
||||
void CL_BatchResourceRequest( qboolean initialize );
|
||||
int CL_EstimateNeededResources( void );
|
||||
|
||||
@@ -911,6 +909,11 @@ int CL_EstimateNeededResources( void );
|
||||
void CL_ParseLegacyServerMessage( sizebuf_t *msg );
|
||||
void CL_LegacyPrecache_f( void );
|
||||
|
||||
//
|
||||
// cl_parse_gs.c
|
||||
//
|
||||
void CL_ParseGoldSrcServerMessage( sizebuf_t *msg );
|
||||
|
||||
//
|
||||
// cl_scrn.c
|
||||
//
|
||||
@@ -952,7 +955,6 @@ void CL_SetSolidPlayers( int playernum );
|
||||
void CL_InitClientMove( void );
|
||||
void CL_PredictMovement( qboolean repredicting );
|
||||
void CL_CheckPredictionError( void );
|
||||
qboolean CL_IsPredicted( void );
|
||||
int CL_WaterEntity( const float *rgflPos );
|
||||
cl_entity_t *CL_GetWaterEntity( const float *rgflPos );
|
||||
pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags );
|
||||
@@ -975,7 +977,9 @@ void CL_ParseQuakeMessage( sizebuf_t *msg );
|
||||
//
|
||||
struct channel_s;
|
||||
struct rawchan_s;
|
||||
int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta );
|
||||
qboolean CL_ValidateDeltaPacket( uint oldpacket, frame_t *oldframe );
|
||||
int CL_UpdateOldEntNum( int oldindex, frame_t *oldframe, entity_state_t **oldent );
|
||||
int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta, connprotocol_t proto );
|
||||
qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType );
|
||||
void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset );
|
||||
qboolean CL_GetEntitySpatialization( struct channel_s *ch );
|
||||
@@ -1025,7 +1029,6 @@ void CL_InitParticles( void );
|
||||
void CL_ClearParticles( void );
|
||||
void CL_FreeParticles( void );
|
||||
void CL_InitTempEnts( void );
|
||||
void CL_ClearTempEnts( void );
|
||||
void CL_FreeTempEnts( void );
|
||||
void CL_TempEntUpdate( void );
|
||||
void CL_InitViewBeams( void );
|
||||
|
||||
@@ -875,7 +875,6 @@ void Con_Print( const char *txt )
|
||||
Con_DeleteLastLine();
|
||||
cr_pending = 0;
|
||||
}
|
||||
|
||||
c = *txt;
|
||||
|
||||
switch( c )
|
||||
@@ -883,10 +882,13 @@ void Con_Print( const char *txt )
|
||||
case '\0':
|
||||
break;
|
||||
case '\r':
|
||||
Con_AddLine( buf, bufpos, true );
|
||||
lastlength = CON_LINES_LAST().length;
|
||||
cr_pending = 1;
|
||||
bufpos = 0;
|
||||
if( txt[1] != '\n' )
|
||||
{
|
||||
Con_AddLine( buf, bufpos, true );
|
||||
lastlength = CON_LINES_LAST().length;
|
||||
cr_pending = 1;
|
||||
bufpos = 0;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
Con_AddLine( buf, bufpos, true );
|
||||
@@ -894,6 +896,7 @@ void Con_Print( const char *txt )
|
||||
bufpos = 0;
|
||||
break;
|
||||
default:
|
||||
|
||||
buf[bufpos++] = c | mask;
|
||||
if(( bufpos >= sizeof( buf ) - 1 ) || bufpos >= ( con.linewidth - 1 ))
|
||||
{
|
||||
@@ -1941,7 +1944,7 @@ void Con_DrawConsole( void )
|
||||
{
|
||||
if( !cl_allow_levelshots.value && !cls.timedemo )
|
||||
{
|
||||
if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console )
|
||||
if( cls.key_dest != key_console && ( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )))
|
||||
con.vislines = con.showlines = 0;
|
||||
else con.vislines = con.showlines = refState.height;
|
||||
}
|
||||
|
||||
@@ -569,10 +569,9 @@ IN_EngineAppendMove
|
||||
Called from cl_main.c after generating command in client
|
||||
================
|
||||
*/
|
||||
void IN_EngineAppendMove( float frametime, void *cmd1, qboolean active )
|
||||
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
|
||||
{
|
||||
float forward, side, pitch, yaw;
|
||||
usercmd_t *cmd = cmd1;
|
||||
|
||||
if( clgame.dllFuncs.pfnLookEvent )
|
||||
return;
|
||||
|
||||
@@ -25,6 +25,7 @@ INPUT
|
||||
*/
|
||||
|
||||
#include "keydefs.h"
|
||||
#include "usercmd.h"
|
||||
|
||||
//
|
||||
// input.c
|
||||
@@ -43,7 +44,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate );
|
||||
|
||||
uint IN_CollectInputDevices( void );
|
||||
void IN_LockInputDevices( qboolean lock );
|
||||
void IN_EngineAppendMove( float frametime, void *cmd, qboolean active );
|
||||
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active );
|
||||
|
||||
extern convar_t m_yaw;
|
||||
extern convar_t m_pitch;
|
||||
|
||||
@@ -524,6 +524,12 @@ static void SND_Spatialize( channel_t *ch )
|
||||
dist = VectorNormalizeLength( source_vec );
|
||||
dot = DotProduct( s_listener.right, source_vec );
|
||||
|
||||
if( !FBitSet( host.bugcomp, BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE ))
|
||||
{
|
||||
// don't pan sounds with no attenuation
|
||||
if( ch->dist_mult <= 0.0f ) dot = 0.0f;
|
||||
}
|
||||
|
||||
// fill out channel volumes for single location
|
||||
S_SpatializeChannel( &ch->leftvol, &ch->rightvol, ch->master_vol, gain, dot, dist * ch->dist_mult );
|
||||
|
||||
@@ -1888,7 +1894,7 @@ S_VoiceRecordStart_f
|
||||
*/
|
||||
static void S_VoiceRecordStart_f( void )
|
||||
{
|
||||
if( cls.state != ca_active || cls.legacymode )
|
||||
if( cls.state != ca_active )
|
||||
return;
|
||||
|
||||
Voice_RecordStart();
|
||||
|
||||
@@ -248,6 +248,12 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
|
||||
const char *p;
|
||||
int len;
|
||||
|
||||
// HACKHACK: some modders send strings like "/fvox/_period four"
|
||||
// which should get parsed as "_period four" said by fvox
|
||||
// it might be incorrect but ignore first slash here for now
|
||||
if( psz[0] == '/' )
|
||||
psz++;
|
||||
|
||||
// search / backwards
|
||||
p = Q_strrchr( psz, '/' );
|
||||
|
||||
@@ -595,8 +601,8 @@ static void Test_VOX_GetDirectory( void )
|
||||
{
|
||||
"", "", "vox/",
|
||||
"bark bark", "bark bark", "vox/",
|
||||
"barney/meow", "meow", "barney/"
|
||||
|
||||
"barney/meow", "meow", "barney/",
|
||||
"/fvox/_period", "_period", "fvox/",
|
||||
};
|
||||
int i;
|
||||
|
||||
|
||||
@@ -396,6 +396,9 @@ void Voice_RecordStart( void )
|
||||
{
|
||||
Voice_RecordStop();
|
||||
|
||||
if( !voice.initialized )
|
||||
return;
|
||||
|
||||
if( voice_inputfromfile.value )
|
||||
{
|
||||
voice.input_file = FS_LoadSound( "voice_input.wav", NULL, 0 );
|
||||
@@ -415,7 +418,7 @@ void Voice_RecordStart( void )
|
||||
}
|
||||
}
|
||||
|
||||
if( !Voice_IsRecording() )
|
||||
if( !Voice_IsRecording( ) && voice.device_opened )
|
||||
voice.is_recording = VoiceCapture_Activate( true );
|
||||
|
||||
if( Voice_IsRecording() )
|
||||
@@ -627,7 +630,8 @@ qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
|
||||
{
|
||||
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
|
||||
{
|
||||
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
|
||||
if( COM_CheckStringEmpty( pszCodecName ))
|
||||
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
|
||||
|
||||
// reset saved codec name, we won't enable voice for this connection
|
||||
voice_codec_init[0] = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef enum
|
||||
T_COUNT
|
||||
} cvartype_t;
|
||||
|
||||
const char *cvartypes[] = { NULL, "BOOL", "NUMBER", "LIST", "STRING" };
|
||||
static const char *const cvartypes[] = { NULL, "BOOL", "NUMBER", "LIST", "STRING" };
|
||||
|
||||
typedef struct parserstate_s
|
||||
{
|
||||
|
||||
@@ -24,18 +24,27 @@ GNU General Public License for more details.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte *data;
|
||||
int cursize;
|
||||
int maxsize;
|
||||
byte *const data;
|
||||
const int maxsize;
|
||||
int cursize;
|
||||
} cmdbuf_t;
|
||||
|
||||
qboolean cmd_wait;
|
||||
cmdbuf_t cmd_text, filteredcmd_text;
|
||||
byte cmd_text_buf[MAX_CMD_BUFFER];
|
||||
byte filteredcmd_text_buf[MAX_CMD_BUFFER];
|
||||
cmdalias_t *cmd_alias;
|
||||
uint cmd_condition;
|
||||
int cmd_condlevel;
|
||||
static qboolean cmd_wait;
|
||||
static byte cmd_text_buf[MAX_CMD_BUFFER];
|
||||
static byte filteredcmd_text_buf[MAX_CMD_BUFFER];
|
||||
static cmdbuf_t cmd_text =
|
||||
{
|
||||
.data = cmd_text_buf,
|
||||
.maxsize = ARRAYSIZE( cmd_text_buf ),
|
||||
};
|
||||
static cmdbuf_t filteredcmd_text =
|
||||
{
|
||||
.data = filteredcmd_text_buf,
|
||||
.maxsize = ARRAYSIZE( filteredcmd_text_buf ),
|
||||
};
|
||||
static cmdalias_t *cmd_alias;
|
||||
static uint cmd_condition;
|
||||
static int cmd_condlevel;
|
||||
static qboolean cmd_currentCommandIsPrivileged;
|
||||
|
||||
static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPrivileged );
|
||||
@@ -48,20 +57,6 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
============
|
||||
Cbuf_Init
|
||||
============
|
||||
*/
|
||||
static void Cbuf_Init( void )
|
||||
{
|
||||
cmd_text.data = cmd_text_buf;
|
||||
filteredcmd_text.data = filteredcmd_text_buf;
|
||||
|
||||
filteredcmd_text.maxsize = cmd_text.maxsize = MAX_CMD_BUFFER;
|
||||
filteredcmd_text.cursize = cmd_text.cursize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cbuf_Clear
|
||||
@@ -1219,13 +1214,13 @@ void Cmd_Unlink( int group )
|
||||
cmd_t **prev;
|
||||
int count = 0;
|
||||
|
||||
if( Cvar_VariableInteger( "host_gameloaded" ) && FBitSet( group, CMD_SERVERDLL ))
|
||||
if( FBitSet( group, CMD_SERVERDLL ) && Cvar_VariableInteger( "host_gameloaded" ))
|
||||
return;
|
||||
|
||||
if( Cvar_VariableInteger( "host_clientloaded" ) && FBitSet( group, CMD_CLIENTDLL ))
|
||||
if( FBitSet( group, CMD_CLIENTDLL ) && Cvar_VariableInteger( "host_clientloaded" ))
|
||||
return;
|
||||
|
||||
if( Cvar_VariableInteger( "host_gameuiloaded" ) && FBitSet( group, CMD_GAMEUIDLL ))
|
||||
if( FBitSet( group, CMD_GAMEUIDLL ) && Cvar_VariableInteger( "host_gameuiloaded" ))
|
||||
return;
|
||||
|
||||
prev = &cmd_functions;
|
||||
@@ -1387,8 +1382,6 @@ Cmd_Init
|
||||
*/
|
||||
void Cmd_Init( void )
|
||||
{
|
||||
Cbuf_Init();
|
||||
|
||||
cmd_functions = NULL;
|
||||
cmd_condition = 0;
|
||||
cmd_alias = NULL;
|
||||
|
||||
@@ -23,7 +23,7 @@ GNU General Public License for more details.
|
||||
#include "client.h"
|
||||
#include "library.h"
|
||||
|
||||
static const char *file_exts[] =
|
||||
static const char *const file_exts[] =
|
||||
{
|
||||
// ban text files that don't make sense as resource
|
||||
"cfg", "lst", "ini", "log",
|
||||
@@ -759,25 +759,6 @@ void GAME_EXPORT COM_FreeFile( void *buffer )
|
||||
free( buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
COM_NormalizeAngles
|
||||
|
||||
=============
|
||||
*/
|
||||
void COM_NormalizeAngles( vec3_t angles )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
if( angles[i] > 180.0f )
|
||||
angles[i] -= 360.0f;
|
||||
else if( angles[i] < -180.0f )
|
||||
angles[i] += 360.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
pfnGetModelType
|
||||
@@ -843,7 +824,7 @@ int GAME_EXPORT COM_CompareFileTime( const char *filename1, const char *filename
|
||||
if( ft1 == -1 || ft2 == -1 )
|
||||
return bRet;
|
||||
|
||||
*iCompare = Host_CompareFileTime( ft1, ft2 );
|
||||
*iCompare = ft1 < ft2 ? -1 : ( ft1 > ft2 ? 1 : 0 );
|
||||
bRet = 1;
|
||||
}
|
||||
|
||||
@@ -898,18 +879,40 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
char lwrfilename[4096];
|
||||
const char *first, *last;
|
||||
const char *ext;
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
if( !COM_CheckString( filename ))
|
||||
return false;
|
||||
|
||||
ext = COM_FileExtension( lwrfilename );
|
||||
ext = COM_FileExtension( filename );
|
||||
len = Q_strlen( filename );
|
||||
|
||||
// only allow extensionless files that start with !MD5
|
||||
if( !Q_strncmp( filename, "!MD5", 4 ) && ext[0] == 0 )
|
||||
if( !Q_strncmp( filename, "!MD5", 4 ))
|
||||
{
|
||||
if( COM_CheckStringEmpty( ext ))
|
||||
return false;
|
||||
|
||||
len = Q_strlen( filename );
|
||||
|
||||
if( len != 36 )
|
||||
return false;
|
||||
|
||||
for( i = 4; i < len; i++ )
|
||||
{
|
||||
if(( filename[i] >= '0' && filename[i] <= '9' ) ||
|
||||
( filename[i] >= 'A' && filename[i] <= 'F' ))
|
||||
continue;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_strnlwr( filename, lwrfilename, sizeof( lwrfilename ));
|
||||
ext = COM_FileExtension( lwrfilename );
|
||||
|
||||
if( Q_strpbrk( lwrfilename, "\\:~" ) || Q_strstr( lwrfilename, ".." ) )
|
||||
return false;
|
||||
@@ -1042,28 +1045,13 @@ void GAME_EXPORT pfnResetTutorMessageDecayData( void )
|
||||
|
||||
void Test_RunCommon( void )
|
||||
{
|
||||
char *file = (char *)"q asdf \"qwerty\" \"f \\\"f\" meowmeow\n// comment \"stuff ignored\"\nbark";
|
||||
int len;
|
||||
char buf[5];
|
||||
Msg( "Checking COM_IsSafeFileToDownload...\n" );
|
||||
|
||||
Msg( "Checking COM_ParseFile...\n" );
|
||||
|
||||
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
|
||||
TASSERT( !Q_strcmp( buf, "q" ) && len == 1);
|
||||
|
||||
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
|
||||
TASSERT( !Q_strcmp( buf, "asdf" ) && len == 4);
|
||||
|
||||
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
|
||||
TASSERT( !Q_strcmp( buf, "qwer" ) && len == -1);
|
||||
|
||||
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
|
||||
TASSERT( !Q_strcmp( buf, "f \"f" ) && len == 4);
|
||||
|
||||
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
|
||||
TASSERT( !Q_strcmp( buf, "meow" ) && len == -1);
|
||||
|
||||
file = COM_ParseFileSafe( file, buf, sizeof( buf ), 0, &len, NULL );
|
||||
TASSERT( !Q_strcmp( buf, "bark" ) && len == 4);
|
||||
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD5AAB5E8B307672DA86FBD10AC302BC732" ), true );
|
||||
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD56f1ffd8c96bd64c9c27955309f6ecfe6" ), false );
|
||||
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD5AAB5E8B307672DA86FBD10AC302B.exe" ), false );
|
||||
TASSERT_EQi( COM_IsSafeFileToDownload( "!MD5/../../valve/resource/GameMenu.res" ), false );
|
||||
TASSERT_EQi( COM_IsSafeFileToDownload( "not-a-virus-trust-me.bat" ), false );
|
||||
TASSERT_EQi( COM_IsSafeFileToDownload( "a-texture.png" ), true );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -112,6 +112,9 @@ typedef enum
|
||||
#include "con_nprint.h"
|
||||
#include "crclib.h"
|
||||
#include "ref_api.h"
|
||||
#define FSCALLBACK_OVERRIDE_OPEN
|
||||
#define FSCALLBACK_OVERRIDE_LOADFILE
|
||||
#define FSCALLBACK_OVERRIDE_MALLOC_LIKE
|
||||
#include "fscallback.h"
|
||||
|
||||
// PERFORMANCE INFO
|
||||
@@ -165,6 +168,7 @@ extern convar_t sys_timescale;
|
||||
extern convar_t cl_filterstuffcmd;
|
||||
extern convar_t rcon_password;
|
||||
extern convar_t hpk_custom_file;
|
||||
extern convar_t con_gamemaps;
|
||||
|
||||
#define Mod_AllowMaterials() ( host_allow_materials.value != 0.0f && !FBitSet( host.features, ENGINE_DISABLE_HDTEXTURES ))
|
||||
|
||||
@@ -273,6 +277,9 @@ typedef enum bugcomp_e
|
||||
// rewrites mod's attempts to write GoldSrc-specific messages into Xash protocol
|
||||
// (new wrappers are added by request)
|
||||
BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG = BIT( 1 ),
|
||||
|
||||
// makes sound with no attenuation spatialized, like in GoldSrc
|
||||
BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE = BIT( 2 ),
|
||||
} bugcomp_t;
|
||||
|
||||
typedef struct host_parm_s
|
||||
@@ -359,12 +366,49 @@ extern host_parm_t host;
|
||||
|
||||
typedef void (*xcommand_t)( void );
|
||||
|
||||
//
|
||||
// zone.c
|
||||
//
|
||||
void Memory_Init( void );
|
||||
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
ALLOC_CHECK( 3 ) WARN_UNUSED_RESULT;
|
||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||
WARN_UNUSED_RESULT;
|
||||
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
||||
void _Mem_Check( const char *filename, int fileline );
|
||||
qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data );
|
||||
void Mem_PrintList( size_t minallocationsize );
|
||||
void Mem_PrintStats( void );
|
||||
|
||||
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
||||
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
||||
#define Mem_Realloc( pool, ptr, size ) _Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
||||
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
||||
#define Mem_AllocPool( name ) _Mem_AllocPool( name, __FILE__, __LINE__ )
|
||||
#define Mem_FreePool( pool ) _Mem_FreePool( pool, __FILE__, __LINE__ )
|
||||
#define Mem_EmptyPool( pool ) _Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
||||
#define Mem_IsAllocated( mem ) Mem_IsAllocatedExt( NULL, mem )
|
||||
#define Mem_Check() _Mem_Check( __FILE__, __LINE__ )
|
||||
|
||||
//
|
||||
// filesystem_engine.c
|
||||
//
|
||||
void FS_Init( const char *basedir );
|
||||
void FS_Shutdown( void );
|
||||
void *FS_GetNativeObject( const char *obj );
|
||||
int FS_Close( file_t *file );
|
||||
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )
|
||||
MALLOC_LIKE( FS_Close, 1 ) WARN_UNUSED_RESULT;
|
||||
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
|
||||
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||
|
||||
//
|
||||
// cmd.c
|
||||
@@ -397,30 +441,6 @@ void Cmd_ExecuteString( const char *text );
|
||||
void Cmd_ForwardToServer( void );
|
||||
void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
|
||||
|
||||
//
|
||||
// zone.c
|
||||
//
|
||||
void Memory_Init( void );
|
||||
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
||||
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
||||
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
|
||||
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
||||
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||
void _Mem_Check( const char *filename, int fileline );
|
||||
qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data );
|
||||
void Mem_PrintList( size_t minallocationsize );
|
||||
void Mem_PrintStats( void );
|
||||
|
||||
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
|
||||
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )
|
||||
#define Mem_Realloc( pool, ptr, size ) _Mem_Realloc( pool, ptr, size, true, __FILE__, __LINE__ )
|
||||
#define Mem_Free( mem ) _Mem_Free( mem, __FILE__, __LINE__ )
|
||||
#define Mem_AllocPool( name ) _Mem_AllocPool( name, __FILE__, __LINE__ )
|
||||
#define Mem_FreePool( pool ) _Mem_FreePool( pool, __FILE__, __LINE__ )
|
||||
#define Mem_EmptyPool( pool ) _Mem_EmptyPool( pool, __FILE__, __LINE__ )
|
||||
#define Mem_IsAllocated( mem ) Mem_IsAllocatedExt( NULL, mem )
|
||||
#define Mem_Check() _Mem_Check( __FILE__, __LINE__ )
|
||||
|
||||
//
|
||||
// imagelib
|
||||
@@ -431,10 +451,10 @@ void Image_Setup( void );
|
||||
void Image_Init( void );
|
||||
void Image_Shutdown( void );
|
||||
void Image_AddCmdFlags( uint flags );
|
||||
rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size );
|
||||
qboolean FS_SaveImage( const char *filename, rgbdata_t *pix );
|
||||
rgbdata_t *FS_CopyImage( rgbdata_t *in );
|
||||
void FS_FreeImage( rgbdata_t *pack );
|
||||
rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size ) MALLOC_LIKE( FS_FreeImage, 1 ) WARN_UNUSED_RESULT;
|
||||
qboolean FS_SaveImage( const char *filename, rgbdata_t *pix );
|
||||
rgbdata_t *FS_CopyImage( rgbdata_t *in ) MALLOC_LIKE( FS_FreeImage, 1 ) WARN_UNUSED_RESULT;
|
||||
extern const bpc_desc_t PFDesc[]; // image get pixelformat
|
||||
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float reserved );
|
||||
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size );
|
||||
@@ -489,14 +509,14 @@ typedef struct
|
||||
//
|
||||
void Sound_Init( void );
|
||||
void Sound_Shutdown( void );
|
||||
wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size );
|
||||
void FS_FreeSound( wavdata_t *pack );
|
||||
stream_t *FS_OpenStream( const char *filename );
|
||||
void FS_FreeStream( stream_t *stream );
|
||||
wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size ) MALLOC_LIKE( FS_FreeSound, 1 ) WARN_UNUSED_RESULT;
|
||||
stream_t *FS_OpenStream( const char *filename ) MALLOC_LIKE( FS_FreeStream, 1 ) WARN_UNUSED_RESULT;
|
||||
wavdata_t *FS_StreamInfo( stream_t *stream );
|
||||
int FS_ReadStream( stream_t *stream, int bytes, void *buffer );
|
||||
int FS_SetStreamPos( stream_t *stream, int newpos );
|
||||
int FS_GetStreamPos( stream_t *stream );
|
||||
void FS_FreeStream( stream_t *stream );
|
||||
qboolean Sound_Process( wavdata_t **wav, int rate, int width, int channels, uint flags );
|
||||
uint Sound_GetApproxWavePlayLen( const char *filepath );
|
||||
qboolean Sound_SupportedFileFormat( const char *fileext );
|
||||
@@ -509,7 +529,6 @@ typedef void( *pfnChangeGame )( const char *progname );
|
||||
qboolean Host_IsQuakeCompatible( void );
|
||||
void EXPORT Host_Shutdown( void );
|
||||
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
|
||||
int Host_CompareFileTime( int ft1, int ft2 );
|
||||
void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
|
||||
void Host_AbortCurrentFrame( void ) NORETURN;
|
||||
void Host_WriteServerConfig( const char *name );
|
||||
@@ -518,7 +537,7 @@ void Host_WriteVideoConfig( void );
|
||||
void Host_WriteConfig( void );
|
||||
void Host_ShutdownServer( void );
|
||||
void Host_Error( const char *error, ... ) _format( 1 );
|
||||
void Host_ValidateEngineFeatures( uint32_t features );
|
||||
void Host_ValidateEngineFeatures( uint32_t mask, uint32_t features );
|
||||
void Host_Frame( double time );
|
||||
void Host_Credits( void );
|
||||
|
||||
@@ -561,7 +580,7 @@ qboolean SV_Active( void );
|
||||
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 );
|
||||
byte* COM_LoadFileForMe( const char *filename, int *pLength );
|
||||
byte *COM_LoadFileForMe( const char *filename, int *pLength ) MALLOC_LIKE( free, 1 );
|
||||
qboolean COM_IsSafeFileToDownload( const char *filename );
|
||||
cvar_t *pfnCVarGetPointer( const char *szVarName );
|
||||
int pfnDrawConsoleString( int x, int y, char *string );
|
||||
@@ -651,6 +670,15 @@ void HPAK_FlushHostQueue( void );
|
||||
#define INPUT_DEVICE_JOYSTICK (1<<2)
|
||||
#define INPUT_DEVICE_VR (1<<3)
|
||||
|
||||
|
||||
typedef enum connprotocol_e
|
||||
{
|
||||
PROTO_CURRENT = 0, // Xash3D 49
|
||||
PROTO_LEGACY, // Xash3D 48
|
||||
PROTO_QUAKE, // Quake 15
|
||||
PROTO_GOLDSRC, // GoldSrc 48
|
||||
} connprotocol_t;
|
||||
|
||||
// shared calls
|
||||
struct physent_s;
|
||||
struct sv_client_s;
|
||||
@@ -661,10 +689,9 @@ qboolean CL_IsThirdPerson( void );
|
||||
qboolean CL_IsIntermission( void );
|
||||
qboolean CL_Initialized( void );
|
||||
char *CL_Userinfo( void );
|
||||
void CL_LegacyUpdateInfo( void );
|
||||
void CL_CharEvent( int key );
|
||||
qboolean CL_DisableVisibility( void );
|
||||
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength );
|
||||
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength ) MALLOC_LIKE( free, 1 );
|
||||
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
|
||||
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
|
||||
struct cmdalias_s *Cmd_AliasGetList( void );
|
||||
@@ -742,13 +769,34 @@ void UI_ShowConnectionWarning( void );
|
||||
void Cmd_Null_f( void );
|
||||
void Rcon_Print( host_redirect_t *rd, const char *pMsg );
|
||||
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
|
||||
void COM_NormalizeAngles( vec3_t angles );
|
||||
int COM_FileSize( const char *filename );
|
||||
void COM_FreeFile( void *buffer );
|
||||
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
|
||||
char *va( const char *format, ... ) _format( 1 );
|
||||
qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer );
|
||||
|
||||
static inline void COM_NormalizeAngles( vec3_t angles )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
if( angles[i] > 180.0f )
|
||||
angles[i] -= 360.0f;
|
||||
else if( angles[i] < -180.0f )
|
||||
angles[i] += 360.0f;
|
||||
}
|
||||
}
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
connprotocol_t CL_Protocol( void );
|
||||
#else
|
||||
static inline connprotocol_t CL_Protocol( void )
|
||||
{
|
||||
return PROTO_CURRENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline qboolean Host_IsLocalGame( void )
|
||||
{
|
||||
if( SV_Active( ))
|
||||
@@ -798,6 +846,16 @@ void NET_MasterClear( void );
|
||||
void NET_MasterShutdown( void );
|
||||
qboolean NET_GetMaster( netadr_t from, uint *challenge, double *last_heartbeat );
|
||||
|
||||
//
|
||||
// munge.c
|
||||
//
|
||||
void COM_Munge( byte *data, size_t len, int seq );
|
||||
void COM_UnMunge( byte *data, size_t len, int seq );
|
||||
void COM_Munge2( byte *data, size_t len, int seq );
|
||||
void COM_UnMunge2( byte *data, size_t len, int seq );
|
||||
void COM_Munge3( byte *data, size_t len, int seq );
|
||||
void COM_UnMunge3( byte *data, size_t len, int seq );
|
||||
|
||||
//
|
||||
// sounds.c
|
||||
//
|
||||
|
||||
@@ -18,8 +18,6 @@ GNU General Public License for more details.
|
||||
#include "const.h"
|
||||
#include "kbutton.h"
|
||||
|
||||
extern convar_t con_gamemaps;
|
||||
|
||||
#define CON_MAXCMDS 4096 // auto-complete intermediate list
|
||||
|
||||
typedef struct autocomplete_list_s
|
||||
@@ -1012,7 +1010,7 @@ int GAME_EXPORT Cmd_CheckMapsList( int fRefresh )
|
||||
return Cmd_CheckMapsList_R( fRefresh, true );
|
||||
}
|
||||
|
||||
autocomplete_list_t cmd_list[] =
|
||||
static const autocomplete_list_t cmd_list[] =
|
||||
{
|
||||
{ "map_background", 1, Cmd_GetMapList },
|
||||
{ "changelevel2", 1, Cmd_GetMapList },
|
||||
@@ -1075,7 +1073,7 @@ for various cmds
|
||||
*/
|
||||
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
|
||||
{
|
||||
autocomplete_list_t *list;
|
||||
const autocomplete_list_t *list;
|
||||
|
||||
for( list = cmd_list; list->name; list++ )
|
||||
{
|
||||
|
||||
@@ -18,17 +18,17 @@ GNU General Public License for more details.
|
||||
#include "base_cmd.h"
|
||||
#include "eiface.h" // ARRAYSIZE
|
||||
|
||||
convar_t *cvar_vars = NULL; // head of list
|
||||
static 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" );
|
||||
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
typedef struct cvar_filter_quirks_s
|
||||
{
|
||||
const char *gamedir; // gamedir to enable for
|
||||
const char *cvars; // list of cvars should be excluded from filter
|
||||
} cvar_filter_quirks_t;
|
||||
|
||||
static cvar_filter_quirks_t cvar_filter_quirks[] =
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
static const cvar_filter_quirks_t cvar_filter_quirks[] =
|
||||
{
|
||||
// EXAMPLE:
|
||||
//{
|
||||
@@ -44,10 +44,10 @@ static cvar_filter_quirks_t cvar_filter_quirks[] =
|
||||
"cl_dodmusic" // Day of Defeat Beta 1.3 cvar
|
||||
},
|
||||
};
|
||||
|
||||
static cvar_filter_quirks_t *cvar_active_filter_quirks = NULL;
|
||||
#endif
|
||||
|
||||
static const cvar_filter_quirks_t *cvar_active_filter_quirks = NULL;
|
||||
|
||||
CVAR_DEFINE_AUTO( cl_filterstuffcmd, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "filter commands coming from server" );
|
||||
|
||||
/*
|
||||
@@ -70,15 +70,14 @@ find the specified variable by name
|
||||
*/
|
||||
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group )
|
||||
{
|
||||
// TODO: ignore group for cvar
|
||||
#if defined(XASH_HASHED_VARS)
|
||||
return (convar_t *)BaseCmd_Find( HM_CVAR, var_name );
|
||||
#else
|
||||
convar_t *var;
|
||||
convar_t *var;
|
||||
|
||||
if( !var_name )
|
||||
return NULL;
|
||||
|
||||
#if defined(XASH_HASHED_VARS) // TODO: ignore_group
|
||||
var = BaseCmd_Find( HM_CVAR, var_name );
|
||||
#else
|
||||
for( var = cvar_vars; var; var = var->next )
|
||||
{
|
||||
if( ignore_group && FBitSet( ignore_group, var->flags ))
|
||||
@@ -87,9 +86,13 @@ convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group )
|
||||
if( !Q_stricmp( var_name, var->name ))
|
||||
return var;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
// HACKHACK: HL25 compatibility
|
||||
if( !var && !Q_stricmp( var_name, "gl_widescreen_yfov" ))
|
||||
var = Cvar_FindVarExt( "r_adjust_fov", ignore_group );
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -272,6 +275,15 @@ static qboolean Cvar_ValidateVarName( const char *s, qboolean isvalue )
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Cvar_Free( convar_t *var )
|
||||
{
|
||||
freestring( var->name );
|
||||
freestring( var->string );
|
||||
freestring( var->def_string );
|
||||
freestring( var->desc );
|
||||
Mem_Free( var );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_UnlinkVar
|
||||
@@ -311,17 +323,13 @@ static int Cvar_UnlinkVar( const char *var_name, int group )
|
||||
#endif
|
||||
|
||||
// unlink variable from list
|
||||
freestring( var->string );
|
||||
*prev = var->next;
|
||||
|
||||
// only allocated cvars can throw these fields
|
||||
if( FBitSet( var->flags, FCVAR_ALLOCATED ))
|
||||
{
|
||||
freestring( var->name );
|
||||
freestring( var->def_string );
|
||||
freestring( var->desc );
|
||||
Mem_Free( var );
|
||||
}
|
||||
Cvar_Free( var );
|
||||
else
|
||||
freestring( var->string );
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -610,7 +618,7 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
||||
return Cvar_Get( var_name, value, FCVAR_USER_CREATED, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if( !Cmd_CurrentCommandIsPrivileged( ))
|
||||
{
|
||||
if( FBitSet( var->flags, FCVAR_PRIVILEGED ))
|
||||
@@ -966,7 +974,6 @@ static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
|
||||
if( cl_filterstuffcmd.value <= 0.0f )
|
||||
return true;
|
||||
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
// check if game-specific filter exceptions should be applied
|
||||
// TODO: for cmd exceptions, make generic function
|
||||
if( cvar_active_filter_quirks )
|
||||
@@ -997,7 +1004,6 @@ static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( FBitSet( v->flags, FCVAR_FILTERABLE ))
|
||||
return false;
|
||||
@@ -1217,6 +1223,20 @@ static void Cvar_List_f( void )
|
||||
Con_Printf( "\n%i cvars\n", count );
|
||||
}
|
||||
|
||||
static qboolean Cvar_ValidateUnlinkGroup( int group )
|
||||
{
|
||||
if( FBitSet( group, FCVAR_EXTDLL ) && !Cvar_VariableInteger( "host_gameloaded" ))
|
||||
return false;
|
||||
|
||||
if( FBitSet( group, FCVAR_CLIENTDLL ) && !Cvar_VariableInteger( "host_clientloaded" ))
|
||||
return false;
|
||||
|
||||
if( FBitSet( group, FCVAR_GAMEUIDLL ) && !Cvar_VariableInteger( "host_gameuiloaded" ))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Unlink
|
||||
@@ -1228,19 +1248,95 @@ void Cvar_Unlink( int group )
|
||||
{
|
||||
int count;
|
||||
|
||||
if( Cvar_VariableInteger( "host_gameloaded" ) && FBitSet( group, FCVAR_EXTDLL ))
|
||||
return;
|
||||
|
||||
if( Cvar_VariableInteger( "host_clientloaded" ) && FBitSet( group, FCVAR_CLIENTDLL ))
|
||||
return;
|
||||
|
||||
if( Cvar_VariableInteger( "host_gameuiloaded" ) && FBitSet( group, FCVAR_GAMEUIDLL ))
|
||||
if( !Cvar_ValidateUnlinkGroup( group ))
|
||||
return;
|
||||
|
||||
count = Cvar_UnlinkVar( NULL, group );
|
||||
Con_Reportf( "unlink %i cvars\n", count );
|
||||
}
|
||||
|
||||
pending_cvar_t *Cvar_PrepareToUnlink( int group )
|
||||
{
|
||||
pending_cvar_t *list = NULL;
|
||||
pending_cvar_t *tail = NULL;
|
||||
convar_t *cv;
|
||||
|
||||
for( cv = cvar_vars; cv != NULL; cv = cv->next )
|
||||
{
|
||||
size_t namelen;
|
||||
pending_cvar_t *p;
|
||||
|
||||
if( !FBitSet( cv->flags, group ))
|
||||
continue;
|
||||
|
||||
namelen = Q_strlen( cv->name ) + 1;
|
||||
p = Mem_Malloc( host.mempool, sizeof( *list ) + namelen );
|
||||
p->next = NULL;
|
||||
p->cv_cur = cv;
|
||||
p->cv_next = cv->next;
|
||||
p->cv_allocated = FBitSet( cv->flags, FCVAR_ALLOCATED ) ? true : false;
|
||||
Q_strncpy( p->cv_name, cv->name, namelen );
|
||||
|
||||
if( list == NULL )
|
||||
list = p;
|
||||
else
|
||||
tail->next = p;
|
||||
|
||||
tail = p;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void Cvar_UnlinkPendingCvars( pending_cvar_t *list )
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
while( list != NULL )
|
||||
{
|
||||
pending_cvar_t *next = list->next;
|
||||
convar_t *cv_prev, *cv;
|
||||
|
||||
for( cv_prev = NULL, cv = cvar_vars; cv != NULL; cv_prev = cv, cv = cv->next )
|
||||
{
|
||||
if( cv == list->cv_cur )
|
||||
break;
|
||||
}
|
||||
|
||||
if( cv == NULL )
|
||||
{
|
||||
Con_Reportf( "%s: can't find %s in variable list\n", __func__, list->cv_name );
|
||||
Mem_Free( list );
|
||||
list = next;
|
||||
continue;
|
||||
}
|
||||
|
||||
// unlink cvar from list
|
||||
BaseCmd_Remove( HM_CVAR, list->cv_name );
|
||||
if( cv_prev != NULL )
|
||||
cv_prev->next = list->cv_next;
|
||||
else cvar_vars = list->cv_next;
|
||||
|
||||
if( list->cv_allocated )
|
||||
Cvar_Free( list->cv_cur );
|
||||
else
|
||||
{
|
||||
// TODO: can't free cvar string here because
|
||||
// it's not safe to access cv_cur and
|
||||
// can't save string pointer because it could've been changed
|
||||
// and pointer to it is already lost
|
||||
// freestring( list->cv_string );
|
||||
}
|
||||
|
||||
// now free pending cvar
|
||||
Mem_Free( list );
|
||||
list = next;
|
||||
count++;
|
||||
}
|
||||
|
||||
Con_Reportf( "unlink %i cvars\n", count );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Init
|
||||
|
||||
@@ -18,6 +18,18 @@ GNU General Public License for more details.
|
||||
|
||||
#include "cvardef.h"
|
||||
|
||||
// As some mods dynamically allocate cvars and free them without notifying the engine
|
||||
// let's construct a list of cvars that must be removed
|
||||
typedef struct pending_cvar_s
|
||||
{
|
||||
struct pending_cvar_s *next;
|
||||
|
||||
convar_t *cv_cur; // preserve the data that might get freed
|
||||
convar_t *cv_next;
|
||||
qboolean cv_allocated; // if it's allocated by us, it's safe to access cv_cur
|
||||
char cv_name[];
|
||||
} pending_cvar_t;
|
||||
|
||||
cvar_t *Cvar_GetList( void );
|
||||
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
|
||||
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
|
||||
@@ -43,4 +55,7 @@ void Cvar_Init( void );
|
||||
void Cvar_PostFSInit( void );
|
||||
void Cvar_Unlink( int group );
|
||||
|
||||
pending_cvar_t *Cvar_PrepareToUnlink( int group );
|
||||
void Cvar_UnlinkPendingCvars( pending_cvar_t *pending_cvars );
|
||||
|
||||
#endif//CVAR_H
|
||||
|
||||
@@ -16,12 +16,37 @@ GNU General Public License for more details.
|
||||
#include "common.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "ref_api.h"
|
||||
#include "server.h"
|
||||
|
||||
ref_globals_t refState;
|
||||
|
||||
void CL_ProcessFile( qboolean successfully_received, const char *filename )
|
||||
const char *CL_MsgInfo( int cmd )
|
||||
{
|
||||
static string sz;
|
||||
|
||||
Q_strncpy( sz, "???", sizeof( sz ));
|
||||
|
||||
if( cmd >= 0 && cmd <= svc_lastmsg )
|
||||
{
|
||||
// get engine message name
|
||||
const char *svc_string = svc_strings[cmd];
|
||||
|
||||
Q_strncpy( sz, svc_string, sizeof( sz ));
|
||||
}
|
||||
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_USER_MESSAGES; i++ )
|
||||
{
|
||||
if( svgame.msg[i].number == cmd )
|
||||
{
|
||||
Q_strncpy( sz, svgame.msg[i].name, sizeof( sz ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
int GAME_EXPORT CL_Active( void )
|
||||
@@ -134,11 +159,6 @@ void GAME_EXPORT S_StopSound(int entnum, int channel, const char *soundname)
|
||||
|
||||
}
|
||||
|
||||
int S_GetCurrentStaticSounds( soundlist_t *pout, int size )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GAME_EXPORT CL_GetMaxClients( void )
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -27,6 +27,31 @@ fs_globals_t *FI;
|
||||
static pfnCreateInterface_t fs_pfnCreateInterface;
|
||||
static HINSTANCE fs_hInstance;
|
||||
|
||||
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||
{
|
||||
return g_fsapi.Search( pattern, caseinsensitive, gamedironly );
|
||||
}
|
||||
|
||||
int FS_Close( file_t *file )
|
||||
{
|
||||
return g_fsapi.Close( file );
|
||||
}
|
||||
|
||||
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )
|
||||
{
|
||||
return g_fsapi.Open( filepath, mode, gamedironly );
|
||||
}
|
||||
|
||||
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||
{
|
||||
return g_fsapi.LoadFile( path, filesizeptr, gamedironly );
|
||||
}
|
||||
|
||||
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
|
||||
{
|
||||
return g_fsapi.LoadDirectFile( path, filesizeptr );
|
||||
}
|
||||
|
||||
static void COM_StripDirectorySlash( char *pname )
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@@ -40,7 +40,7 @@ GNU General Public License for more details.
|
||||
#include "render_api.h" // decallist_t
|
||||
#include "tests.h"
|
||||
|
||||
pfnChangeGame pChangeGame = NULL;
|
||||
static pfnChangeGame pChangeGame = NULL;
|
||||
host_parm_t host; // host parms
|
||||
|
||||
#ifdef XASH_ENGINE_TESTS
|
||||
@@ -49,8 +49,8 @@ struct tests_stats_s tests_stats;
|
||||
|
||||
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
|
||||
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" );
|
||||
CVAR_DEFINE_AUTO( sys_ticrate, "100", FCVAR_SERVER, "framerate in dedicated mode" );
|
||||
|
||||
static CVAR_DEFINE_AUTO( sys_ticrate, "100", FCVAR_SERVER, "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" );
|
||||
@@ -69,13 +69,14 @@ typedef struct feature_message_s
|
||||
const char *arg;
|
||||
} feature_message_t;
|
||||
|
||||
static feature_message_t bugcomp_features[] =
|
||||
static const feature_message_t bugcomp_features[] =
|
||||
{
|
||||
{ BUGCOMP_PENTITYOFENTINDEX_FLAG, "pfnPEntityOfEntIndex bugfix revert", "peoei" },
|
||||
{ BUGCOMP_MESSAGE_REWRITE_FACILITY_FLAG, "GoldSrc Message Rewrite Facility", "gsmrf" },
|
||||
{ BUGCOMP_SPATIALIZE_SOUND_WITH_ATTN_NONE, "spatialize sounds with zero attenuation", "sp_attn_none" },
|
||||
};
|
||||
|
||||
static feature_message_t engine_features[] =
|
||||
static const feature_message_t engine_features[] =
|
||||
{
|
||||
{ ENGINE_WRITE_LARGE_COORD, "Big World Support" },
|
||||
{ ENGINE_QUAKE_COMPATIBLE, "Quake Compatibility" },
|
||||
@@ -199,19 +200,6 @@ static void Sys_PrintUsage( const char *exename )
|
||||
Sys_Quit();
|
||||
}
|
||||
|
||||
int Host_CompareFileTime( int ft1, int ft2 )
|
||||
{
|
||||
if( ft1 < ft2 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if( ft1 > ft2 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Host_ShutdownServer( void )
|
||||
{
|
||||
SV_Shutdown( "Server was killed\n" );
|
||||
@@ -222,7 +210,7 @@ void Host_ShutdownServer( void )
|
||||
Host_PrintEngineFeatures
|
||||
================
|
||||
*/
|
||||
static void Host_PrintFeatures( uint32_t flags, const char *s, feature_message_t *features, size_t size )
|
||||
static void Host_PrintFeatures( uint32_t flags, const char *s, const feature_message_t *features, size_t size )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -240,15 +228,8 @@ Host_ValidateEngineFeatures
|
||||
validate features bits and set host.features
|
||||
==============
|
||||
*/
|
||||
void Host_ValidateEngineFeatures( uint32_t features )
|
||||
void Host_ValidateEngineFeatures( uint32_t mask, uint32_t features )
|
||||
{
|
||||
uint32_t mask = ENGINE_FEATURES_MASK;
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
if( !Host_IsDedicated( ) && cls.legacymode )
|
||||
mask = ENGINE_LEGACY_FEATURES_MASK;
|
||||
#endif
|
||||
|
||||
// don't allow unsupported bits
|
||||
features &= mask;
|
||||
|
||||
@@ -1071,6 +1052,9 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
|
||||
Host_RunTests( 0 );
|
||||
#endif
|
||||
|
||||
#if XASH_DEDICATED
|
||||
Platform_SetupSigtermHandling();
|
||||
#endif
|
||||
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED );
|
||||
FS_Init( basedir );
|
||||
|
||||
|
||||
@@ -1055,7 +1055,7 @@ static void HPAK_Extract_f( void )
|
||||
FS_Seek( f, entry->filepos, SEEK_SET );
|
||||
FS_Read( f, pData, nDataSize );
|
||||
|
||||
Q_snprintf( szFileOut, sizeof( szFileOut ), "hpklmps\\lmp%04i.bmp", nCurrent );
|
||||
Q_snprintf( szFileOut, sizeof( szFileOut ), "hpklmps/lmp%04i.bmp", nCurrent );
|
||||
FS_WriteFile( szFileOut, pData, nDataSize );
|
||||
if( pData ) Mem_Free( pData );
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ void Image_Reset( void )
|
||||
image.size = 0;
|
||||
}
|
||||
|
||||
static rgbdata_t *ImagePack( void )
|
||||
static MALLOC_LIKE( FS_FreeImage, 1 ) rgbdata_t *ImagePack( void )
|
||||
{
|
||||
rgbdata_t *pack;
|
||||
|
||||
@@ -547,7 +547,7 @@ static void Test_CheckImage( const char *name, rgbdata_t *rgb )
|
||||
TASSERT( load->size == rgb->size )
|
||||
TASSERT( memcmp(load->buffer, rgb->buffer, rgb->size ) == 0 )
|
||||
|
||||
Mem_Free( load );
|
||||
FS_FreeImage( load );
|
||||
}
|
||||
|
||||
void Test_RunImagelib( void )
|
||||
|
||||
@@ -126,20 +126,14 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
static void COM_GenerateCommonLibraryName( const char *name, const char *ext, const char *suffix, char *out, size_t size )
|
||||
static void COM_GenerateCommonLibraryName( const char *name, const char *ext, char *out, size_t size )
|
||||
{
|
||||
#if ( XASH_WIN32 || XASH_LINUX || XASH_APPLE ) && XASH_X86
|
||||
if( suffix )
|
||||
Q_snprintf( out, size, "%s_%s.%s", name, suffix, ext );
|
||||
else Q_snprintf( out, size, "%s.%s", name, ext );
|
||||
Q_snprintf( out, size, "%s.%s", name, ext );
|
||||
#elif ( XASH_WIN32 || XASH_LINUX || XASH_APPLE )
|
||||
if( suffix )
|
||||
Q_snprintf( out, size, "%s_%s_%s.%s", name, Q_buildarch(), suffix, ext );
|
||||
else Q_snprintf( out, size, "%s_%s.%s", name, Q_buildarch(), ext );
|
||||
Q_snprintf( out, size, "%s_%s.%s", name, Q_buildarch(), ext );
|
||||
#else
|
||||
if( suffix )
|
||||
Q_snprintf( out, size, "%s_%s_%s_%s.%s", name, Q_buildos(), Q_buildarch(), suffix, ext );
|
||||
else Q_snprintf( out, size, "%s_%s_%s.%s", name, Q_buildos(), Q_buildarch(), ext );
|
||||
Q_snprintf( out, size, "%s_%s_%s.%s", name, Q_buildos(), Q_buildarch(), ext );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -160,7 +154,7 @@ static void COM_GenerateClientLibraryPath( const char *name, char *out, size_t s
|
||||
// we don't have any library prefixes, so we can safely append dll_path here
|
||||
Q_snprintf( dllpath, sizeof( dllpath ), "%s/%s", GI->dll_path, name );
|
||||
|
||||
COM_GenerateCommonLibraryName( dllpath, OS_LIB_EXT, NULL, out, size );
|
||||
COM_GenerateCommonLibraryName( dllpath, OS_LIB_EXT, out, size );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -217,13 +211,7 @@ static void COM_GenerateServerLibraryPath( char *out, size_t size )
|
||||
COM_StripExtension( dllpath );
|
||||
COM_StripIntelSuffix( dllpath );
|
||||
|
||||
#if XASH_ARCH_USES_ONLY_ABI2
|
||||
COM_GenerateCommonLibraryName( dllpath, ext, NULL, out, size );
|
||||
#elif XASH_64BIT
|
||||
COM_GenerateCommonLibraryName( dllpath, ext, "st64", out, size );
|
||||
#else
|
||||
COM_GenerateCommonLibraryName( dllpath, ext, NULL, out, size );
|
||||
#endif
|
||||
COM_GenerateCommonLibraryName( dllpath, ext, out, size );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ typedef struct master_s
|
||||
struct master_s *next;
|
||||
qboolean sent; // TODO: get rid of this internal state
|
||||
qboolean save;
|
||||
qboolean v6only;
|
||||
string address;
|
||||
netadr_t adr; // temporary, rewritten after each send
|
||||
|
||||
@@ -45,7 +46,7 @@ NET_GetMasterHostByName
|
||||
*/
|
||||
static net_gai_state_t NET_GetMasterHostByName( master_t *m )
|
||||
{
|
||||
net_gai_state_t res = NET_StringToAdrNB( m->address, &m->adr );
|
||||
net_gai_state_t res = NET_StringToAdrNB( m->address, &m->adr, m->v6only );
|
||||
|
||||
if( res == NET_EAI_OK )
|
||||
return res;
|
||||
@@ -251,7 +252,7 @@ NET_AddMaster
|
||||
Add master to the list
|
||||
========================
|
||||
*/
|
||||
static void NET_AddMaster( const char *addr, qboolean save )
|
||||
static void NET_AddMaster( const char *addr, qboolean save, qboolean v6only )
|
||||
{
|
||||
master_t *master, *last;
|
||||
|
||||
@@ -261,10 +262,11 @@ static void NET_AddMaster( const char *addr, qboolean save )
|
||||
return;
|
||||
}
|
||||
|
||||
master = Mem_Malloc( host.mempool, sizeof( master_t ) );
|
||||
master = Mem_Malloc( host.mempool, sizeof( *master ) );
|
||||
Q_strncpy( master->address, addr, sizeof( master->address ));
|
||||
master->sent = false;
|
||||
master->save = save;
|
||||
master->v6only = v6only;
|
||||
master->next = NULL;
|
||||
master->adr.type = 0;
|
||||
|
||||
@@ -283,7 +285,7 @@ static void NET_AddMaster_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
NET_AddMaster( Cmd_Argv( 1 ), true ); // save them into config
|
||||
NET_AddMaster( Cmd_Argv( 1 ), true, false ); // save them into config
|
||||
ml.modified = true; // save config
|
||||
}
|
||||
|
||||
@@ -316,15 +318,14 @@ static void NET_ListMasters_f( void )
|
||||
master_t *list;
|
||||
int i;
|
||||
|
||||
Msg( "Master servers\n=============\n" );
|
||||
|
||||
Con_Printf( "Master servers:\n" );
|
||||
|
||||
for( i = 1, list = ml.list; list; i++, list = list->next )
|
||||
{
|
||||
Msg( "%d\t%s", i, list->address );
|
||||
Con_Printf( "%d\t%s", i, list->address );
|
||||
if( list->adr.type != 0 )
|
||||
Msg( "\t%s\n", NET_AdrToString( list->adr ));
|
||||
else Msg( "\n" );
|
||||
Con_Printf( "\t%s\n", NET_AdrToString( list->adr ));
|
||||
else Con_Printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +355,15 @@ static void NET_LoadMasters( void )
|
||||
// format: master <addr>\n
|
||||
while( ( pfile = COM_ParseFile( pfile, token, sizeof( token ) ) ) )
|
||||
{
|
||||
if( !Q_strcmp( token, "master" ) ) // load addr
|
||||
if( !Q_strcmp( token, "master" )) // load addr
|
||||
{
|
||||
pfile = COM_ParseFile( pfile, token, sizeof( token ) );
|
||||
|
||||
NET_AddMaster( token, true );
|
||||
NET_AddMaster( token, true, false );
|
||||
}
|
||||
else if( !Q_strcmp( token, "master6" ))
|
||||
{
|
||||
pfile = COM_ParseFile( pfile, token, sizeof( token ) );
|
||||
NET_AddMaster( token, true, true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +401,7 @@ void NET_SaveMasters( void )
|
||||
for( m = ml.list; m; m = m->next )
|
||||
{
|
||||
if( m->save )
|
||||
FS_Printf( f, "master %s\n", m->address );
|
||||
FS_Printf( f, "%s %s\n", m->v6only ? "master6" : "master", m->address );
|
||||
}
|
||||
|
||||
FS_Close( f );
|
||||
@@ -418,10 +423,10 @@ void NET_InitMasters( void )
|
||||
Cvar_RegisterVariable( &sv_verbose_heartbeats );
|
||||
|
||||
// keep main master always there
|
||||
NET_AddMaster( MASTERSERVER_ADR, false );
|
||||
NET_AddMaster( "aaaa.mentality.rip:27010", false ); // IPv6-only
|
||||
NET_AddMaster( "mentality.rip:27011", false ); // testing server, might be offline
|
||||
NET_AddMaster( "aaaa.mentality.rip:27011", false ); // IPv6-only, testing server, might be offline
|
||||
NET_AddMaster( MASTERSERVER_ADR, false, false );
|
||||
NET_AddMaster( "aaaa.mentality.rip:27010", false, true ); // IPv6-only
|
||||
NET_AddMaster( "mentality.rip:27011", false, false ); // testing server, might be offline
|
||||
NET_AddMaster( "aaaa.mentality.rip:27011", false, true ); // IPv6-only, testing server, might be offline
|
||||
|
||||
NET_LoadMasters( );
|
||||
}
|
||||
|
||||
@@ -30,13 +30,6 @@ GNU General Public License for more details.
|
||||
|
||||
#define MIPTEX_CUSTOM_PALETTE_SIZE_BYTES ( sizeof( int16_t ) + 768 )
|
||||
|
||||
typedef struct wadlist_s
|
||||
{
|
||||
char wadnames[MAX_MAP_WADS][32];
|
||||
int wadusage[MAX_MAP_WADS];
|
||||
int count;
|
||||
} wadlist_t;
|
||||
|
||||
typedef struct leaflist_s
|
||||
{
|
||||
int count;
|
||||
@@ -136,7 +129,6 @@ typedef struct
|
||||
dclipnode32_t *clipnodes_out; // temporary 32-bit array to hold clipnodes
|
||||
|
||||
// misc stuff
|
||||
wadlist_t wadlist;
|
||||
int lightmap_samples; // samples per lightmap (1 or 3)
|
||||
int version; // model version
|
||||
qboolean isworld;
|
||||
@@ -206,7 +198,7 @@ static mlumpinfo_t srclumps[HEADER_LUMPS] =
|
||||
{ LUMP_MODELS, 1, MAX_MAP_MODELS, sizeof( dmodel_t ), -1, "models", CHECK_OVERFLOW, (const void **)&srcmodel.submodels, &srcmodel.numsubmodels },
|
||||
};
|
||||
|
||||
static mlumpinfo_t extlumps[EXTRA_LUMPS] =
|
||||
static const mlumpinfo_t extlumps[EXTRA_LUMPS] =
|
||||
{
|
||||
{ LUMP_LIGHTVECS, 0, MAX_MAP_LIGHTING, sizeof( byte ), -1, "deluxmaps", USE_EXTRAHEADER, (const void **)&srcmodel.deluxdata, &srcmodel.deluxdatasize },
|
||||
{ LUMP_FACEINFO, 0, MAX_MAP_FACEINFO, sizeof( dfaceinfo_t ), -1, "faceinfos", CHECK_OVERFLOW|USE_EXTRAHEADER, (const void **)&srcmodel.faceinfo, &srcmodel.numfaceinfo },
|
||||
@@ -355,7 +347,7 @@ Mod_LoadLump
|
||||
generic loader
|
||||
=================
|
||||
*/
|
||||
static void Mod_LoadLump( const byte *in, mlumpinfo_t *info, mlumpstat_t *stat, int flags )
|
||||
static void Mod_LoadLump( const byte *in, const mlumpinfo_t *info, mlumpstat_t *stat, int flags )
|
||||
{
|
||||
int version = ((dheader_t *)in)->version;
|
||||
size_t numelems, real_entrysize;
|
||||
@@ -1835,7 +1827,7 @@ static void Mod_LoadEntities( model_t *mod, dbspmodel_t *bmod )
|
||||
world.generator[0] = '\0';
|
||||
world.compiler[0] = '\0';
|
||||
world.message[0] = '\0';
|
||||
bmod->wadlist.count = 0;
|
||||
world.wadlist.count = 0;
|
||||
|
||||
// parse all the wads for loading textures in right ordering
|
||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||||
@@ -1878,12 +1870,12 @@ static void Mod_LoadEntities( model_t *mod, dbspmodel_t *bmod )
|
||||
// make sure that wad is really exist
|
||||
if( FS_FileExists( va( "%s.wad", token ), false ))
|
||||
{
|
||||
int num = bmod->wadlist.count++;
|
||||
Q_strncpy( bmod->wadlist.wadnames[num], token, sizeof( bmod->wadlist.wadnames[0] ));
|
||||
bmod->wadlist.wadusage[num] = 0;
|
||||
int num = world.wadlist.count++;
|
||||
Q_strncpy( world.wadlist.wadnames[num], token, sizeof( world.wadlist.wadnames[0] ));
|
||||
world.wadlist.wadusage[num] = 0;
|
||||
}
|
||||
|
||||
if( bmod->wadlist.count >= MAX_MAP_WADS )
|
||||
if( world.wadlist.count >= MAX_MAP_WADS )
|
||||
break; // too many wads...
|
||||
}
|
||||
}
|
||||
@@ -2030,24 +2022,35 @@ static void Mod_LoadMarkSurfaces( model_t *mod, dbspmodel_t *bmod )
|
||||
|
||||
if( bmod->version == QBSP2_VERSION )
|
||||
{
|
||||
dmarkface32_t *in = bmod->markfaces32;
|
||||
const dmarkface32_t *in = bmod->markfaces32;
|
||||
|
||||
for( i = 0; i < bmod->nummarkfaces; i++, in++ )
|
||||
for( i = 0; i < bmod->nummarkfaces; i++ )
|
||||
{
|
||||
if( *in < 0 || *in >= mod->numsurfaces )
|
||||
Host_Error( "%s: bad surface number in '%s'\n", __func__, mod->name );
|
||||
out[i] = mod->surfaces + *in;
|
||||
if( in[i] < 0 || in[i] >= mod->numsurfaces )
|
||||
Host_Error( "%s: bad surface number %i at %i (max %i) in '%s'\n", __func__, in[i], i, mod->numsurfaces, mod->name );
|
||||
out[i] = mod->surfaces + in[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dmarkface_t *in = bmod->markfaces;
|
||||
const dmarkface_t *in = bmod->markfaces;
|
||||
|
||||
for( i = 0; i < bmod->nummarkfaces; i++, in++ )
|
||||
for( i = 0; i < bmod->nummarkfaces; i++ )
|
||||
{
|
||||
if( *in < 0 || *in >= mod->numsurfaces )
|
||||
Host_Error( "%s: bad surface number in '%s'\n", __func__, mod->name );
|
||||
out[i] = mod->surfaces + *in;
|
||||
// NOTE: some of the buggy compilers have written a broken BSP file
|
||||
// with marksurface pointing at negative surface, for example darkf6.bsp
|
||||
// and darkf26.bsp in darkfuture mod. GoldSrc straight up writes
|
||||
// invalid pointer to a surface. Try to fix up these cases...
|
||||
if( mod->numsurfaces <= INT16_MAX && (int16_t)in[i] < 0 )
|
||||
{
|
||||
Con_Printf( S_WARN "%s: fixing up bad surface number %i at %i (max %i) in '%s'\n", __func__, in[i], i, mod->numsurfaces, mod->name );
|
||||
out[i] = mod->surfaces;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( in[i] < 0 || in[i] >= mod->numsurfaces )
|
||||
Host_Error( "%s: bad surface number %i at %i (max %i) in '%s'\n", __func__, in[i], i, mod->numsurfaces, mod->name );
|
||||
out[i] = mod->surfaces + in[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2309,9 +2312,9 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
||||
}
|
||||
|
||||
// Try WAD texture (force while r_wadtextures is 1)
|
||||
if( !texture->gl_texturenum && (( r_wadtextures.value && bmod->wadlist.count > 0 ) || mipTex->offsets[0] <= 0 ))
|
||||
if( !texture->gl_texturenum && (( r_wadtextures.value && world.wadlist.count > 0 ) || mipTex->offsets[0] <= 0 ))
|
||||
{
|
||||
int wadIndex = Mod_FindTextureInWadList( &bmod->wadlist, mipTex->name, texpath, sizeof( texpath ));
|
||||
int wadIndex = Mod_FindTextureInWadList( &world.wadlist, mipTex->name, texpath, sizeof( texpath ));
|
||||
|
||||
if( wadIndex >= 0 )
|
||||
{
|
||||
@@ -2319,7 +2322,7 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
||||
if( !Host_IsDedicated( ))
|
||||
texture->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, txFlags );
|
||||
#endif // !XASH_DEDICATED
|
||||
bmod->wadlist.wadusage[wadIndex]++;
|
||||
world.wadlist.wadusage[wadIndex]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2377,12 +2380,12 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
|
||||
// doesn't exist there. The original texture is already loaded, but cannot be modified.
|
||||
// Instead, load the original texture again and convert it to luma.
|
||||
|
||||
wadIndex = Mod_FindTextureInWadList( &bmod->wadlist, texture->name, texpath, sizeof( texpath ));
|
||||
wadIndex = Mod_FindTextureInWadList( &world.wadlist, texture->name, texpath, sizeof( texpath ));
|
||||
|
||||
if( wadIndex >= 0 )
|
||||
{
|
||||
src = FS_LoadFile( texpath, &srcSize, false );
|
||||
bmod->wadlist.wadusage[wadIndex]++;
|
||||
world.wadlist.wadusage[wadIndex]++;
|
||||
}
|
||||
|
||||
// OK, loading it from wad or hi-res version
|
||||
@@ -3415,18 +3418,14 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
|
||||
Mod_CalcPHS( mod );
|
||||
}
|
||||
|
||||
for( i = 0; i < bmod->wadlist.count; i++ )
|
||||
for( i = 0; i < world.wadlist.count; i++ )
|
||||
{
|
||||
string wadname;
|
||||
|
||||
if( !bmod->wadlist.wadusage[i] )
|
||||
if( !world.wadlist.wadusage[i] )
|
||||
continue;
|
||||
|
||||
Q_snprintf( wadname, sizeof( wadname ), "%s.wad", bmod->wadlist.wadnames[i] );
|
||||
|
||||
// a1ba: automatically precache used wad files so client will download it
|
||||
if( SV_Active( ))
|
||||
SV_GenericIndex( wadname );
|
||||
Q_snprintf( wadname, sizeof( wadname ), "%s.wad", world.wadlist.wadnames[i] );
|
||||
|
||||
if( !wadlist_warn )
|
||||
{
|
||||
|
||||
@@ -83,6 +83,12 @@ typedef struct
|
||||
uint num_polys;
|
||||
} hull_model_t;
|
||||
|
||||
typedef struct wadlist_s
|
||||
{
|
||||
char wadnames[MAX_MAP_WADS][32];
|
||||
int wadusage[MAX_MAP_WADS];
|
||||
int count;
|
||||
} wadlist_t;
|
||||
|
||||
typedef struct world_static_s
|
||||
{
|
||||
@@ -119,6 +125,8 @@ typedef struct world_static_s
|
||||
// Potentially Hearable Set
|
||||
byte *compressed_phs;
|
||||
size_t *phsofs;
|
||||
|
||||
wadlist_t wadlist;
|
||||
} world_static_t;
|
||||
|
||||
#ifndef REF_DLL
|
||||
|
||||
161
engine/common/munge.c
Normal file
161
engine/common/munge.c
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
munge.c - protocol mangling for GoldSrc
|
||||
Copyright (C) ReHLDS developers
|
||||
Copyright (C) 2023 Alibek Omarov
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
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"
|
||||
|
||||
static const byte mungify_table[] =
|
||||
{
|
||||
0x7A, 0x64, 0x05, 0xF1, 0x1B, 0x9B, 0xA0, 0xB5,
|
||||
0xCA, 0xED, 0x61, 0x0D, 0x4A, 0xDF, 0x8E, 0xC7,
|
||||
};
|
||||
|
||||
static const byte mungify_table2[] =
|
||||
{
|
||||
0x05, 0x61, 0x7A, 0xED, 0x1B, 0xCA, 0x0D, 0x9B,
|
||||
0x4A, 0xF1, 0x64, 0xC7, 0xB5, 0x8E, 0xDF, 0xA0,
|
||||
};
|
||||
|
||||
static const byte mungify_table3[] =
|
||||
{
|
||||
0x20, 0x07, 0x13, 0x61, 0x03, 0x45, 0x17, 0x72,
|
||||
0x0A, 0x2D, 0x48, 0x0C, 0x4A, 0x12, 0xA9, 0xB5,
|
||||
};
|
||||
|
||||
static uint COM_SwapLong( uint c )
|
||||
{
|
||||
return ((( c >> 0 ) & 0xFF) << 24 ) +
|
||||
((( c >> 8 ) & 0xFF) << 16 ) +
|
||||
((( c >> 16 ) & 0xFF) << 8 ) +
|
||||
((( c >> 24 ) & 0xFF) << 0 );
|
||||
}
|
||||
|
||||
static void COM_GenericMunge( byte *data, const size_t len, const int seq, const byte *table, const qboolean reverse )
|
||||
{
|
||||
const size_t mungelen = len / 4;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < mungelen; i++ )
|
||||
{
|
||||
uint32_t c;
|
||||
void *pc = &data[i * 4];
|
||||
byte *p;
|
||||
int j;
|
||||
|
||||
memcpy( &c, pc, sizeof( c ));
|
||||
c ^= seq;
|
||||
if( !reverse )
|
||||
c = COM_SwapLong( c );
|
||||
|
||||
p = (byte *)&c;
|
||||
for( j = 0; j < 4; j++ )
|
||||
*p++ ^= (0xa5 | (j << j) | j | table[(i + j) & 0x0f]);
|
||||
|
||||
if( reverse )
|
||||
c = COM_SwapLong( c );
|
||||
c ^= ~seq;
|
||||
memcpy( pc, &c, sizeof( c ));
|
||||
}
|
||||
}
|
||||
|
||||
// Anti-proxy/aimbot obfuscation code
|
||||
// COM_UnMunge should reversably fixup the data
|
||||
void COM_Munge( byte *data, size_t len, int seq )
|
||||
{
|
||||
COM_GenericMunge( data, len, seq, mungify_table, false );
|
||||
}
|
||||
|
||||
void COM_UnMunge( byte *data, size_t len, int seq )
|
||||
{
|
||||
COM_GenericMunge( data, len, seq, mungify_table, true );
|
||||
}
|
||||
|
||||
void COM_Munge2( byte *data, size_t len, int seq )
|
||||
{
|
||||
COM_GenericMunge( data, len, seq, mungify_table2, false );
|
||||
}
|
||||
|
||||
void COM_UnMunge2( byte *data, size_t len, int seq )
|
||||
{
|
||||
COM_GenericMunge( data, len, seq, mungify_table2, true );
|
||||
}
|
||||
|
||||
void COM_Munge3( byte *data, size_t len, int seq )
|
||||
{
|
||||
COM_GenericMunge( data, len, seq, mungify_table3, false );
|
||||
}
|
||||
|
||||
void COM_UnMunge3( byte *data, size_t len, int seq )
|
||||
{
|
||||
COM_GenericMunge( data, len, seq, mungify_table3, true );
|
||||
}
|
||||
|
||||
#if XASH_ENGINE_TESTS
|
||||
#include "tests.h"
|
||||
|
||||
void Test_RunMunge( void )
|
||||
{
|
||||
const char *msg = "0123456789qwertyuiopasdfghjklzxcvbnmaa";
|
||||
const char *expected[][3] =
|
||||
{
|
||||
{
|
||||
"\x33\x2a\x61\x30\x2d\x6e\x35\x74\x2d\x79\x79\x78\x73\x34\x32\x25\x30\x2f\x39\x35\x26\x3c\x33\x61\x31\x22\x78\x67\x29\x68\x6a\x6c\x7d\x7e\x72\x36\x61\x61",
|
||||
"\x69\x2a\x31\x30\x2d\x36\x25\x74\x77\x61\x79\x38\x6b\x34\x62\x25\x30\x7f\x39\x35\x76\x34\x33\x61\x39\x2a\x78\x67\x23\x68\x7a\x6c\x7d\x66\x72\x76\x61\x61",
|
||||
"\x69\x6a\x71\x30\x6f\x7e\x25\x74\x3f\x69\x69\x38\x63\x2c\x62\x25\x28\x77\x29\x75\x7c\x2c\x73\x21\x23\x62\x38\x27\x6b\x28\x2a\x6c\x3d\x3e\x72\x36\x61\x61",
|
||||
}, {
|
||||
"\x32\x2a\x61\x31\x2c\x6e\x35\x75\x2c\x79\x79\x79\x72\x34\x32\x24\x31\x2f\x39\x34\x27\x3c\x33\x60\x30\x22\x78\x66\x28\x68\x6a\x6d\x7c\x7e\x72\x37\x61\x61",
|
||||
"\x68\x2a\x31\x31\x2c\x36\x25\x75\x76\x61\x79\x39\x6a\x34\x62\x24\x31\x7f\x39\x34\x77\x34\x33\x60\x38\x2a\x78\x66\x22\x68\x7a\x6d\x7c\x66\x72\x77\x61\x61",
|
||||
"\x68\x6a\x71\x31\x6e\x7e\x25\x75\x3e\x69\x69\x39\x62\x2c\x62\x24\x29\x77\x29\x74\x7d\x2c\x73\x20\x22\x62\x38\x26\x6a\x28\x2a\x6d\x3c\x3e\x72\x37\x61\x61",
|
||||
}
|
||||
};
|
||||
string buf;
|
||||
size_t msglen = Q_strlen( msg ) + 1;
|
||||
int i;
|
||||
|
||||
Q_strncpy( buf, msg, msglen );
|
||||
|
||||
for( i = 0; i < 0xFF; i++ )
|
||||
{
|
||||
COM_Munge( buf, msglen, i );
|
||||
if( i < sizeof( expected ) / sizeof( expected[0] ))
|
||||
{
|
||||
//for( int j = 0; j < msglen; j++ )
|
||||
// printf( "\\x%02x", buf[j] );
|
||||
//printf( "\n" );
|
||||
TASSERT( !memcmp( buf, expected[i][0], msglen ));
|
||||
}
|
||||
COM_UnMunge( buf, msglen, i );
|
||||
|
||||
TASSERT( !Q_strcmp( buf, msg ));
|
||||
|
||||
COM_Munge2( buf, msglen, i );
|
||||
if( i < sizeof( expected ) / sizeof( expected[0] ))
|
||||
{
|
||||
TASSERT( !memcmp( buf, expected[i][1], msglen ));
|
||||
}
|
||||
COM_UnMunge2( buf, msglen, i );
|
||||
|
||||
TASSERT( !Q_strcmp( buf, msg ));
|
||||
|
||||
COM_Munge3( buf, msglen, i );
|
||||
if( i < sizeof( expected ) / sizeof( expected[0] ))
|
||||
{
|
||||
TASSERT( !memcmp( buf, expected[i][2], msglen ));
|
||||
}
|
||||
COM_UnMunge3( buf, msglen, i );
|
||||
|
||||
TASSERT( !Q_strcmp( buf, msg ));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -17,15 +17,13 @@ GNU General Public License for more details.
|
||||
#include "protocol.h"
|
||||
#include "net_buffer.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
//#define DEBUG_NET_MESSAGES_SEND
|
||||
//#define DEBUG_NET_MESSAGES_READ
|
||||
|
||||
// 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];
|
||||
const char *svc_strings[svc_lastmsg+1] =
|
||||
const char *const svc_strings[svc_lastmsg+1] =
|
||||
{
|
||||
"svc_bad",
|
||||
"svc_nop",
|
||||
@@ -81,7 +79,7 @@ const char *svc_strings[svc_lastmsg+1] =
|
||||
"svc_director",
|
||||
"svc_voiceinit",
|
||||
"svc_voicedata",
|
||||
"svc_deltapacketbones",
|
||||
"svc_unused54",
|
||||
"svc_unused55",
|
||||
"svc_resourcelocation",
|
||||
"svc_querycvarvalue",
|
||||
@@ -89,7 +87,7 @@ const char *svc_strings[svc_lastmsg+1] =
|
||||
"svc_exec",
|
||||
};
|
||||
|
||||
const char *svc_legacy_strings[svc_lastmsg+1] =
|
||||
const char *const svc_legacy_strings[svc_lastmsg+1] =
|
||||
{
|
||||
[svc_legacy_changing] = "svc_legacy_changing",
|
||||
[svc_legacy_ambientsound] = "svc_legacy_ambientsound",
|
||||
@@ -100,7 +98,7 @@ const char *svc_legacy_strings[svc_lastmsg+1] =
|
||||
[svc_legacy_chokecount] = "svc_legacy_chokecount",
|
||||
};
|
||||
|
||||
const char *svc_goldsrc_strings[svc_lastmsg+1] =
|
||||
const char *const svc_goldsrc_strings[svc_lastmsg+1] =
|
||||
{
|
||||
[svc_goldsrc_version] = "svc_goldsrc_version",
|
||||
[svc_goldsrc_serverinfo] = "svc_goldsrc_serverinfo",
|
||||
@@ -119,7 +117,7 @@ const char *svc_goldsrc_strings[svc_lastmsg+1] =
|
||||
[svc_goldsrc_sendcvarvalue2] = "svc_goldsrc_sendcvarvalue2",
|
||||
};
|
||||
|
||||
const char *svc_quake_strings[svc_lastmsg+1] =
|
||||
const char *const svc_quake_strings[svc_lastmsg+1] =
|
||||
{
|
||||
[svc_updatestat] = "svc_quake_updatestat",
|
||||
[svc_version] = "svc_quake_version",
|
||||
@@ -213,17 +211,23 @@ void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits )
|
||||
// do we have a valid # of bits to encode with?
|
||||
Assert( numbits >= 1 && numbits <= 32 );
|
||||
|
||||
// NOTE: it does this wierdness here so it's bit-compatible with regular integer data in the buffer.
|
||||
// (Some old code writes direct integers right into the buffer).
|
||||
if( data < 0 )
|
||||
if( sb->iAlternateSign )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, (uint)( 0x80000000 + data ), numbits - 1 );
|
||||
MSG_WriteOneBit( sb, 1 );
|
||||
MSG_WriteOneBit( sb, data < 0 ? 1 : 0 );
|
||||
MSG_WriteUBitLong( sb, (uint)abs( data ), numbits - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG_WriteUBitLong( sb, (uint)data, numbits - 1 );
|
||||
MSG_WriteOneBit( sb, 0 );
|
||||
if( data < 0 )
|
||||
{
|
||||
MSG_WriteUBitLong( sb, (uint)( 0x80000000 + data ), numbits - 1 );
|
||||
MSG_WriteOneBit( sb, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG_WriteUBitLong( sb, (uint)data, numbits - 1 );
|
||||
MSG_WriteOneBit( sb, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,28 +321,30 @@ void MSG_WriteVec3Angles( sizebuf_t *sb, const float *fa )
|
||||
|
||||
void MSG_WriteCmdExt( sizebuf_t *sb, int cmd, netsrc_t type, const char *name )
|
||||
{
|
||||
#ifdef DEBUG_NET_MESSAGES_SEND
|
||||
if( name != NULL )
|
||||
if( unlikely( net_send_debug.value ))
|
||||
{
|
||||
// get custom name
|
||||
Con_Printf( "^1sv^7 write: %s\n", name );
|
||||
}
|
||||
else if( type == NS_SERVER )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= svc_lastmsg )
|
||||
if( name != NULL )
|
||||
{
|
||||
// get engine message name
|
||||
Con_Printf( "^1sv^7 write: %s\n", svc_strings[cmd] );
|
||||
// get custom name
|
||||
Con_Printf( "^1sv^7 (%d) write: %s\n", sb->iCurBit, name );
|
||||
}
|
||||
else if( type == NS_SERVER )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= svc_lastmsg )
|
||||
{
|
||||
// get engine message name
|
||||
Con_Printf( "^1sv^7 (%d) write: %s\n", sb->iCurBit, svc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
else if( type == NS_CLIENT )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= clc_lastmsg && cmd != clc_nop )
|
||||
{
|
||||
Con_Printf( "^1cl^7 (%d) write: %s\n", sb->iCurBit, clc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( type == NS_CLIENT )
|
||||
{
|
||||
if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1cl^7 write: %s\n", clc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MSG_WriteUBitLong( sb, cmd, sizeof( uint8_t ) << 3 );
|
||||
}
|
||||
|
||||
@@ -533,12 +539,22 @@ int MSG_ReadSBitLong( sizebuf_t *sb, int numbits )
|
||||
{
|
||||
int r, sign;
|
||||
|
||||
r = MSG_ReadUBitLong( sb, numbits - 1 );
|
||||
if( sb->iAlternateSign )
|
||||
{
|
||||
sign = MSG_ReadOneBit( sb );
|
||||
r = MSG_ReadUBitLong( sb, numbits - 1 );
|
||||
|
||||
// NOTE: it does this wierdness here so it's bit-compatible with regular integer data in the buffer.
|
||||
// (Some old code writes direct integers right into the buffer).
|
||||
sign = MSG_ReadOneBit( sb );
|
||||
if( sign ) r = -( BIT( numbits - 1 ) - r );
|
||||
if( sign )
|
||||
r = -r;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = MSG_ReadUBitLong( sb, numbits - 1 );
|
||||
sign = MSG_ReadOneBit( sb );
|
||||
|
||||
if( sign )
|
||||
r = -( BIT( numbits - 1 ) - r );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -554,22 +570,31 @@ int MSG_ReadCmd( sizebuf_t *sb, netsrc_t type )
|
||||
{
|
||||
int cmd = MSG_ReadUBitLong( sb, sizeof( uint8_t ) << 3 );
|
||||
|
||||
#ifdef DEBUG_NET_MESSAGES_READ
|
||||
if( type == NS_SERVER )
|
||||
if( unlikely( net_recv_debug.value ))
|
||||
{
|
||||
Con_Printf( "^1cl^7 read: %s\n", CL_MsgInfo( cmd ));
|
||||
if( type == NS_SERVER )
|
||||
{
|
||||
if( cmd != svc_nop )
|
||||
Con_Printf( "^1cl^7 read: %s\n", CL_MsgInfo( cmd ));
|
||||
}
|
||||
else if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1sv^7 read: %s\n", clc_strings[cmd] );
|
||||
}
|
||||
}
|
||||
else if( cmd >= 0 && cmd <= clc_lastmsg )
|
||||
{
|
||||
Con_Printf( "^1sv^7 read: %s\n", clc_strings[cmd] );
|
||||
}
|
||||
#endif
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
int MSG_ReadChar( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadSBitLong( sb, sizeof( int8_t ) << 3 );
|
||||
int alt = sb->iAlternateSign, ret;
|
||||
|
||||
sb->iAlternateSign = 0;
|
||||
ret = MSG_ReadSBitLong( sb, sizeof( int8_t ) << 3 );
|
||||
sb->iAlternateSign = alt;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int MSG_ReadByte( sizebuf_t *sb )
|
||||
@@ -579,7 +604,13 @@ int MSG_ReadByte( sizebuf_t *sb )
|
||||
|
||||
int MSG_ReadShort( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadSBitLong( sb, sizeof( int16_t ) << 3 );
|
||||
int alt = sb->iAlternateSign, ret;
|
||||
|
||||
sb->iAlternateSign = 0;
|
||||
ret = MSG_ReadSBitLong( sb, sizeof( int16_t ) << 3 );
|
||||
sb->iAlternateSign = alt;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int MSG_ReadWord( sizebuf_t *sb )
|
||||
@@ -611,7 +642,13 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa )
|
||||
|
||||
int MSG_ReadLong( sizebuf_t *sb )
|
||||
{
|
||||
return MSG_ReadSBitLong( sb, sizeof( int32_t ) << 3 );
|
||||
int alt = sb->iAlternateSign, ret;
|
||||
|
||||
sb->iAlternateSign = 0;
|
||||
ret = MSG_ReadSBitLong( sb, sizeof( int32_t ) << 3 );
|
||||
sb->iAlternateSign = alt;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint MSG_ReadDword( sizebuf_t *sb )
|
||||
|
||||
@@ -42,6 +42,9 @@ struct sizebuf_s
|
||||
int iCurBit;
|
||||
int nDataBits;
|
||||
const char *pDebugName; // buffer name (pointer to const name)
|
||||
|
||||
// to support GoldSrc broken signed integers
|
||||
int iAlternateSign;
|
||||
};
|
||||
|
||||
#define MSG_StartReading MSG_StartWriting
|
||||
@@ -71,6 +74,7 @@ static inline void MSG_InitExt( sizebuf_t *sb, const char *pDebugName, void *pDa
|
||||
sb->nDataBits = nBits;
|
||||
|
||||
sb->pDebugName = pDebugName;
|
||||
sb->iAlternateSign = 0;
|
||||
}
|
||||
|
||||
static inline void MSG_StartWriting( sizebuf_t *sb, void *pData, int nBytes, int iStartBit, int nBits )
|
||||
@@ -169,6 +173,26 @@ static inline qboolean MSG_Overflow( sizebuf_t *sb, int nBits )
|
||||
return sb->bOverflow;
|
||||
}
|
||||
|
||||
static inline void MSG_EndBitWriting( sizebuf_t *sb )
|
||||
{
|
||||
sb->iAlternateSign--;
|
||||
|
||||
if( sb->iAlternateSign < 0 )
|
||||
{
|
||||
Con_Printf( "%s: non-even MSG_Start/EndBitWriting\n", __func__ );
|
||||
sb->iAlternateSign = 0;
|
||||
}
|
||||
|
||||
// we have native bit ops here, just pad to closest byte
|
||||
if(( sb->iCurBit & 7 ) != 0 )
|
||||
MSG_SeekToBit( sb, 8 - ( sb->iCurBit & 7 ), SEEK_CUR );
|
||||
}
|
||||
|
||||
static inline void MSG_StartBitWriting( sizebuf_t *sb )
|
||||
{
|
||||
sb->iAlternateSign++;
|
||||
}
|
||||
|
||||
void MSG_InitMasks( void ); // called once at startup engine
|
||||
void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove );
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ GNU General Public License for more details.
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "net_encode.h"
|
||||
#include "protocol.h"
|
||||
#if !XASH_DEDICATED
|
||||
#include <bzlib.h>
|
||||
#endif // !XASH_DEDICATED
|
||||
|
||||
#define MAKE_FRAGID( id, count ) ((( id & 0xffff ) << 16 ) | ( count & 0xffff ))
|
||||
#define FRAG_GETID( fragid ) (( fragid >> 16 ) & 0xffff )
|
||||
@@ -84,10 +87,12 @@ 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_showpackets, "0", FCVAR_PRIVILEGED, "show network packets" );
|
||||
static CVAR_DEFINE_AUTO( net_chokeloop, "0", 0, "apply bandwidth choke to loopback packets" );
|
||||
static CVAR_DEFINE_AUTO( net_showdrop, "0", 0, "show packets that are dropped" );
|
||||
static CVAR_DEFINE_AUTO( net_qport, "0", FCVAR_READ_ONLY, "current quake netport" );
|
||||
CVAR_DEFINE_AUTO( net_send_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for outgoing messages" );
|
||||
CVAR_DEFINE_AUTO( net_recv_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for incoming messages" );
|
||||
|
||||
int net_drop;
|
||||
netadr_t net_from;
|
||||
@@ -95,12 +100,58 @@ sizebuf_t net_message;
|
||||
static poolhandle_t net_mempool;
|
||||
byte net_message_buffer[NET_MAX_MESSAGE];
|
||||
|
||||
const char *ns_strings[NS_COUNT] =
|
||||
static const char *const ns_strings[NS_COUNT] =
|
||||
{
|
||||
"Client",
|
||||
"Server",
|
||||
};
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
void bz_internal_error( int errcode );
|
||||
void bz_internal_error( int errcode )
|
||||
{
|
||||
Con_Printf( S_ERROR "bzip2/libbzip2: internal error number %d.\n"
|
||||
"This is a bug in bzip2/libbzip2, %s.\n"
|
||||
"Please report it at: https://gitlab.com/bzip2/bzip2/-/issues\n"
|
||||
"If this happened when you were using some program which uses\n"
|
||||
"libbzip2 as a component, you should also report this bug to\n"
|
||||
"the author(s) of that program.\n"
|
||||
"Please make an effort to report this bug;\n"
|
||||
"timely and accurate bug reports eventually lead to higher\n"
|
||||
"quality software. Thanks.\n\n",
|
||||
errcode, BZ2_bzlibVersion( ));
|
||||
|
||||
if (errcode == 1007) {
|
||||
Con_Printf(
|
||||
"\n*** A special note about internal error number 1007 ***\n"
|
||||
"\n"
|
||||
"Experience suggests that a common cause of i.e. 1007\n"
|
||||
"is unreliable memory or other hardware. The 1007 assertion\n"
|
||||
"just happens to cross-check the results of huge numbers of\n"
|
||||
"memory reads/writes, and so acts (unintendedly) as a stress\n"
|
||||
"test of your memory system.\n"
|
||||
"\n"
|
||||
"I suggest the following: try compressing the file again,\n"
|
||||
"possibly monitoring progress in detail with the -vv flag.\n"
|
||||
"\n"
|
||||
"* If the error cannot be reproduced, and/or happens at different\n"
|
||||
" points in compression, you may have a flaky memory system.\n"
|
||||
" Try a memory-test program. I have used Memtest86\n"
|
||||
" (www.memtest86.com). At the time of writing it is free (GPLd).\n"
|
||||
" Memtest86 tests memory much more thorougly than your BIOSs\n"
|
||||
" power-on test, and may find failures that the BIOS doesn't.\n"
|
||||
"\n"
|
||||
"* If the error can be repeatably reproduced, this is a bug in\n"
|
||||
" bzip2, and I would very much like to hear about it. Please\n"
|
||||
" let me know, and, ideally, save a copy of the file causing the\n"
|
||||
" problem -- without which I will be unable to investigate it.\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
Sys_Error( "bzip2/libbzip2: internal error number %d\n", errcode );
|
||||
}
|
||||
#endif // XASH_DEDICATED
|
||||
|
||||
/*
|
||||
=================================
|
||||
@@ -216,6 +267,8 @@ void Netchan_Init( void )
|
||||
Cvar_RegisterVariable( &net_chokeloop );
|
||||
Cvar_RegisterVariable( &net_showdrop );
|
||||
Cvar_RegisterVariable( &net_qport );
|
||||
Cvar_RegisterVariable( &net_send_debug );
|
||||
Cvar_RegisterVariable( &net_recv_debug );
|
||||
Cvar_FullSet( net_qport.name, buf, net_qport.flags );
|
||||
|
||||
net_mempool = Mem_AllocPool( "Network Pool" );
|
||||
@@ -265,12 +318,18 @@ Netchan_Setup
|
||||
called to open a channel to a remote system
|
||||
==============
|
||||
*/
|
||||
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, void *client, int (*pfnBlockSize)(void *, fragsize_t mode ))
|
||||
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, void *client, int (*pfnBlockSize)(void *, fragsize_t mode ), uint flags )
|
||||
{
|
||||
Netchan_Clear( chan );
|
||||
|
||||
memset( chan, 0, sizeof( *chan ));
|
||||
|
||||
if( pfnBlockSize == NULL )
|
||||
{
|
||||
Host_Error( "%s: pfnBlockSize == NULL", __func__ );
|
||||
return;
|
||||
}
|
||||
|
||||
chan->sock = sock;
|
||||
chan->remote_address = adr;
|
||||
chan->last_received = host.realtime;
|
||||
@@ -281,6 +340,10 @@ void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, voi
|
||||
chan->qport = qport;
|
||||
chan->client = client;
|
||||
chan->pfnBlockSize = pfnBlockSize;
|
||||
chan->split = FBitSet( flags, NETCHAN_USE_LEGACY_SPLIT ) ? true : false;
|
||||
chan->use_munge = FBitSet( flags, NETCHAN_USE_MUNGE ) ? true : false;
|
||||
chan->use_bz2 = FBitSet( flags, NETCHAN_USE_BZIP2 ) ? true : false;
|
||||
chan->gs_netchan = FBitSet( flags, NETCHAN_GOLDSRC ) ? true : false;
|
||||
|
||||
MSG_Init( &chan->message, "NetData", chan->message_buf, sizeof( chan->message_buf ));
|
||||
}
|
||||
@@ -457,7 +520,7 @@ Netchan_OutOfBand
|
||||
Sends an out-of-band datagram
|
||||
================
|
||||
*/
|
||||
void Netchan_OutOfBand( int net_socket, netadr_t adr, int len, byte *data )
|
||||
void Netchan_OutOfBand( int net_socket, netadr_t adr, int len, const byte *data )
|
||||
{
|
||||
byte buf[MAX_PRINT_MSG + 4] = { 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
@@ -681,21 +744,39 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
|
||||
if( MSG_GetNumBytesWritten( msg ) == 0 )
|
||||
return;
|
||||
|
||||
if( chan->pfnBlockSize != NULL )
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
else chunksize = FRAGMENT_MAX_SIZE; // fallback
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
|
||||
wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
|
||||
if( !LZSS_IsCompressed( MSG_GetData( msg )))
|
||||
if( chan->use_bz2 && memcmp( MSG_GetData( msg ), "BZ2", 4 ))
|
||||
{
|
||||
uint uCompressedSize = 0;
|
||||
uint uSourceSize = MSG_GetNumBytesWritten( msg );
|
||||
byte *pbOut = LZSS_Compress( msg->pData, uSourceSize, &uCompressedSize );
|
||||
#if !XASH_DEDICATED
|
||||
byte pbOut[0x10000];
|
||||
uint uSourceSize = MSG_GetNumBytesWritten( msg );
|
||||
uint uCompressedSize = MSG_GetNumBytesWritten( msg ) - 4;
|
||||
if( !BZ2_bzBuffToBuffCompress( pbOut, &uCompressedSize, MSG_GetData( msg ), uSourceSize, 9, 0, 30 ))
|
||||
{
|
||||
if( uCompressedSize < uSourceSize )
|
||||
{
|
||||
Con_Reportf( "Compressing split packet with BZip2 (%d -> %d bytes)\n", uSourceSize, uCompressedSize );
|
||||
memcpy( msg->pData, "BZ2", 4 );
|
||||
memcpy( msg->pData + 4, pbOut, uCompressedSize );
|
||||
MSG_SeekToBit( msg, uCompressedSize << 3, SEEK_SET );
|
||||
}
|
||||
}
|
||||
#else
|
||||
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
|
||||
#endif
|
||||
}
|
||||
else if( !chan->use_bz2 && !LZSS_IsCompressed( MSG_GetData( msg )))
|
||||
{
|
||||
uint uCompressedSize = 0;
|
||||
uint uSourceSize = MSG_GetNumBytesWritten( msg );
|
||||
byte *pbOut = LZSS_Compress( msg->pData, uSourceSize, &uCompressedSize );
|
||||
|
||||
if( pbOut && uCompressedSize > 0 && uCompressedSize < uSourceSize )
|
||||
{
|
||||
Con_Reportf( "Compressing split packet (%d -> %d bytes)\n", uSourceSize, uCompressedSize );
|
||||
Con_Reportf( "Compressing split packet with LZSS (%d -> %d bytes)\n", uSourceSize, uCompressedSize );
|
||||
memcpy( msg->pData, pbOut, uCompressedSize );
|
||||
MSG_SeekToBit( msg, uCompressedSize << 3, SEEK_SET );
|
||||
}
|
||||
@@ -842,9 +923,7 @@ void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filenam
|
||||
|
||||
if( !size ) return;
|
||||
|
||||
if( chan->pfnBlockSize != NULL )
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
else chunksize = FRAGMENT_MAX_SIZE; // fallback
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
|
||||
if( !LZSS_IsCompressed( pbuf ))
|
||||
{
|
||||
@@ -940,16 +1019,14 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
||||
Con_Printf( S_WARN "Unable to transfer %s due to path length overflow\n", filename );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if(( filesize = FS_FileSize( filename, false )) <= 0 )
|
||||
{
|
||||
Con_Printf( S_WARN "Unable to open %s for transfer\n", filename );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( chan->pfnBlockSize != NULL )
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
else chunksize = FRAGMENT_MAX_SIZE; // fallback
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
|
||||
Q_snprintf( compressedfilename, sizeof( compressedfilename ), "%s.ztmp", filename );
|
||||
compressedFileTime = FS_FileTime( compressedfilename, false );
|
||||
@@ -1098,7 +1175,20 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l
|
||||
p = n;
|
||||
}
|
||||
|
||||
if( LZSS_IsCompressed( MSG_GetData( msg )))
|
||||
if( chan->use_bz2 && !memcmp( MSG_GetData( msg ), "BZ2", 4 ) )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
byte buf[0x10000];
|
||||
uint uDecompressedLen = sizeof( buf );
|
||||
|
||||
BZ2_bzBuffToBuffDecompress( buf, &uDecompressedLen, MSG_GetData( msg ) + 4, MSG_GetNumBytesWritten( msg ) - 4, 1, 0 );
|
||||
memcpy( msg->pData, buf, uDecompressedLen );
|
||||
size = uDecompressedLen;
|
||||
#else
|
||||
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
|
||||
#endif
|
||||
}
|
||||
else if( !chan->use_bz2 && LZSS_IsCompressed( MSG_GetData( msg )))
|
||||
{
|
||||
uint uDecompressedLen = LZSS_GetActualSize( MSG_GetData( msg ));
|
||||
byte buf[NET_MAX_MESSAGE];
|
||||
@@ -1135,7 +1225,8 @@ Netchan_CopyFileFragments
|
||||
*/
|
||||
qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
{
|
||||
char filename[MAX_OSPATH];
|
||||
char filename[MAX_OSPATH], compressor[32];
|
||||
uint uncompressedSize;
|
||||
int nsize, pos;
|
||||
byte *buffer;
|
||||
fragbuf_t *p, *n;
|
||||
@@ -1158,6 +1249,12 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
MSG_Clear( msg );
|
||||
|
||||
Q_strncpy( filename, MSG_ReadString( msg ), sizeof( filename ));
|
||||
compressor[0] = 0;
|
||||
if( chan->gs_netchan )
|
||||
{
|
||||
Q_strncpy( compressor, MSG_ReadString( msg ), sizeof( compressor ));
|
||||
uncompressedSize = MSG_ReadLong( msg );
|
||||
}
|
||||
|
||||
if( !COM_CheckString( filename ))
|
||||
{
|
||||
@@ -1228,10 +1325,26 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
p = n;
|
||||
}
|
||||
|
||||
if( LZSS_IsCompressed( buffer ))
|
||||
if( chan->gs_netchan && chan->use_bz2 && !Q_stricmp( compressor, "bz2" ))
|
||||
{
|
||||
uint uncompressedSize = LZSS_GetActualSize( buffer ) + 1;
|
||||
byte *uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
#if !XASH_DEDICATED
|
||||
byte *uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
|
||||
Con_DPrintf( "Decompressing file %s (%d -> %d bytes)\n", filename, nsize, uncompressedSize );
|
||||
BZ2_bzBuffToBuffDecompress( uncompressedBuffer, &uncompressedSize, buffer, nsize, 1, 0 );
|
||||
Mem_Free( buffer );
|
||||
nsize = uncompressedSize;
|
||||
buffer = uncompressedBuffer;
|
||||
#else
|
||||
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
|
||||
#endif
|
||||
}
|
||||
else if( LZSS_IsCompressed( buffer ))
|
||||
{
|
||||
byte *uncompressedBuffer;
|
||||
|
||||
uncompressedSize = LZSS_GetActualSize( buffer ) + 1;
|
||||
uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
|
||||
nsize = LZSS_Decompress( buffer, uncompressedBuffer );
|
||||
Mem_Free( buffer );
|
||||
@@ -1391,7 +1504,7 @@ transmition / retransmition of the reliable messages.
|
||||
A 0 length will still generate a packet and deal with the reliable messages.
|
||||
================
|
||||
*/
|
||||
void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
void Netchan_TransmitBits( netchan_t *chan, int length, const byte *data )
|
||||
{
|
||||
byte send_buf[NET_MAX_MESSAGE];
|
||||
qboolean send_reliable_fragment;
|
||||
@@ -1408,6 +1521,9 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
return;
|
||||
}
|
||||
|
||||
if( chan->pfnBlockSize == NULL ) // not initialized
|
||||
return;
|
||||
|
||||
// if the remote side dropped the last reliable message, resend it
|
||||
send_reliable = false;
|
||||
|
||||
@@ -1446,12 +1562,9 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
// stall reliable payloads if sending from frag buffer
|
||||
if( send_from_regular && ( send_from_frag[FRAG_NORMAL_STREAM] ))
|
||||
{
|
||||
int maxsize = MAX_RELIABLE_PAYLOAD;
|
||||
int maxsize = chan->pfnBlockSize( chan->client, FRAGSIZE_SPLIT );
|
||||
send_from_regular = false;
|
||||
|
||||
|
||||
if( chan->pfnBlockSize )
|
||||
maxsize = chan->pfnBlockSize( chan->client, FRAGSIZE_SPLIT );
|
||||
if( maxsize == 0 )
|
||||
maxsize = MAX_RELIABLE_PAYLOAD;
|
||||
|
||||
@@ -1593,7 +1706,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
MSG_WriteLong( &send, w2 );
|
||||
|
||||
// send the qport if we are a client
|
||||
if( chan->sock == NS_CLIENT )
|
||||
if( chan->sock == NS_CLIENT && !chan->gs_netchan )
|
||||
{
|
||||
MSG_WriteWord( &send, (int)net_qport.value );
|
||||
}
|
||||
@@ -1606,8 +1719,16 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
{
|
||||
MSG_WriteByte( &send, 1 );
|
||||
MSG_WriteLong( &send, chan->reliable_fragid[i] );
|
||||
MSG_WriteLong( &send, chan->frag_startpos[i] );
|
||||
MSG_WriteLong( &send, chan->frag_length[i] );
|
||||
if( chan->gs_netchan )
|
||||
{
|
||||
MSG_WriteShort( &send, chan->frag_startpos[i] >> 3 );
|
||||
MSG_WriteShort( &send, chan->frag_length[i] >> 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG_WriteLong( &send, chan->frag_startpos[i] );
|
||||
MSG_WriteLong( &send, chan->frag_length[i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1625,9 +1746,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
|
||||
if( length )
|
||||
{
|
||||
int maxsize = NET_MAX_MESSAGE;
|
||||
if( chan->pfnBlockSize )
|
||||
maxsize = chan->pfnBlockSize( chan->client, FRAGSIZE_UNRELIABLE );
|
||||
int maxsize = chan->pfnBlockSize( chan->client, FRAGSIZE_UNRELIABLE );
|
||||
|
||||
if( (( MSG_GetNumBytesWritten( &send ) + length ) >> 3) <= maxsize )
|
||||
MSG_WriteBits( &send, data, length );
|
||||
@@ -1661,9 +1780,11 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
|
||||
// send the datagram
|
||||
if( !CL_IsPlaybackDemo( ))
|
||||
{
|
||||
int splitsize = 0;
|
||||
if( chan->pfnBlockSize )
|
||||
splitsize = chan->pfnBlockSize( chan->client, FRAGSIZE_SPLIT );
|
||||
int splitsize = chan->pfnBlockSize( chan->client, FRAGSIZE_SPLIT );
|
||||
|
||||
if( chan->use_munge )
|
||||
COM_Munge2( send.pData + 8, MSG_GetNumBytesWritten( &send ) - 8, (byte)( chan->outgoing_sequence - 1 ));
|
||||
|
||||
NET_SendPacketEx( chan->sock, MSG_GetNumBytesWritten( &send ), MSG_GetData( &send ), chan->remote_address, splitsize );
|
||||
}
|
||||
|
||||
@@ -1712,6 +1833,9 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
sequence = MSG_ReadLong( msg );
|
||||
sequence_ack = MSG_ReadLong( msg );
|
||||
|
||||
if( chan->use_munge )
|
||||
COM_UnMunge2( msg->pData + 8, ( msg->nDataBits >> 3 ) - 8, sequence & 0xFF );
|
||||
|
||||
// read the qport if we are a server
|
||||
if( chan->sock == NS_SERVER )
|
||||
qport = MSG_ReadShort( msg );
|
||||
@@ -1729,8 +1853,16 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
{
|
||||
frag_message[i] = true;
|
||||
fragid[i] = MSG_ReadLong( msg );
|
||||
frag_offset[i] = MSG_ReadLong( msg );
|
||||
frag_length[i] = MSG_ReadLong( msg );
|
||||
if( chan->gs_netchan )
|
||||
{
|
||||
frag_offset[i] = MSG_ReadShort( msg ) << 3;
|
||||
frag_length[i] = MSG_ReadShort( msg ) << 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
frag_offset[i] = MSG_ReadLong( msg );
|
||||
frag_length[i] = MSG_ReadLong( msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ GNU General Public License for more details.
|
||||
#define DT_TIMEWINDOW_BIG BIT( 6 ) // and re-encoded on the client relative to the client's clock
|
||||
#define DT_STRING BIT( 7 ) // A null terminated string, sent as 8 byte chars
|
||||
#define DT_SIGNED BIT( 8 ) // sign modificator
|
||||
#define DT_SIGNED_GS BIT( 31 ) // GoldSrc-specific sign modificator
|
||||
|
||||
#define NUM_FIELDS( x ) ((sizeof( x ) / sizeof( x[0] )) - 1)
|
||||
|
||||
@@ -47,6 +48,7 @@ GNU General Public License for more details.
|
||||
#define PHYS_DEF( x ) #x, offsetof( movevars_t, x ), sizeof( ((movevars_t *)0)->x )
|
||||
#define CLDT_DEF( x ) #x, offsetof( clientdata_t, x ), sizeof( ((clientdata_t *)0)->x )
|
||||
#define WPDT_DEF( x ) #x, offsetof( weapon_data_t, x ), sizeof( ((weapon_data_t *)0)->x )
|
||||
#define DESC_DEF( x ) #x, offsetof( goldsrc_delta_t, x ), sizeof( ((goldsrc_delta_t *)0)->x )
|
||||
|
||||
static qboolean delta_init = false;
|
||||
|
||||
@@ -315,6 +317,18 @@ static const delta_field_t ent_fields[] =
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const delta_field_t meta_fields[] =
|
||||
{
|
||||
{ DESC_DEF( fieldType ), },
|
||||
{ DESC_DEF( fieldName ), },
|
||||
{ DESC_DEF( fieldOffset ), },
|
||||
{ DESC_DEF( fieldSize ), },
|
||||
{ DESC_DEF( significant_bits ), },
|
||||
{ DESC_DEF( premultiply ), },
|
||||
{ DESC_DEF( postmultiply ), },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
#if XASH_ENGINE_TESTS
|
||||
typedef struct delta_test_struct_t
|
||||
{
|
||||
@@ -352,22 +366,6 @@ static const delta_field_t test_fields[] =
|
||||
};
|
||||
#endif
|
||||
|
||||
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,
|
||||
#if XASH_ENGINE_TESTS
|
||||
DT_DELTA_TEST_STRUCT_T,
|
||||
#endif
|
||||
DT_STRUCT_COUNT
|
||||
};
|
||||
|
||||
static delta_info_t dt_info[] =
|
||||
{
|
||||
[DT_EVENT_T] = { "event_t", ev_fields, NUM_FIELDS( ev_fields ) },
|
||||
@@ -375,7 +373,7 @@ static delta_info_t dt_info[] =
|
||||
[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_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 ) },
|
||||
#if XASH_ENGINE_TESTS
|
||||
@@ -384,6 +382,68 @@ static delta_info_t dt_info[] =
|
||||
[DT_STRUCT_COUNT] = { NULL },
|
||||
};
|
||||
|
||||
// meta description is special, it cannot be overriden
|
||||
static const delta_info_t dt_goldsrc_meta =
|
||||
{
|
||||
.pName = "goldsrc_delta_t",
|
||||
.pInfo = meta_fields,
|
||||
.maxFields = NUM_FIELDS( meta_fields ),
|
||||
.numFields = NUM_FIELDS( meta_fields ),
|
||||
.pFields = (delta_t[NUM_FIELDS( meta_fields )])
|
||||
{
|
||||
{
|
||||
DESC_DEF( fieldType ),
|
||||
.flags = DT_INTEGER,
|
||||
.multiplier = 1.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 32,
|
||||
},
|
||||
{
|
||||
DESC_DEF( fieldName ),
|
||||
.flags = DT_STRING,
|
||||
.multiplier = 1.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 1,
|
||||
},
|
||||
{
|
||||
DESC_DEF( fieldOffset ),
|
||||
.flags = DT_INTEGER,
|
||||
.multiplier = 1.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 16,
|
||||
},
|
||||
{
|
||||
DESC_DEF( fieldSize ),
|
||||
.flags = DT_INTEGER,
|
||||
.multiplier = 1.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 8,
|
||||
},
|
||||
{
|
||||
DESC_DEF( significant_bits ),
|
||||
.flags = DT_INTEGER,
|
||||
.multiplier = 1.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 8,
|
||||
},
|
||||
{
|
||||
DESC_DEF( premultiply ),
|
||||
.flags = DT_FLOAT,
|
||||
.multiplier = 4000.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 32,
|
||||
},
|
||||
{
|
||||
DESC_DEF( postmultiply ),
|
||||
.flags = DT_FLOAT,
|
||||
.multiplier = 4000.0f,
|
||||
.post_multiplier = 1.0f,
|
||||
.bits = 32,
|
||||
},
|
||||
},
|
||||
.bInitialized = true
|
||||
};
|
||||
|
||||
static delta_info_t *Delta_FindStruct( const char *name )
|
||||
{
|
||||
int i;
|
||||
@@ -493,7 +553,7 @@ static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags,
|
||||
int i;
|
||||
|
||||
// check for coexisting field
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields; i++, pField++ )
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields && pField; i++, pField++ )
|
||||
{
|
||||
if( !Q_strcmp( pField->name, pName ))
|
||||
{
|
||||
@@ -988,7 +1048,7 @@ compare fields by offsets
|
||||
assume from and to is valid
|
||||
=====================
|
||||
*/
|
||||
static qboolean Delta_CompareField( delta_t *pField, void *from, void *to, double timebase )
|
||||
static qboolean Delta_CompareField( delta_t *pField, const void *from, const void *to )
|
||||
{
|
||||
int signbit = ( pField->flags & DT_SIGNED ) ? 1 : 0;
|
||||
float val_a, val_b;
|
||||
@@ -1109,7 +1169,7 @@ Delta_TestBaseline
|
||||
compare baselines to find optimal
|
||||
=====================
|
||||
*/
|
||||
int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean player, double timebase )
|
||||
int Delta_TestBaseline( const entity_state_t *from, const entity_state_t *to, qboolean player, double timebase )
|
||||
{
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
@@ -1145,7 +1205,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
||||
// flag about field change (sets always)
|
||||
countBits++;
|
||||
|
||||
if( !Delta_CompareField( pField, from, to, timebase ))
|
||||
if( !Delta_CompareField( pField, from, to ))
|
||||
{
|
||||
// strings are handled differently
|
||||
if( FBitSet( pField->flags, DT_STRING ))
|
||||
@@ -1166,7 +1226,7 @@ write fields by offsets
|
||||
assume from and to is valid
|
||||
=====================
|
||||
*/
|
||||
static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase )
|
||||
static void Delta_WriteField_( sizebuf_t *msg, delta_t *pField, const void *from, const void *to, double timebase )
|
||||
{
|
||||
int signbit = FBitSet( pField->flags, DT_SIGNED ) ? 1 : 0;
|
||||
float flValue, flAngle;
|
||||
@@ -1174,14 +1234,6 @@ static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, v
|
||||
int dt;
|
||||
const char *pStr;
|
||||
|
||||
if( Delta_CompareField( pField, from, to, timebase ))
|
||||
{
|
||||
MSG_WriteOneBit( msg, 0 ); // unchanged
|
||||
return false;
|
||||
}
|
||||
|
||||
MSG_WriteOneBit( msg, 1 ); // changed
|
||||
|
||||
if( pField->flags & DT_BYTE )
|
||||
{
|
||||
if( signbit )
|
||||
@@ -1255,6 +1307,20 @@ static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, v
|
||||
pStr = (char *)((byte *)to + pField->offset );
|
||||
MSG_WriteString( msg, pStr );
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, const void *from, const void *to, double timebase )
|
||||
{
|
||||
if( Delta_CompareField( pField, from, to ))
|
||||
{
|
||||
MSG_WriteOneBit( msg, 0 ); // unchanged
|
||||
return false;
|
||||
}
|
||||
|
||||
MSG_WriteOneBit( msg, 1 ); // changed
|
||||
|
||||
Delta_WriteField_( msg, pField, from, to, timebase );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1264,7 +1330,7 @@ Delta_CopyField
|
||||
|
||||
====================
|
||||
*/
|
||||
static void Delta_CopyField( delta_t *pField, void *from, void *to, double timebase )
|
||||
static void Delta_CopyField( delta_t *pField, const void *from, void *to, double timebase )
|
||||
{
|
||||
qboolean bSigned = FBitSet( pField->flags, DT_SIGNED );
|
||||
uint8_t *to_field = (uint8_t *)to + pField->offset;
|
||||
@@ -1313,7 +1379,7 @@ read fields by offsets
|
||||
assume 'from' and 'to' is valid
|
||||
=====================
|
||||
*/
|
||||
static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase )
|
||||
static void Delta_ReadField_( sizebuf_t *msg, delta_t *pField, void *to, double timebase )
|
||||
{
|
||||
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
|
||||
float flValue, flAngle, flTime;
|
||||
@@ -1321,12 +1387,6 @@ static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, vo
|
||||
const char *pStr;
|
||||
char *pOut;
|
||||
|
||||
if( !MSG_ReadOneBit( msg ) )
|
||||
{
|
||||
Delta_CopyField( pField, from, to, timebase );
|
||||
return false;
|
||||
}
|
||||
|
||||
Assert( pField->multiplier != 0.0f );
|
||||
|
||||
if( pField->flags & DT_BYTE )
|
||||
@@ -1410,9 +1470,85 @@ static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, vo
|
||||
pOut = (char *)((byte *)to + pField->offset );
|
||||
Q_strncpy( pOut, pStr, pField->size );
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, const void *from, void *to, double timebase )
|
||||
{
|
||||
if( !MSG_ReadOneBit( msg ))
|
||||
{
|
||||
Delta_CopyField( pField, from, to, timebase );
|
||||
return false;
|
||||
}
|
||||
|
||||
Delta_ReadField_( msg, pField, to, timebase );
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Delta_ParseGSFields( sizebuf_t *msg, const delta_info_t *dt, const void *from, void *to, double timebase )
|
||||
{
|
||||
uint8_t bits[8] = { 0 };
|
||||
delta_t *pField;
|
||||
byte c;
|
||||
int i;
|
||||
|
||||
c = MSG_ReadUBitLong( msg, 3 );
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
bits[i] = MSG_ReadByte( msg );
|
||||
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
int b = i >> 3;
|
||||
int n = 1 << ( i & 7 );
|
||||
|
||||
if( FBitSet( bits[b], n ))
|
||||
Delta_ReadField_( msg, pField, to, timebase );
|
||||
else Delta_CopyField( pField, from, to, timebase );
|
||||
}
|
||||
}
|
||||
|
||||
void Delta_ReadGSFields( sizebuf_t *msg, int index, const void *from, void *to, double timebase )
|
||||
{
|
||||
const delta_info_t *dt = Delta_FindStructByIndex( index );
|
||||
Delta_ParseGSFields( msg, dt, from, to, timebase );
|
||||
}
|
||||
|
||||
void Delta_WriteGSFields( sizebuf_t *msg, int index, const void *from, const void *to, double timebase )
|
||||
{
|
||||
delta_info_t *dt = Delta_FindStructByIndex( index );
|
||||
delta_t *pField;
|
||||
uint8_t bits[8] = { 0 };
|
||||
uint c = 0;
|
||||
int i;
|
||||
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
if( !Delta_CompareField( pField, from, to ))
|
||||
{
|
||||
int b = i >> 3;
|
||||
int n = 1 << ( i & 7 );
|
||||
|
||||
SetBits( bits[b], n );
|
||||
c = b + 1;
|
||||
}
|
||||
}
|
||||
|
||||
MSG_WriteUBitLong( msg, c, 3 );
|
||||
for( i = 0; i < c; i++ )
|
||||
MSG_WriteByte( msg, bits[i] );
|
||||
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
int b = i >> 3;
|
||||
int n = 1 << ( i & 7 );
|
||||
|
||||
if( FBitSet( bits[b], n ))
|
||||
Delta_WriteField_( msg, pField, from, to, timebase );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
@@ -1425,7 +1561,7 @@ usercmd_t communication
|
||||
MSG_WriteDeltaUsercmd
|
||||
=====================
|
||||
*/
|
||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, const usercmd_t *from, const usercmd_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1452,7 +1588,7 @@ void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
||||
MSG_ReadDeltaUsercmd
|
||||
=====================
|
||||
*/
|
||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to )
|
||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, const usercmd_t *from, usercmd_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1487,7 +1623,7 @@ event_args_t communication
|
||||
MSG_WriteDeltaEvent
|
||||
=====================
|
||||
*/
|
||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, const event_args_t *from, const event_args_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1514,7 +1650,7 @@ void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
||||
MSG_ReadDeltaEvent
|
||||
=====================
|
||||
*/
|
||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to )
|
||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, const event_args_t *from, event_args_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1542,7 +1678,7 @@ movevars_t communication
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to )
|
||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const movevars_t *from, const movevars_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1578,7 +1714,7 @@ qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *t
|
||||
return true;
|
||||
}
|
||||
|
||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to )
|
||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, const movevars_t *from, movevars_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1614,7 +1750,7 @@ Writes current client data only for local client
|
||||
Other clients can grab the client state from entity_state_t
|
||||
==================
|
||||
*/
|
||||
void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, double timebase )
|
||||
void MSG_WriteClientData( sizebuf_t *msg, const clientdata_t *from, const clientdata_t *to, double timebase )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1654,7 +1790,7 @@ MSG_ReadClientData
|
||||
Read the clientdata
|
||||
==================
|
||||
*/
|
||||
void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, double timebase )
|
||||
void MSG_ReadClientData( sizebuf_t *msg, const clientdata_t *from, clientdata_t *to, double timebase )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
delta_t *pField;
|
||||
@@ -1695,7 +1831,7 @@ Writes current client data only for local client
|
||||
Other clients can grab the client state from entity_state_t
|
||||
==================
|
||||
*/
|
||||
void MSG_WriteWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, double timebase, int index )
|
||||
void MSG_WriteWeaponData( sizebuf_t *msg, const weapon_data_t *from, const weapon_data_t *to, double timebase, int index )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1734,7 +1870,7 @@ MSG_ReadWeaponData
|
||||
Read the clientdata
|
||||
==================
|
||||
*/
|
||||
void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, double timebase )
|
||||
void MSG_ReadWeaponData( sizebuf_t *msg, const weapon_data_t *from, weapon_data_t *to, double timebase )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
@@ -1771,7 +1907,7 @@ If force is not set, then nothing at all will be generated if the entity is
|
||||
identical, under the assumption that the in-order delta code will catch it.
|
||||
==================
|
||||
*/
|
||||
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int delta_type, double timebase, int baseline )
|
||||
void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to, sizebuf_t *msg, qboolean force, int delta_type, double timebase, int baseline )
|
||||
{
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
@@ -1873,7 +2009,7 @@ If the delta removes the entity, entity_state_t->number will be set to MAX_EDICT
|
||||
Can go from either a baseline or a previous packet_entity
|
||||
==================
|
||||
*/
|
||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase )
|
||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
delta_info_t *dt = NULL;
|
||||
@@ -1882,7 +2018,10 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
||||
int baseline_offset = 0;
|
||||
|
||||
if( number < 0 || number >= clgame.maxEntities )
|
||||
Host_Error( "%s: bad delta entity number: %i\n", __func__, number );
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: bad delta entity number: %i\n", __func__, number );
|
||||
return false;
|
||||
}
|
||||
|
||||
fRemoveType = MSG_ReadUBitLong( msg, 2 );
|
||||
|
||||
@@ -1904,7 +2043,8 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
||||
return false;
|
||||
}
|
||||
|
||||
Host_Error( "%s: unknown update type %i\n", __func__, fRemoveType );
|
||||
Con_Printf( S_ERROR "%s: unknown update type %i\n", __func__, fRemoveType );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !cls.legacymode )
|
||||
@@ -1952,7 +2092,11 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
||||
}
|
||||
|
||||
Assert( dt && dt->bInitialized );
|
||||
if( !dt || !dt->bInitialized )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: broken delta\n", __func__ );
|
||||
return true;
|
||||
}
|
||||
|
||||
pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
@@ -1967,6 +2111,44 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
||||
return true;
|
||||
}
|
||||
|
||||
void Delta_ParseTableField_GS( sizebuf_t *msg )
|
||||
{
|
||||
const char *s = MSG_ReadString( msg );
|
||||
delta_info_t *dt = Delta_FindStruct( s );
|
||||
goldsrc_delta_t null = { 0 };
|
||||
int i, num_fields;
|
||||
|
||||
// delta encoders it's already initialized on this machine (local game)
|
||||
if( delta_init )
|
||||
Delta_Shutdown();
|
||||
|
||||
if( !dt )
|
||||
Host_Error( "%s: not initialized", __func__ );
|
||||
|
||||
num_fields = MSG_ReadShort( msg );
|
||||
if( num_fields > dt->maxFields )
|
||||
Host_Error( "%s: numFields > maxFields", __func__ );
|
||||
|
||||
MSG_StartBitWriting( msg );
|
||||
|
||||
for( i = 0; i < num_fields; i++ )
|
||||
{
|
||||
goldsrc_delta_t to;
|
||||
|
||||
Delta_ParseGSFields( msg, &dt_goldsrc_meta, &null, &to, 0.0f );
|
||||
|
||||
// patch our DT_SIGNED flag
|
||||
if( FBitSet( to.fieldType, DT_SIGNED_GS ))
|
||||
{
|
||||
ClearBits( to.fieldType, DT_SIGNED_GS );
|
||||
SetBits( to.fieldType, DT_SIGNED );
|
||||
}
|
||||
Delta_AddField( dt, to.fieldName, to.fieldType, to.significant_bits, to.premultiply, to.postmultiply );
|
||||
}
|
||||
|
||||
MSG_EndBitWriting( msg );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Delta_WriteDescriptionToClient
|
||||
|
||||
@@ -33,6 +33,22 @@ enum
|
||||
DELTA_STATIC,
|
||||
};
|
||||
|
||||
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,
|
||||
#if XASH_ENGINE_TESTS
|
||||
DT_DELTA_TEST_STRUCT_T,
|
||||
#endif
|
||||
DT_STRUCT_COUNT
|
||||
};
|
||||
|
||||
// struct info (filled by engine)
|
||||
typedef struct
|
||||
{
|
||||
@@ -54,6 +70,17 @@ struct delta_s
|
||||
qboolean bInactive; // unsetted by user request
|
||||
};
|
||||
|
||||
typedef struct goldsrc_delta_s
|
||||
{
|
||||
int fieldType;
|
||||
char fieldName[32];
|
||||
int fieldOffset;
|
||||
short fieldSize;
|
||||
int significant_bits;
|
||||
float premultiply;
|
||||
float postmultiply;
|
||||
} goldsrc_delta_t;
|
||||
|
||||
typedef void (*pfnDeltaEncode)( struct delta_s *pFields, const byte *from, const byte *to );
|
||||
|
||||
typedef struct
|
||||
@@ -87,6 +114,7 @@ void Delta_UnsetFieldByIndex( delta_t *pFields, int fieldNumber );
|
||||
// send table over network
|
||||
void Delta_WriteDescriptionToClient( sizebuf_t *msg );
|
||||
void Delta_ParseTableField( sizebuf_t *msg );
|
||||
void Delta_ParseTableField_GS( sizebuf_t *msg );
|
||||
|
||||
|
||||
// encode routines
|
||||
@@ -96,18 +124,20 @@ struct event_args_s;
|
||||
struct movevars_s;
|
||||
struct clientdata_s;
|
||||
struct weapon_data_s;
|
||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to );
|
||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to );
|
||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to );
|
||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to );
|
||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to );
|
||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to );
|
||||
void MSG_WriteClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, double timebase );
|
||||
void MSG_ReadClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, double timebase );
|
||||
void MSG_WriteWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase, int index );
|
||||
void MSG_ReadWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase );
|
||||
void MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs );
|
||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase );
|
||||
int Delta_TestBaseline( struct entity_state_s *from, struct entity_state_s *to, qboolean player, double timebase );
|
||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, const struct usercmd_s *from, const struct usercmd_s *to );
|
||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, const struct usercmd_s *from, struct usercmd_s *to );
|
||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, const struct event_args_s *from, const struct event_args_s *to );
|
||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, const struct event_args_s *from, struct event_args_s *to );
|
||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const struct movevars_s *from, const struct movevars_s *to );
|
||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, const struct movevars_s *from, struct movevars_s *to );
|
||||
void MSG_WriteClientData( sizebuf_t *msg, const struct clientdata_s *from, const struct clientdata_s *to, double timebase );
|
||||
void MSG_ReadClientData( sizebuf_t *msg, const struct clientdata_s *from, struct clientdata_s *to, double timebase );
|
||||
void MSG_WriteWeaponData( sizebuf_t *msg, const struct weapon_data_s *from, const struct weapon_data_s *to, double timebase, int index );
|
||||
void MSG_ReadWeaponData( sizebuf_t *msg, const struct weapon_data_s *from, struct weapon_data_s *to, double timebase );
|
||||
void MSG_WriteDeltaEntity( const struct entity_state_s *from, const struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs );
|
||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase );
|
||||
int Delta_TestBaseline( const struct entity_state_s *from, const struct entity_state_s *to, qboolean player, double timebase );
|
||||
void Delta_ReadGSFields( sizebuf_t *msg, int index, const void *from, void *to, double timebase );
|
||||
void Delta_WriteGSFields( sizebuf_t *msg, int index, const void *from, const void *to, double timebase );
|
||||
|
||||
#endif//NET_ENCODE_H
|
||||
|
||||
1188
engine/common/net_http.c
Normal file
1188
engine/common/net_http.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -50,8 +50,10 @@ 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;
|
||||
extern convar_t net_send_debug;
|
||||
extern convar_t net_recv_debug;
|
||||
|
||||
void NET_Init( void );
|
||||
void NET_Shutdown( void );
|
||||
@@ -59,14 +61,13 @@ void NET_Sleep( int msec );
|
||||
qboolean NET_IsActive( void );
|
||||
qboolean NET_IsConfigured( void );
|
||||
void NET_Config( qboolean net_enable, qboolean changeport );
|
||||
qboolean NET_IsLocalAddress( netadr_t adr );
|
||||
const char *NET_AdrToString( const netadr_t a );
|
||||
const char *NET_BaseAdrToString( const netadr_t a );
|
||||
qboolean NET_IsReservedAdr( netadr_t a );
|
||||
qboolean NET_CompareClassBAdr( const netadr_t a, const netadr_t b );
|
||||
qboolean NET_StringToAdr( const char *string, netadr_t *adr );
|
||||
qboolean NET_StringToFilterAdr( const char *s, netadr_t *adr, uint *prefixlen );
|
||||
net_gai_state_t NET_StringToAdrNB( const char *string, netadr_t *adr );
|
||||
net_gai_state_t NET_StringToAdrNB( const char *string, netadr_t *adr, qboolean v6only );
|
||||
int NET_CompareAdrSort( const void *_a, const void *_b );
|
||||
qboolean NET_CompareAdr( const netadr_t a, const netadr_t b );
|
||||
qboolean NET_CompareBaseAdr( const netadr_t a, const netadr_t b );
|
||||
@@ -74,17 +75,20 @@ qboolean NET_CompareAdrByMask( const netadr_t a, const netadr_t b, uint prefixle
|
||||
qboolean NET_GetPacket( netsrc_t sock, netadr_t *from, byte *data, size_t *length );
|
||||
void NET_SendPacket( netsrc_t sock, size_t length, const void *data, netadr_t to );
|
||||
void NET_SendPacketEx( netsrc_t sock, size_t length, const void *data, netadr_t to, size_t splitsize );
|
||||
void NET_ClearLagData( qboolean bClient, qboolean bServer );
|
||||
void NET_IP6BytesToNetadr( netadr_t *adr, const uint8_t *ip6 );
|
||||
void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr );
|
||||
|
||||
static inline qboolean NET_IsLocalAddress( netadr_t adr )
|
||||
{
|
||||
return adr.type == NA_LOOPBACK ? true : false;
|
||||
}
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
qboolean CL_LegacyMode( void );
|
||||
int CL_GetSplitSize( void );
|
||||
#endif
|
||||
|
||||
void HTTP_AddCustomServer( const char *url );
|
||||
void HTTP_AddDownload( const char *path, int size, qboolean process );
|
||||
void HTTP_AddDownload( const char *path, int size, qboolean process, resource_t *res );
|
||||
void HTTP_ClearCustomServers( void );
|
||||
void HTTP_Shutdown( void );
|
||||
void HTTP_ResetProcessState( void );
|
||||
|
||||
103
engine/common/net_ws_private.h
Normal file
103
engine/common/net_ws_private.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
net_ws_private.h - networking private definitions
|
||||
Copyright (C) 2024 Alibek Omarov
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
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 "net_ws.h"
|
||||
#if XASH_NO_NETWORK
|
||||
#include "platform/stub/net_stub.h"
|
||||
#elif XASH_WIN32
|
||||
#include "platform/win32/net.h"
|
||||
#elif XASH_PSVITA
|
||||
#include "platform/psvita/net_psvita.h"
|
||||
static const struct in6_addr in6addr_any;
|
||||
#else
|
||||
#include "platform/posix/net.h"
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// net_ws.c
|
||||
//
|
||||
static inline const char *NET_ErrorString( void )
|
||||
{
|
||||
#if XASH_WIN32
|
||||
int err = WSAGetLastError();
|
||||
switch( err )
|
||||
{
|
||||
case WSAEINTR: return "WSAEINTR";
|
||||
case WSAEBADF: return "WSAEBADF";
|
||||
case WSAEACCES: return "WSAEACCES";
|
||||
case WSAEFAULT: return "WSAEFAULT";
|
||||
case WSAEINVAL: return "WSAEINVAL";
|
||||
case WSAEMFILE: return "WSAEMFILE";
|
||||
case WSAEWOULDBLOCK: return "WSAEWOULDBLOCK";
|
||||
case WSAEINPROGRESS: return "WSAEINPROGRESS";
|
||||
case WSAEALREADY: return "WSAEALREADY";
|
||||
case WSAENOTSOCK: return "WSAENOTSOCK";
|
||||
case WSAEDESTADDRREQ: return "WSAEDESTADDRREQ";
|
||||
case WSAEMSGSIZE: return "WSAEMSGSIZE";
|
||||
case WSAEPROTOTYPE: return "WSAEPROTOTYPE";
|
||||
case WSAENOPROTOOPT: return "WSAENOPROTOOPT";
|
||||
case WSAEPROTONOSUPPORT: return "WSAEPROTONOSUPPORT";
|
||||
case WSAESOCKTNOSUPPORT: return "WSAESOCKTNOSUPPORT";
|
||||
case WSAEOPNOTSUPP: return "WSAEOPNOTSUPP";
|
||||
case WSAEPFNOSUPPORT: return "WSAEPFNOSUPPORT";
|
||||
case WSAEAFNOSUPPORT: return "WSAEAFNOSUPPORT";
|
||||
case WSAEADDRINUSE: return "WSAEADDRINUSE";
|
||||
case WSAEADDRNOTAVAIL: return "WSAEADDRNOTAVAIL";
|
||||
case WSAENETDOWN: return "WSAENETDOWN";
|
||||
case WSAENETUNREACH: return "WSAENETUNREACH";
|
||||
case WSAENETRESET: return "WSAENETRESET";
|
||||
case WSAECONNABORTED: return "WSWSAECONNABORTEDAEINTR";
|
||||
case WSAECONNRESET: return "WSAECONNRESET";
|
||||
case WSAENOBUFS: return "WSAENOBUFS";
|
||||
case WSAEISCONN: return "WSAEISCONN";
|
||||
case WSAENOTCONN: return "WSAENOTCONN";
|
||||
case WSAESHUTDOWN: return "WSAESHUTDOWN";
|
||||
case WSAETOOMANYREFS: return "WSAETOOMANYREFS";
|
||||
case WSAETIMEDOUT: return "WSAETIMEDOUT";
|
||||
case WSAECONNREFUSED: return "WSAECONNREFUSED";
|
||||
case WSAELOOP: return "WSAELOOP";
|
||||
case WSAENAMETOOLONG: return "WSAENAMETOOLONG";
|
||||
case WSAEHOSTDOWN: return "WSAEHOSTDOWN";
|
||||
case WSAEDISCON: return "WSAEDISCON";
|
||||
case WSASYSNOTREADY: return "WSASYSNOTREADY";
|
||||
case WSAVERNOTSUPPORTED: return "WSAVERNOTSUPPORTED";
|
||||
case WSANOTINITIALISED: return "WSANOTINITIALISED";
|
||||
case WSAHOST_NOT_FOUND: return "WSAHOST_NOT_FOUND";
|
||||
case WSATRY_AGAIN: return "WSATRY_AGAIN";
|
||||
case WSANO_RECOVERY: return "WSANO_RECOVERY";
|
||||
case WSANO_DATA: return "WSANO_DATA";
|
||||
}
|
||||
|
||||
return "NO ERROR";
|
||||
#else
|
||||
return strerror( errno );
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline socklen_t NET_SockAddrLen( const struct sockaddr_storage *addr )
|
||||
{
|
||||
switch ( addr->ss_family )
|
||||
{
|
||||
case AF_INET:
|
||||
return sizeof( struct sockaddr_in );
|
||||
case AF_INET6:
|
||||
return sizeof( struct sockaddr_in6 );
|
||||
default:
|
||||
return sizeof( *addr ); // what the fuck is this?
|
||||
}
|
||||
}
|
||||
|
||||
net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_storage *sadr, qboolean nonblocking, int family );
|
||||
@@ -208,6 +208,14 @@ typedef enum fragsize_e
|
||||
FRAGSIZE_UNRELIABLE
|
||||
} fragsize_t;
|
||||
|
||||
typedef enum netchan_flags_e
|
||||
{
|
||||
NETCHAN_USE_LEGACY_SPLIT = BIT( 0 ),
|
||||
NETCHAN_USE_MUNGE = BIT( 1 ),
|
||||
NETCHAN_USE_BZIP2 = BIT( 2 ),
|
||||
NETCHAN_GOLDSRC = BIT( 3 ),
|
||||
} netchan_flags_t;
|
||||
|
||||
// Network Connection Channel
|
||||
typedef struct netchan_s
|
||||
{
|
||||
@@ -270,10 +278,14 @@ typedef struct netchan_s
|
||||
// added for net_speeds
|
||||
size_t total_sended;
|
||||
size_t total_received;
|
||||
qboolean split;
|
||||
unsigned int maxpacket;
|
||||
unsigned int splitid;
|
||||
netsplit_t netsplit;
|
||||
netsplit_t netsplit;
|
||||
|
||||
qboolean split;
|
||||
qboolean use_munge;
|
||||
qboolean use_bz2;
|
||||
qboolean gs_netchan;
|
||||
} netchan_t;
|
||||
|
||||
extern netadr_t net_from;
|
||||
@@ -287,14 +299,14 @@ extern int net_drop;
|
||||
|
||||
void Netchan_Init( void );
|
||||
void Netchan_Shutdown( void );
|
||||
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, void *client, int (*pfnBlockSize)(void *, fragsize_t mode ) );
|
||||
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, void *client, int (*pfnBlockSize)(void *, fragsize_t mode ), uint flags );
|
||||
void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filename, byte *pbuf, int size );
|
||||
qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *length );
|
||||
qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg );
|
||||
void Netchan_CreateFragments( netchan_t *chan, sizebuf_t *msg );
|
||||
int Netchan_CreateFileFragments( netchan_t *chan, const char *filename );
|
||||
void Netchan_TransmitBits( netchan_t *chan, int lengthInBits, byte *data );
|
||||
void Netchan_OutOfBand( int net_socket, netadr_t adr, int length, byte *data );
|
||||
void Netchan_TransmitBits( netchan_t *chan, int lengthInBits, const byte *data );
|
||||
void Netchan_OutOfBand( int net_socket, netadr_t adr, int length, const byte *data );
|
||||
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, const char *format, ... ) _format( 3 );
|
||||
qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg );
|
||||
void Netchan_UpdateProgress( netchan_t *chan );
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
pm_debug.c - player move debugging code
|
||||
Copyright (C) 2017 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "pm_local.h"
|
||||
#if !XASH_DEDICATED
|
||||
#include "client.h" // CL_Particle
|
||||
#endif
|
||||
|
||||
// expand debugging BBOX particle hulls by this many units.
|
||||
#define BOX_GAP 0.0f
|
||||
|
||||
/*
|
||||
===============
|
||||
PM_ParticleLine
|
||||
|
||||
draw line from particles
|
||||
================
|
||||
*/
|
||||
void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
float len, curdist;
|
||||
vec3_t diff, pos;
|
||||
|
||||
// determine distance
|
||||
VectorSubtract( end, start, diff );
|
||||
len = VectorNormalizeLength( diff );
|
||||
curdist = 0;
|
||||
|
||||
while( curdist <= len )
|
||||
{
|
||||
VectorMA( start, curdist, diff, pos );
|
||||
CL_Particle( pos, pcolor, life, 0, zvel );
|
||||
curdist += 2.0f;
|
||||
}
|
||||
#endif // XASH_DEDICATED
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
PM_DrawRectangle
|
||||
|
||||
================
|
||||
*/
|
||||
static void PM_DrawRectangle( const vec3_t tl, const vec3_t bl, const vec3_t tr, const vec3_t br, int pcolor, float life )
|
||||
{
|
||||
PM_ParticleLine( tl, bl, pcolor, life, 0 );
|
||||
PM_ParticleLine( bl, br, pcolor, life, 0 );
|
||||
PM_ParticleLine( br, tr, pcolor, life, 0 );
|
||||
PM_ParticleLine( tr, tl, pcolor, life, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
PM_DrawBBox
|
||||
|
||||
================
|
||||
*/
|
||||
void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int pcolor, float life )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
vec3_t p[8], tmp;
|
||||
float gap = BOX_GAP;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
tmp[0] = (i & 1) ? mins[0] - gap : maxs[0] + gap;
|
||||
tmp[1] = (i & 2) ? mins[1] - gap : maxs[1] + gap ;
|
||||
tmp[2] = (i & 4) ? mins[2] - gap : maxs[2] + gap ;
|
||||
|
||||
VectorAdd( tmp, origin, tmp );
|
||||
VectorCopy( tmp, p[i] );
|
||||
}
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
{
|
||||
PM_DrawRectangle( p[boxpnt[i][1]], p[boxpnt[i][0]], p[boxpnt[i][2]], p[boxpnt[i][3]], pcolor, life );
|
||||
}
|
||||
#endif // XASH_DEDICATED
|
||||
}
|
||||
@@ -20,17 +20,10 @@ GNU General Public License for more details.
|
||||
|
||||
typedef int (*pfnIgnore)( physent_t *pe ); // custom trace filter
|
||||
|
||||
//
|
||||
// pm_debug.c
|
||||
//
|
||||
void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel );
|
||||
void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int pcolor, float life );
|
||||
|
||||
//
|
||||
// pm_trace.c
|
||||
//
|
||||
void Pmove_Init( void );
|
||||
void PM_ClearPhysEnts( playermove_t *pmove );
|
||||
void PM_InitBoxHull( void );
|
||||
hull_t *PM_HullForBsp( physent_t *pe, playermove_t *pmove, float *offset );
|
||||
qboolean PM_RecursiveHullCheck( hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace );
|
||||
@@ -46,7 +39,29 @@ struct msurface_s *PM_TraceSurfacePmove( playermove_t *pmove, int ground, float
|
||||
const char *PM_TraceTexture( playermove_t *pmove, int ground, float *vstart, float *vend );
|
||||
int PM_PointContentsPmove( playermove_t *pmove, const float *p, int *truecontents );
|
||||
void PM_StuckTouch( playermove_t *pmove, int hitent, pmtrace_t *tr );
|
||||
void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent );
|
||||
|
||||
static inline void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent )
|
||||
{
|
||||
out->allsolid = in->allsolid;
|
||||
out->startsolid = in->startsolid;
|
||||
out->inopen = in->inopen;
|
||||
out->inwater = in->inwater;
|
||||
out->fraction = in->fraction;
|
||||
out->plane.dist = in->plane.dist;
|
||||
out->hitgroup = in->hitgroup;
|
||||
out->ent = ent;
|
||||
|
||||
VectorCopy( in->endpos, out->endpos );
|
||||
VectorCopy( in->plane.normal, out->plane.normal );
|
||||
}
|
||||
|
||||
static inline void PM_ClearPhysEnts( playermove_t *pmove )
|
||||
{
|
||||
pmove->nummoveent = 0;
|
||||
pmove->numphysent = 0;
|
||||
pmove->numvisent = 0;
|
||||
pmove->numtouch = 0;
|
||||
}
|
||||
|
||||
static inline void PM_InitTrace( trace_t *trace, const vec3_t end )
|
||||
{
|
||||
|
||||
@@ -55,14 +55,6 @@ void Pmove_Init( void )
|
||||
memcpy( host.player_maxs, pm_hullmaxs, sizeof( pm_hullmaxs ));
|
||||
}
|
||||
|
||||
void PM_ClearPhysEnts( playermove_t *pmove )
|
||||
{
|
||||
pmove->nummoveent = 0;
|
||||
pmove->numphysent = 0;
|
||||
pmove->numvisent = 0;
|
||||
pmove->numtouch = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
PM_InitBoxHull
|
||||
@@ -117,21 +109,6 @@ static hull_t *PM_HullForBox( const vec3_t mins, const vec3_t maxs )
|
||||
return &pm_boxhull;
|
||||
}
|
||||
|
||||
void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent )
|
||||
{
|
||||
out->allsolid = in->allsolid;
|
||||
out->startsolid = in->startsolid;
|
||||
out->inopen = in->inopen;
|
||||
out->inwater = in->inwater;
|
||||
out->fraction = in->fraction;
|
||||
out->plane.dist = in->plane.dist;
|
||||
out->hitgroup = in->hitgroup;
|
||||
out->ent = ent;
|
||||
|
||||
VectorCopy( in->endpos, out->endpos );
|
||||
VectorCopy( in->plane.normal, out->plane.normal );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
PM_HullPointContents
|
||||
|
||||
@@ -73,7 +73,7 @@ GNU General Public License for more details.
|
||||
#define svc_director 51 // <variable sized>
|
||||
#define svc_voiceinit 52 // <see code>
|
||||
#define svc_voicedata 53 // [byte][short][...]
|
||||
#define svc_deltapacketbones 54 // [short][byte][...]
|
||||
// reserved
|
||||
// reserved
|
||||
#define svc_resourcelocation 56 // [string]
|
||||
#define svc_querycvarvalue 57 // [string]
|
||||
@@ -93,7 +93,7 @@ GNU General Public License for more details.
|
||||
#define clc_voicedata 8
|
||||
#define clc_requestcvarvalue 9
|
||||
#define clc_requestcvarvalue2 10
|
||||
#define clc_lastmsg 10 // end client messages
|
||||
#define clc_lastmsg 11 // end client messages (11 is GoldSrc message)
|
||||
|
||||
#define MAX_VISIBLE_PACKET_BITS 11 // 2048 visible entities per frame (hl1 has 256)
|
||||
#define MAX_VISIBLE_PACKET (1<<MAX_VISIBLE_PACKET_BITS)
|
||||
@@ -277,11 +277,11 @@ GNU General Public License for more details.
|
||||
#define SU_ARMOR (1<<13)
|
||||
#define SU_WEAPON (1<<14)
|
||||
|
||||
extern const char *svc_strings[svc_lastmsg+1];
|
||||
extern const char *svc_legacy_strings[svc_lastmsg+1];
|
||||
extern const char *svc_quake_strings[svc_lastmsg+1];
|
||||
extern const char *svc_goldsrc_strings[svc_lastmsg+1];
|
||||
extern const char *clc_strings[clc_lastmsg+1];
|
||||
extern const char *const svc_strings[svc_lastmsg+1];
|
||||
extern const char *const svc_legacy_strings[svc_lastmsg+1];
|
||||
extern const char *const svc_quake_strings[svc_lastmsg+1];
|
||||
extern const char *const svc_goldsrc_strings[svc_lastmsg+1];
|
||||
extern const char *const clc_strings[clc_lastmsg+1];
|
||||
|
||||
// FWGS extensions
|
||||
#define NET_EXT_SPLITSIZE (1U<<0) // set splitsize by cl_dlmax
|
||||
@@ -320,8 +320,7 @@ extern const char *clc_strings[clc_lastmsg+1];
|
||||
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" // TODO: implement IP filter
|
||||
|
||||
// GoldSrc protocol definitions
|
||||
#define PROTOCOL_GOLDSRC_VERSION_REAL 48
|
||||
#define PROTOCOL_GOLDSRC_VERSION (PROTOCOL_GOLDSRC_VERSION_REAL | (BIT( 7 ))) // should be 48, only to differentiate it from PROTOCOL_LEGACY_VERSION
|
||||
#define PROTOCOL_GOLDSRC_VERSION 48
|
||||
|
||||
#define svc_goldsrc_version svc_changing
|
||||
#define svc_goldsrc_serverinfo svc_serverdata
|
||||
@@ -342,17 +341,66 @@ extern const char *clc_strings[clc_lastmsg+1];
|
||||
#define clc_goldsrc_hltv clc_requestcvarvalue // 9
|
||||
#define clc_goldsrc_requestcvarvalue clc_requestcvarvalue2 // 10
|
||||
#define clc_goldsrc_requestcvarvalue2 11
|
||||
#define clc_goldsrc_lastmsg 12
|
||||
|
||||
#define S2C_REJECT_BADPASSWORD '8'
|
||||
#define S2C_REJECT '9'
|
||||
#define S2C_CHALLENGE "A00000000"
|
||||
#define S2C_CONNECTION "B"
|
||||
#define clc_goldsrc_lastmsg 11
|
||||
|
||||
#define MAX_GOLDSRC_BACKUP_CMDS 8
|
||||
#define MAX_GOLDSRC_TOTAL_CMDS 16
|
||||
#define MAX_GOLDSRC_MODEL_BITS 10
|
||||
#define MAX_GOLDSRC_RESOURCE_BITS 12
|
||||
#define MAX_GOLDSRC_ENTITY_BITS 11
|
||||
// #define MAX_GOLDSRC_EDICTS BIT( MAX_ENTITY_BITS )
|
||||
#define MAX_GOLDSRC_EDICTS ( BIT( MAX_ENTITY_BITS ) + ( MAX_CLIENTS * 15 ))
|
||||
#define LAST_GOLDSRC_EDICT ( BIT( MAX_ENTITY_BITS ) - 1 )
|
||||
|
||||
|
||||
// from any to any (must be handled on both server and client)
|
||||
|
||||
#define A2A_PING "ping" // reply with A2A_ACK
|
||||
#define A2A_ACK "ack" // no-op
|
||||
#define A2A_INFO "info" // different format for client and server, see code
|
||||
#define A2A_NETINFO "netinfo" // different format for client and server, see code
|
||||
#define A2A_GOLDSRC_PING "i" // reply with A2A_GOLDSRC_ACK
|
||||
#define A2A_GOLDSRC_ACK "j" // no-op
|
||||
|
||||
// from any to server
|
||||
#define A2S_GOLDSRC_INFO "TSource Engine Query"
|
||||
#define A2S_GOLDSRC_RULES 'V'
|
||||
#define A2S_GOLDSRC_PLAYERS 'U'
|
||||
|
||||
// from server to any
|
||||
#define S2A_GOLDSRC_INFO 'I'
|
||||
#define S2A_GOLDSRC_RULES 'E'
|
||||
#define S2A_GOLDSRC_PLAYERS 'D'
|
||||
|
||||
// from master to server
|
||||
#define M2S_CHALLENGE "s"
|
||||
#define M2S_NAT_CONNECT "c"
|
||||
|
||||
// from server to master
|
||||
#define S2M_INFO "0\n"
|
||||
|
||||
// from client to server
|
||||
#define C2S_BANDWIDTHTEST "bandwidth"
|
||||
#define C2S_GETCHALLENGE "getchallenge"
|
||||
#define C2S_CONNECT "connect"
|
||||
#define C2S_RCON "rcon"
|
||||
|
||||
// from server to client
|
||||
#define S2C_BANDWIDTHTEST "testpacket"
|
||||
#define S2C_CHALLENGE "challenge"
|
||||
#define S2C_CONNECTION "client_connect"
|
||||
#define S2C_ERRORMSG "errormsg"
|
||||
#define S2C_REJECT "disconnect"
|
||||
#define S2C_GOLDSRC_REJECT_BADPASSWORD '8'
|
||||
#define S2C_GOLDSRC_REJECT '9'
|
||||
#define S2C_GOLDSRC_CHALLENGE "A00000000"
|
||||
#define S2C_GOLDSRC_CONNECTION "B"
|
||||
|
||||
// from any to client
|
||||
#define A2C_PRINT "print"
|
||||
#define A2C_GOLDSRC_PRINT 'l'
|
||||
|
||||
// from master to client
|
||||
#define M2A_SERVERSLIST "f"
|
||||
|
||||
#endif//NET_PROTOCOL_H
|
||||
|
||||
@@ -30,7 +30,7 @@ static void Sound_Reset( void )
|
||||
sound.size = 0;
|
||||
}
|
||||
|
||||
static wavdata_t *SoundPack( void )
|
||||
static MALLOC_LIKE( FS_FreeSound, 1 ) wavdata_t *SoundPack( void )
|
||||
{
|
||||
wavdata_t *pack = Mem_Calloc( host.soundpool, sizeof( wavdata_t ));
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ enum soundlst_type_e
|
||||
SoundList_List
|
||||
};
|
||||
|
||||
static const char *soundlst_groups[SoundList_Groups] =
|
||||
static const char *const soundlst_groups[SoundList_Groups] =
|
||||
{
|
||||
"BouncePlayerShell",
|
||||
"BounceWeaponShell",
|
||||
@@ -46,7 +46,7 @@ typedef struct soundlst_s
|
||||
int max; // the string count if type is group
|
||||
} soundlst_t;
|
||||
|
||||
soundlst_t soundlst[SoundList_Groups];
|
||||
static soundlst_t soundlst[SoundList_Groups];
|
||||
|
||||
static void SoundList_Print_f( void );
|
||||
static void SoundList_Free( soundlst_t *lst )
|
||||
|
||||
@@ -230,13 +230,20 @@ static void Sys_PrintLogfile( const int fd, const char *logtime, const char *msg
|
||||
|
||||
if( p == NULL )
|
||||
{
|
||||
write( fd, msg, Q_strlen( msg ));
|
||||
if( write( fd, msg, Q_strlen( msg )) < 0 )
|
||||
{
|
||||
// don't call engine Msg, might cause recursion
|
||||
fprintf( stderr, "%s: write failed: %s\n", __func__, strerror( errno ));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if( IsColorString( p ))
|
||||
{
|
||||
if( p != msg )
|
||||
write( fd, msg, p - msg );
|
||||
{
|
||||
if( write( fd, msg, p - msg ) < 0 )
|
||||
fprintf( stderr, "%s: write failed: %s\n", __func__, strerror( errno ));
|
||||
}
|
||||
msg = p + 2;
|
||||
|
||||
if( colorize )
|
||||
@@ -244,7 +251,8 @@ static void Sys_PrintLogfile( const int fd, const char *logtime, const char *msg
|
||||
}
|
||||
else
|
||||
{
|
||||
write( fd, msg, p - msg + 1 );
|
||||
if( write( fd, msg, p - msg + 1 ) < 0 )
|
||||
fprintf( stderr, "%s: write failed: %s\n", __func__, strerror( errno ));
|
||||
msg = p + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ void Test_RunIPFilter( void );
|
||||
void Test_RunGamma( void );
|
||||
void Test_RunDelta( void );
|
||||
void Test_RunBuffer( void );
|
||||
void Test_RunMunge( void );
|
||||
|
||||
#define TEST_LIST_0 \
|
||||
Test_RunLibCommon(); \
|
||||
@@ -49,7 +50,8 @@ void Test_RunBuffer( void );
|
||||
Test_RunCvar(); \
|
||||
Test_RunIPFilter(); \
|
||||
Test_RunBuffer(); \
|
||||
Test_RunDelta();
|
||||
Test_RunDelta(); \
|
||||
Test_RunMunge();
|
||||
|
||||
#define TEST_LIST_0_CLIENT \
|
||||
Test_RunCon(); \
|
||||
|
||||
@@ -20,47 +20,6 @@ GNU General Public License for more details.
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "studio.h"
|
||||
|
||||
/*
|
||||
==================
|
||||
World_MoveBounds
|
||||
==================
|
||||
*/
|
||||
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
if( end[i] > start[i] )
|
||||
{
|
||||
boxmins[i] = start[i] + mins[i] - 1.0f;
|
||||
boxmaxs[i] = end[i] + maxs[i] + 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
boxmins[i] = end[i] + mins[i] - 1.0f;
|
||||
boxmaxs[i] = start[i] + maxs[i] + 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch )
|
||||
{
|
||||
if( trace->allsolid || trace->startsolid || trace->fraction < cliptrace->fraction )
|
||||
{
|
||||
trace->ent = touch;
|
||||
|
||||
if( cliptrace->startsolid )
|
||||
{
|
||||
*cliptrace = *trace;
|
||||
cliptrace->startsolid = true;
|
||||
}
|
||||
else *cliptrace = *trace;
|
||||
}
|
||||
|
||||
return *cliptrace;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
World_TransformAABB
|
||||
@@ -107,31 +66,3 @@ void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
RankForContents
|
||||
|
||||
Used for determine contents priority
|
||||
==================
|
||||
*/
|
||||
int RankForContents( int contents )
|
||||
{
|
||||
switch( contents )
|
||||
{
|
||||
case CONTENTS_EMPTY: return 0;
|
||||
case CONTENTS_WATER: return 1;
|
||||
case CONTENTS_TRANSLUCENT: return 2;
|
||||
case CONTENTS_CURRENT_0: return 3;
|
||||
case CONTENTS_CURRENT_90: return 4;
|
||||
case CONTENTS_CURRENT_180: return 5;
|
||||
case CONTENTS_CURRENT_270: return 6;
|
||||
case CONTENTS_CURRENT_UP: return 7;
|
||||
case CONTENTS_CURRENT_DOWN: return 8;
|
||||
case CONTENTS_SLIME: return 9;
|
||||
case CONTENTS_LAVA: return 10;
|
||||
case CONTENTS_SKY: return 11;
|
||||
case CONTENTS_SOLID: return 12;
|
||||
default: return 13; // any user contents has more priority than default
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,71 @@ ENTITY AREA CHECKING
|
||||
#include "lightstyle.h"
|
||||
|
||||
// trace common
|
||||
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs );
|
||||
static inline void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
if( end[i] > start[i] )
|
||||
{
|
||||
boxmins[i] = start[i] + mins[i] - 1.0f;
|
||||
boxmaxs[i] = end[i] + maxs[i] + 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
boxmins[i] = end[i] + mins[i] - 1.0f;
|
||||
boxmaxs[i] = start[i] + maxs[i] + 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch )
|
||||
{
|
||||
if( trace->allsolid || trace->startsolid || trace->fraction < cliptrace->fraction )
|
||||
{
|
||||
trace->ent = touch;
|
||||
|
||||
if( cliptrace->startsolid )
|
||||
{
|
||||
*cliptrace = *trace;
|
||||
cliptrace->startsolid = true;
|
||||
}
|
||||
else *cliptrace = *trace;
|
||||
}
|
||||
|
||||
return *cliptrace;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
RankForContents
|
||||
|
||||
Used for determine contents priority
|
||||
==================
|
||||
*/
|
||||
static inline int RankForContents( int contents )
|
||||
{
|
||||
switch( contents )
|
||||
{
|
||||
case CONTENTS_EMPTY: return 0;
|
||||
case CONTENTS_WATER: return 1;
|
||||
case CONTENTS_TRANSLUCENT: return 2;
|
||||
case CONTENTS_CURRENT_0: return 3;
|
||||
case CONTENTS_CURRENT_90: return 4;
|
||||
case CONTENTS_CURRENT_180: return 5;
|
||||
case CONTENTS_CURRENT_270: return 6;
|
||||
case CONTENTS_CURRENT_UP: return 7;
|
||||
case CONTENTS_CURRENT_DOWN: return 8;
|
||||
case CONTENTS_SLIME: return 9;
|
||||
case CONTENTS_LAVA: return 10;
|
||||
case CONTENTS_SKY: return 11;
|
||||
case CONTENTS_SOLID: return 12;
|
||||
default: return 13; // any user contents has more priority than default
|
||||
}
|
||||
}
|
||||
|
||||
void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t maxs, vec3_t outmins, vec3_t outmaxs );
|
||||
trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch );
|
||||
int RankForContents( int contents );
|
||||
|
||||
#define check_angles( x ) ( (int)x == 90 || (int)x == 180 || (int)x == 270 || (int)x == -90 || (int)x == -180 || (int)x == -270 )
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ typedef enum
|
||||
force_exactfile, // File on client must exactly match server's file
|
||||
force_model_samebounds, // For model files only, the geometry must fit in the same bbox
|
||||
force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox
|
||||
force_model_specifybounds_if_avail,
|
||||
} FORCE_TYPE;
|
||||
|
||||
// Returned by TraceLine
|
||||
@@ -125,7 +126,7 @@ typedef struct enginefuncs_s
|
||||
void (*pfnAngleVectors)( const float *rgflVector, float *forward, float *right, float *up );
|
||||
edict_t* (*pfnCreateEntity)( void );
|
||||
void (*pfnRemoveEntity)( edict_t* e );
|
||||
edict_t* (*pfnCreateNamedEntity)( string_t className );
|
||||
edict_t* (*pfnCreateNamedEntity)( int className );
|
||||
void (*pfnMakeStatic)( edict_t *ent );
|
||||
int (*pfnEntIsOnFloor)( edict_t *e );
|
||||
int (*pfnDropToFloor)( edict_t* e );
|
||||
@@ -168,8 +169,8 @@ typedef struct enginefuncs_s
|
||||
void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, long cb );
|
||||
void* (*pfnPvEntPrivateData)( edict_t *pEdict );
|
||||
void (*pfnFreeEntPrivateData)( edict_t *pEdict );
|
||||
const char *(*pfnSzFromIndex)( string_t iString );
|
||||
string_t (*pfnAllocString)( const char *szValue );
|
||||
const char *(*pfnSzFromIndex)( int iString );
|
||||
int (*pfnAllocString)( const char *szValue );
|
||||
struct entvars_s *(*pfnGetVarsOfEnt)( edict_t *pEdict );
|
||||
edict_t* (*pfnPEntityOfEntOffset)( int iEntOffset );
|
||||
int (*pfnEntOffsetOfPEntity)( const edict_t *pEdict );
|
||||
|
||||
@@ -222,6 +222,10 @@ typedef struct ui_extendedfuncs_s {
|
||||
// new mods info
|
||||
gameinfo2_t *(*pfnGetGameInfo)( int gi_version ); // might return NULL if gi_version is unsupported
|
||||
gameinfo2_t *(*pfnGetModInfo)( int gi_version, int mod_index ); // continiously call it until it returns null
|
||||
|
||||
// returns 1 if cvar has read-only flag
|
||||
// or -1 if cvar not found
|
||||
int (*pfnIsCvarReadOnly)( const char *name );
|
||||
} ui_extendedfuncs_t;
|
||||
|
||||
// deprecated export from old engine
|
||||
|
||||
@@ -26,47 +26,56 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined __ANDROID__ && !defined XASH_64BIT
|
||||
#include "build.h"
|
||||
#if XASH_ANDROID && !XASH_64BIT
|
||||
#include <string.h>
|
||||
#include <android/log.h>
|
||||
#include "linker.h"
|
||||
|
||||
static Elf_Sym* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name) {
|
||||
Elf_Sym* symtab = si->symtab;
|
||||
const char* strtab = si->strtab;
|
||||
static Elf_Sym *soinfo_elf_lookup( const soinfo *si, unsigned hash, const char *name )
|
||||
{
|
||||
const Elf_Sym *symtab = si->symtab;
|
||||
const char *strtab = si->strtab;
|
||||
unsigned n;
|
||||
|
||||
if( si->nbucket == 0 )
|
||||
return NULL;
|
||||
|
||||
for (unsigned n = si->bucket[hash % si->nbucket]; n != 0; n = si->chain[n]) {
|
||||
Elf_Sym* s = symtab + n;
|
||||
if (strcmp(strtab + s->st_name, name)) continue;
|
||||
for( n = si->bucket[hash % si->nbucket]; n != 0; n = si->chain[n] )
|
||||
{
|
||||
const Elf_Sym *s = symtab + n;
|
||||
|
||||
/* only concern ourselves with global and weak symbol definitions */
|
||||
switch (ELF_ST_BIND(s->st_info)) {
|
||||
case STB_GLOBAL:
|
||||
case STB_WEAK:
|
||||
if (s->st_shndx == SHN_UNDEF) {
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
if( strcmp( strtab + s->st_name, name ))
|
||||
continue;
|
||||
|
||||
return NULL;
|
||||
/* only concern ourselves with global and weak symbol definitions */
|
||||
switch( ELF_ST_BIND( s->st_info ))
|
||||
{
|
||||
case STB_GLOBAL:
|
||||
case STB_WEAK:
|
||||
if( s->st_shndx == SHN_UNDEF )
|
||||
continue;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static unsigned elfhash(const char* _name) {
|
||||
const unsigned char* name = (const unsigned char*) _name;
|
||||
unsigned h = 0, g;
|
||||
static unsigned elfhash( const unsigned char *name )
|
||||
{
|
||||
unsigned h = 0;
|
||||
|
||||
while(*name) {
|
||||
h = (h << 4) + *name++;
|
||||
g = h & 0xf0000000;
|
||||
h ^= g;
|
||||
h ^= g >> 24;
|
||||
}
|
||||
return h;
|
||||
while( *name )
|
||||
{
|
||||
unsigned g;
|
||||
|
||||
h = ( h << 4 ) + *name++;
|
||||
g = h & 0xf0000000;
|
||||
h ^= g;
|
||||
h ^= g >> 24;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/* This is used by dlsym(3). It performs symbol lookup only within the
|
||||
@@ -78,21 +87,20 @@ static unsigned elfhash(const char* _name) {
|
||||
Binary Interface) where in Chapter 5 it discuss resolving "Shared
|
||||
Object Dependencies" in breadth first search order.
|
||||
*/
|
||||
static Elf_Sym* dlsym_handle_lookup(soinfo* si, const char* name) {
|
||||
return soinfo_elf_lookup(si, elfhash(name), name);
|
||||
static Elf_Sym *dlsym_handle_lookup( const soinfo *si, const char *name )
|
||||
{
|
||||
return soinfo_elf_lookup( si, elfhash((const unsigned char *)name ), name );
|
||||
}
|
||||
|
||||
extern "C" void* dlsym_weak(void* handle, const char* symbol) {
|
||||
extern "C" void *dlsym_weak( void *handle, const char *symbol )
|
||||
{
|
||||
soinfo *found = (soinfo *)handle;
|
||||
Elf_Sym *sym = dlsym_handle_lookup( found, symbol );
|
||||
|
||||
soinfo* found = NULL;
|
||||
Elf_Sym* sym = NULL;
|
||||
found = reinterpret_cast<soinfo*>(handle);
|
||||
sym = dlsym_handle_lookup(found, symbol);
|
||||
if( sym != NULL )
|
||||
return (void *)( sym->st_value + found->base /*load_bias*/ );
|
||||
|
||||
if (sym != NULL) {
|
||||
return reinterpret_cast<void*>(sym->st_value + found->base/*load_bias*/);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_ERROR, "dlsym-weak", "Failed when looking up %s\n", symbol);
|
||||
return NULL;
|
||||
__android_log_print( ANDROID_LOG_ERROR, "dlsym-weak", "Failed when looking up %s\n", symbol );
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#endif // XASH_ANDROID && !XASH_64BIT
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#ifndef _LINKER_H_
|
||||
#define _LINKER_H_
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
@@ -39,163 +38,153 @@
|
||||
|
||||
// a1ba: we don't really need custom linker on Android 64, because
|
||||
// it's only intended to workaround bug which persist on Android < 4.4
|
||||
#define Elf_Ehdr Elf32_Ehdr
|
||||
#define Elf_Phdr Elf32_Phdr
|
||||
#define Elf_Shdr Elf32_Shdr
|
||||
#define Elf_Sym Elf32_Sym
|
||||
#define Elf_Rel Elf32_Rel
|
||||
#define Elf_RelA Elf32_Rela
|
||||
#define Elf_Dyn Elf32_Dyn
|
||||
#define Elf_Half Elf32_Half
|
||||
#define Elf_Word Elf32_Word
|
||||
#define Elf_Sword Elf32_Sword
|
||||
#define Elf_Addr Elf32_Addr
|
||||
#define Elf_Off Elf32_Off
|
||||
#define Elf_Nhdr Elf32_Nhdr
|
||||
#define Elf_Note Elf32_Note
|
||||
#define Elf_Ehdr Elf32_Ehdr
|
||||
#define Elf_Phdr Elf32_Phdr
|
||||
#define Elf_Shdr Elf32_Shdr
|
||||
#define Elf_Sym Elf32_Sym
|
||||
#define Elf_Rel Elf32_Rel
|
||||
#define Elf_RelA Elf32_Rela
|
||||
#define Elf_Dyn Elf32_Dyn
|
||||
#define Elf_Half Elf32_Half
|
||||
#define Elf_Word Elf32_Word
|
||||
#define Elf_Sword Elf32_Sword
|
||||
#define Elf_Addr Elf32_Addr
|
||||
#define Elf_Off Elf32_Off
|
||||
#define Elf_Nhdr Elf32_Nhdr
|
||||
#define Elf_Note Elf32_Note
|
||||
|
||||
// Returns the address of the page containing address 'x'.
|
||||
#define PAGE_START(x) ((x) & PAGE_MASK)
|
||||
#define PAGE_START( x ) (( x )&PAGE_MASK )
|
||||
|
||||
// Returns the offset of address 'x' in its page.
|
||||
#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
|
||||
#define PAGE_OFFSET( x ) (( x ) & ~PAGE_MASK )
|
||||
|
||||
// Returns the address of the next page after address 'x', unless 'x' is
|
||||
// itself at the start of a page.
|
||||
#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
|
||||
#define PAGE_END( x ) PAGE_START(( x ) + ( PAGE_SIZE - 1 ))
|
||||
|
||||
// Magic shared structures that GDB knows about.
|
||||
|
||||
struct link_map_t {
|
||||
uintptr_t l_addr;
|
||||
char* l_name;
|
||||
uintptr_t l_ld;
|
||||
link_map_t* l_next;
|
||||
link_map_t* l_prev;
|
||||
uintptr_t l_addr;
|
||||
char *l_name;
|
||||
uintptr_t l_ld;
|
||||
link_map_t *l_next;
|
||||
link_map_t *l_prev;
|
||||
};
|
||||
|
||||
// Values for r_debug->state
|
||||
enum {
|
||||
RT_CONSISTENT,
|
||||
RT_ADD,
|
||||
RT_DELETE
|
||||
RT_CONSISTENT,
|
||||
RT_ADD,
|
||||
RT_DELETE
|
||||
};
|
||||
#if 0
|
||||
struct r_debug {
|
||||
int32_t r_version;
|
||||
link_map_t* r_map;
|
||||
void (*r_brk)(void);
|
||||
int32_t r_state;
|
||||
uintptr_t r_ldbase;
|
||||
};
|
||||
#endif
|
||||
#define FLAG_LINKED 0x00000001
|
||||
#define FLAG_EXE 0x00000004 // The main executable
|
||||
#define FLAG_LINKER 0x00000010 // The linker itself
|
||||
#define FLAG_LINKED 0x00000001
|
||||
#define FLAG_EXE 0x00000004 // The main executable
|
||||
#define FLAG_LINKER 0x00000010 // The linker itself
|
||||
|
||||
#define SOINFO_NAME_LEN 128
|
||||
|
||||
typedef void (*linker_function_t)();
|
||||
|
||||
// Android uses REL for 32-bit but only uses RELA for 64-bit.
|
||||
#if defined(__LP64__)
|
||||
#if defined( __LP64__ )
|
||||
#define USE_RELA 1
|
||||
#endif
|
||||
|
||||
struct soinfo {
|
||||
public:
|
||||
char name[SOINFO_NAME_LEN];
|
||||
const Elf_Phdr* phdr;
|
||||
size_t phnum;
|
||||
Elf_Addr entry;
|
||||
Elf_Addr base;
|
||||
unsigned size;
|
||||
public:
|
||||
char name[SOINFO_NAME_LEN];
|
||||
const Elf_Phdr *phdr;
|
||||
size_t phnum;
|
||||
Elf_Addr entry;
|
||||
Elf_Addr base;
|
||||
unsigned size;
|
||||
|
||||
#ifndef __LP64__
|
||||
uint32_t unused1; // DO NOT USE, maintained for compatibility.
|
||||
uint32_t unused1; // DO NOT USE, maintained for compatibility.
|
||||
#endif
|
||||
|
||||
Elf_Dyn* dynamic;
|
||||
Elf_Dyn *dynamic;
|
||||
|
||||
#ifndef __LP64__
|
||||
uint32_t unused2; // DO NOT USE, maintained for compatibility
|
||||
uint32_t unused3; // DO NOT USE, maintained for compatibility
|
||||
uint32_t unused2; // DO NOT USE, maintained for compatibility
|
||||
uint32_t unused3; // DO NOT USE, maintained for compatibility
|
||||
#endif
|
||||
|
||||
soinfo* next;
|
||||
unsigned flags;
|
||||
soinfo *next;
|
||||
unsigned flags;
|
||||
|
||||
const char* strtab;
|
||||
Elf_Sym* symtab;
|
||||
const char *strtab;
|
||||
Elf_Sym *symtab;
|
||||
|
||||
size_t nbucket;
|
||||
size_t nchain;
|
||||
unsigned* bucket;
|
||||
unsigned* chain;
|
||||
size_t nbucket;
|
||||
size_t nchain;
|
||||
unsigned *bucket;
|
||||
unsigned *chain;
|
||||
|
||||
#if !defined(__LP64__)
|
||||
// This is only used by 32-bit MIPS, but needs to be here for
|
||||
// all 32-bit architectures to preserve binary compatibility.
|
||||
unsigned* plt_got;
|
||||
#if !defined( __LP64__ )
|
||||
// This is only used by 32-bit MIPS, but needs to be here for
|
||||
// all 32-bit architectures to preserve binary compatibility.
|
||||
unsigned *plt_got;
|
||||
#endif
|
||||
|
||||
#if defined(USE_RELA)
|
||||
Elf_RelA* plt_rela;
|
||||
size_t plt_rela_count;
|
||||
#if defined( USE_RELA )
|
||||
Elf_RelA *plt_rela;
|
||||
size_t plt_rela_count;
|
||||
|
||||
Elf_RelA* rela;
|
||||
size_t rela_count;
|
||||
Elf_RelA *rela;
|
||||
size_t rela_count;
|
||||
#else
|
||||
Elf_Rel* plt_rel;
|
||||
size_t plt_rel_count;
|
||||
Elf_Rel *plt_rel;
|
||||
size_t plt_rel_count;
|
||||
|
||||
Elf_Rel* rel;
|
||||
size_t rel_count;
|
||||
Elf_Rel *rel;
|
||||
size_t rel_count;
|
||||
#endif
|
||||
|
||||
linker_function_t* preinit_array;
|
||||
size_t preinit_array_count;
|
||||
linker_function_t *preinit_array;
|
||||
size_t preinit_array_count;
|
||||
|
||||
linker_function_t* init_array;
|
||||
size_t init_array_count;
|
||||
linker_function_t* fini_array;
|
||||
size_t fini_array_count;
|
||||
linker_function_t *init_array;
|
||||
size_t init_array_count;
|
||||
linker_function_t *fini_array;
|
||||
size_t fini_array_count;
|
||||
|
||||
linker_function_t init_func;
|
||||
linker_function_t fini_func;
|
||||
linker_function_t init_func;
|
||||
linker_function_t fini_func;
|
||||
|
||||
#if defined(__arm__)
|
||||
// ARM EABI section used for stack unwinding.
|
||||
unsigned* ARM_exidx;
|
||||
size_t ARM_exidx_count;
|
||||
#elif defined(__mips__)
|
||||
unsigned mips_symtabno;
|
||||
unsigned mips_local_gotno;
|
||||
unsigned mips_gotsym;
|
||||
#if defined( __arm__ )
|
||||
// ARM EABI section used for stack unwinding.
|
||||
unsigned *ARM_exidx;
|
||||
size_t ARM_exidx_count;
|
||||
#elif defined( __mips__ )
|
||||
unsigned mips_symtabno;
|
||||
unsigned mips_local_gotno;
|
||||
unsigned mips_gotsym;
|
||||
#endif
|
||||
|
||||
size_t ref_count;
|
||||
link_map_t link_map;
|
||||
size_t ref_count;
|
||||
link_map_t link_map;
|
||||
|
||||
bool constructors_called;
|
||||
bool constructors_called;
|
||||
|
||||
// When you read a virtual address from the ELF file, add this
|
||||
// value to get the corresponding address in the process' address space.
|
||||
Elf_Addr load_bias;
|
||||
// When you read a virtual address from the ELF file, add this
|
||||
// value to get the corresponding address in the process' address space.
|
||||
Elf_Addr load_bias;
|
||||
|
||||
#if !defined(__LP64__)
|
||||
bool has_text_relocations;
|
||||
#if !defined( __LP64__ )
|
||||
bool has_text_relocations;
|
||||
#endif
|
||||
bool has_DT_SYMBOLIC;
|
||||
bool has_DT_SYMBOLIC;
|
||||
|
||||
void CallConstructors();
|
||||
void CallDestructors();
|
||||
void CallPreInitConstructors();
|
||||
void CallConstructors();
|
||||
void CallDestructors();
|
||||
void CallPreInitConstructors();
|
||||
|
||||
private:
|
||||
void CallArray(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
|
||||
void CallFunction(const char* function_name, linker_function_t function);
|
||||
private:
|
||||
void CallArray( const char *array_name, linker_function_t *functions, size_t count, bool reverse );
|
||||
void CallFunction( const char *function_name, linker_function_t function );
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -51,6 +51,7 @@ void IOS_LaunchDialog( void );
|
||||
|
||||
#if XASH_POSIX
|
||||
void Posix_Daemonize( void );
|
||||
void Posix_SetupSigtermHandling( void );
|
||||
#endif
|
||||
|
||||
#if XASH_SDL
|
||||
@@ -156,6 +157,13 @@ static inline qboolean Sys_DebuggerPresent( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void Platform_SetupSigtermHandling( void )
|
||||
{
|
||||
#if XASH_POSIX
|
||||
Posix_SetupSigtermHandling( );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ GNU General Public License for more details.
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "platform/platform.h"
|
||||
#include "menu_int.h"
|
||||
|
||||
@@ -145,6 +146,21 @@ void Posix_Daemonize( void )
|
||||
|
||||
}
|
||||
|
||||
static void Posix_SigtermCallback( int signal )
|
||||
{
|
||||
Sys_Quit();
|
||||
}
|
||||
|
||||
void Posix_SetupSigtermHandling( void )
|
||||
{
|
||||
#if !XASH_PSVITA
|
||||
struct sigaction act = { 0 };
|
||||
act.sa_handler = Posix_SigtermCallback;
|
||||
act.sa_flags = 0;
|
||||
sigaction( SIGTERM, &act, NULL );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if XASH_TIMER == TIMER_POSIX
|
||||
double Platform_DoubleTime( void )
|
||||
{
|
||||
|
||||
@@ -18,8 +18,10 @@ GNU General Public License for more details.
|
||||
#define NET_PSVITA_H
|
||||
|
||||
#include <vitasdk.h>
|
||||
#include "platform/posix/net.h"
|
||||
|
||||
/* we're missing IPv6 support; define some trash */
|
||||
#define XASH_NO_IPV6_RESOLVE 1
|
||||
|
||||
#ifndef IN6_IS_ADDR_V4MAPPED
|
||||
#define IN6_IS_ADDR_V4MAPPED( p ) ( 0 )
|
||||
|
||||
@@ -674,7 +674,7 @@ static void VID_SetWindowIcon( SDL_Window *hWnd )
|
||||
if( ico && WIN_SetWindowIcon( ico ))
|
||||
return;
|
||||
}
|
||||
#endif // _WIN32 && !XASH_64BIT
|
||||
#endif // XASH_WIN32
|
||||
|
||||
Q_strncpy( iconpath, GI->iconpath, sizeof( iconpath ));
|
||||
COM_ReplaceExtension( iconpath, ".tga", sizeof( iconpath ));
|
||||
|
||||
@@ -85,8 +85,8 @@ typedef struct entvars_s
|
||||
int modelindex;
|
||||
|
||||
string_t model;
|
||||
string_t viewmodel; // player's viewmodel
|
||||
string_t weaponmodel; // what other players see
|
||||
int viewmodel; // player's viewmodel
|
||||
int weaponmodel; // what other players see
|
||||
|
||||
vec3_t absmin; // BB max translated to world coord
|
||||
vec3_t absmax; // BB max translated to world coord
|
||||
@@ -144,7 +144,7 @@ typedef struct entvars_s
|
||||
int flags;
|
||||
|
||||
int colormap; // lowbyte topcolor, highbyte bottomcolor
|
||||
string_t team;
|
||||
int team;
|
||||
|
||||
float max_health;
|
||||
float teleport_time;
|
||||
|
||||
@@ -61,8 +61,6 @@ GNU General Public License for more details.
|
||||
#define FCONTEXT_CORE_PROFILE BIT( 0 )
|
||||
#define FCONTEXT_DEBUG_ARB BIT( 1 )
|
||||
|
||||
#define FCVAR_READ_ONLY (1<<17) // cannot be set by user at all, and can't be requested by CvarGetPointer from game dlls
|
||||
|
||||
// screenshot types
|
||||
#define VID_SCREENSHOT 0
|
||||
#define VID_LEVELSHOT 1
|
||||
@@ -389,10 +387,13 @@ typedef struct ref_api_s
|
||||
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
|
||||
|
||||
// memory
|
||||
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
|
||||
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline )
|
||||
WARN_UNUSED_RESULT;
|
||||
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
|
||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
|
||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
ALLOC_CHECK( 2 ) WARN_UNUSED_RESULT;
|
||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
ALLOC_CHECK( 3 ) WARN_UNUSED_RESULT;
|
||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||
|
||||
// library management
|
||||
|
||||
@@ -683,6 +683,6 @@ int SV_LightForEntity( edict_t *pEdict );
|
||||
//
|
||||
// sv_query.c
|
||||
//
|
||||
qboolean SV_SourceQuery_HandleConnnectionlessPacket( const char *c, netadr_t from );
|
||||
void SV_SourceQuery_HandleConnnectionlessPacket( const char *c, netadr_t from );
|
||||
|
||||
#endif//SERVER_H
|
||||
|
||||
@@ -19,7 +19,7 @@ GNU General Public License for more details.
|
||||
#include "net_encode.h"
|
||||
#include "net_api.h"
|
||||
|
||||
const char *clc_strings[clc_lastmsg+1] =
|
||||
const char *const clc_strings[clc_lastmsg+1] =
|
||||
{
|
||||
"clc_bad",
|
||||
"clc_nop",
|
||||
@@ -27,11 +27,12 @@ const char *clc_strings[clc_lastmsg+1] =
|
||||
"clc_stringcmd",
|
||||
"clc_delta",
|
||||
"clc_resourcelist",
|
||||
"clc_unused6",
|
||||
"clc_legacy_userinfo",
|
||||
"clc_fileconsistency",
|
||||
"clc_voicedata",
|
||||
"clc_cvarvalue",
|
||||
"clc_cvarvalue2",
|
||||
"clc_cvarvalue/clc_goldsrc_hltv",
|
||||
"clc_cvarvalue2/clc_goldsrc_requestcvarvalue",
|
||||
"clc_goldsrc_requestcvarvalue2",
|
||||
};
|
||||
|
||||
typedef struct ucmd_s
|
||||
@@ -130,7 +131,7 @@ static void SV_GetChallenge( netadr_t from )
|
||||
}
|
||||
|
||||
// send it back
|
||||
Netchan_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, "challenge %i", svs.challenges[i].challenge );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, S2C_CHALLENGE" %i", svs.challenges[i].challenge );
|
||||
}
|
||||
|
||||
static int SV_GetFragmentSize( void *pcl, fragsize_t mode )
|
||||
@@ -193,9 +194,9 @@ void SV_RejectConnection( netadr_t from, const char *fmt, ... )
|
||||
va_end( argptr );
|
||||
|
||||
Con_Reportf( "%s connection refused. Reason: %s\n", NET_AdrToString( from ), text );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\n^1Server was reject the connection:^7 %s", text );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "print\n^1Server was reject the connection:^7 %s", text );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "disconnect\n" );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, S2C_ERRORMSG"\n^1Server was reject the connection:^7 %s", text );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, A2C_PRINT"\n^1Server was reject the connection:^7 %s", text );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, S2C_REJECT"\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -444,7 +445,7 @@ static void SV_ConnectClient( netadr_t from )
|
||||
newcl->listeners = -1;
|
||||
|
||||
// initailize netchan
|
||||
Netchan_Setup( NS_SERVER, &newcl->netchan, from, qport, newcl, SV_GetFragmentSize );
|
||||
Netchan_Setup( NS_SERVER, &newcl->netchan, from, qport, newcl, SV_GetFragmentSize, 0 );
|
||||
MSG_Init( &newcl->datagram, "Datagram", newcl->datagram_buf, sizeof( newcl->datagram_buf )); // datagram buf
|
||||
|
||||
Q_strncpy( newcl->hashedcdkey, Info_ValueForKey( protinfo, "uuid" ), 32 );
|
||||
@@ -455,7 +456,7 @@ static void SV_ConnectClient( netadr_t from )
|
||||
Info_SetValueForKeyf( protinfo, "ext", sizeof( protinfo ), "%d", newcl->extensions );
|
||||
|
||||
// send the connect packet to the client
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "client_connect %s", protinfo );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, S2C_CONNECTION" %s", protinfo );
|
||||
|
||||
newcl->upstate = us_inactive;
|
||||
newcl->connection_started = host.realtime;
|
||||
@@ -603,7 +604,7 @@ void SV_KickPlayer( sv_client_t *cl, const char *fmt, ... )
|
||||
SV_BroadcastPrintf( cl, "%s was kicked with message: \"%s\"\n", cl->name, buf );
|
||||
SV_ClientPrintf( cl, "You were kicked from the game with message: \"%s\"\n", buf );
|
||||
if( cl->useragent[0] )
|
||||
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, "errormsg\nKicked with message:\n%s\n", buf );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, S2C_ERRORMSG"\nKicked with message:\n%s\n", buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -611,7 +612,7 @@ void SV_KickPlayer( sv_client_t *cl, const char *fmt, ... )
|
||||
SV_BroadcastPrintf( cl, "%s was kicked\n", cl->name );
|
||||
SV_ClientPrintf( cl, "You were kicked from the game\n" );
|
||||
if( cl->useragent[0] )
|
||||
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, "errormsg\nYou were kicked from the game\n" );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, cl->netchan.remote_address, S2C_ERRORMSG"\nYou were kicked from the game\n" );
|
||||
}
|
||||
|
||||
SV_DropClient( cl, false );
|
||||
@@ -713,20 +714,18 @@ static void SV_BeginRedirect( host_redirect_t *rd, netadr_t adr, rdtype_t target
|
||||
|
||||
static void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
||||
{
|
||||
if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT ))
|
||||
return;
|
||||
|
||||
switch( dest )
|
||||
{
|
||||
case RD_PACKET:
|
||||
Netchan_OutOfBandPrint( NS_SERVER, adr, "print\n%s", buf );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, adr, A2C_PRINT"\n%s", buf );
|
||||
break;
|
||||
case RD_CLIENT:
|
||||
if( !sv.current_client ) return; // client not set
|
||||
if( !sv.current_client || !FBitSet( sv.current_client->flags, FCL_FAKECLIENT ))
|
||||
return; // client not set
|
||||
MSG_BeginServerCmd( &sv.current_client->netchan.message, svc_print );
|
||||
MSG_WriteString( &sv.current_client->netchan.message, buf );
|
||||
break;
|
||||
case RD_NONE:
|
||||
default:
|
||||
Con_Printf( S_ERROR "%s: %s: invalid destination\n", __func__, NET_AdrToString( adr ));
|
||||
break;
|
||||
}
|
||||
@@ -952,14 +951,30 @@ static void SV_Info( netadr_t from, int protocolVersion )
|
||||
if( remaining < 0 )
|
||||
{
|
||||
// should never happen?
|
||||
Con_Printf( S_ERROR "SV_Info: infostring overflow!\n" );
|
||||
Con_Printf( S_ERROR "%s: infostring overflow!\n", __func__ );
|
||||
return;
|
||||
}
|
||||
Q_strncpy( temp, hostname.string, remaining );
|
||||
Info_SetValueForKey( s, "host", temp, sizeof( s ));
|
||||
}
|
||||
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "info\n%s", s );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, A2A_INFO"\n%s", s );
|
||||
}
|
||||
|
||||
static void SV_ConnectNatClient( netadr_t from )
|
||||
{
|
||||
netadr_t to;
|
||||
|
||||
if( !sv_nat.value || !NET_IsMasterAdr( from ))
|
||||
return;
|
||||
|
||||
if( !NET_StringToAdr( Cmd_Argv( 1 ), &to ))
|
||||
return;
|
||||
|
||||
if( NET_IsReservedAdr( to ))
|
||||
return;
|
||||
|
||||
SV_Info( to, PROTOCOL_VERSION );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -993,7 +1008,7 @@ static void SV_BuildNetAnswer( netadr_t from )
|
||||
{
|
||||
// send error unsupported protocol
|
||||
Info_SetValueForKey( string, "neterror", "protocol", sizeof( string ));
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "netinfo %i %i %s\n", context, type, string );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, A2A_NETINFO" %i %i %s\n", context, type, string );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1064,19 +1079,7 @@ static void SV_BuildNetAnswer( netadr_t from )
|
||||
break;
|
||||
}
|
||||
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "netinfo %i %i %s\n", context, type, string );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SV_Ping
|
||||
|
||||
Just responds with an acknowledgement
|
||||
================
|
||||
*/
|
||||
static void SV_Ping( netadr_t from )
|
||||
{
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "ack" );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, A2A_NETINFO" %i %i %s\n", context, type, string );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1104,10 +1107,7 @@ Redirect all printfs
|
||||
*/
|
||||
void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
|
||||
{
|
||||
static char outputbuf[2048];
|
||||
const char *adr;
|
||||
char remaining[1024];
|
||||
char *p = remaining;
|
||||
int i;
|
||||
|
||||
if( !rcon_enable.value || !COM_CheckStringEmpty( rcon_password.string ))
|
||||
@@ -1120,7 +1120,9 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
|
||||
|
||||
if( Rcon_Validate( ))
|
||||
{
|
||||
SV_BeginRedirect( &host.rd, from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );
|
||||
static char outputbuf[2048];
|
||||
char remaining[1024];
|
||||
char *p = remaining;
|
||||
|
||||
remaining[0] = 0;
|
||||
for( i = 2; i < Cmd_Argc(); i++ )
|
||||
@@ -1129,8 +1131,9 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
|
||||
p += Q_strncpy( p, Cmd_Argv( i ), sizeof( remaining ) - ( p - remaining ));
|
||||
p += Q_strncpy( p, "\" ", sizeof( remaining ) - ( p - remaining ));
|
||||
}
|
||||
Cmd_ExecuteString( remaining );
|
||||
|
||||
SV_BeginRedirect( &host.rd, from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );
|
||||
Cmd_ExecuteString( remaining );
|
||||
SV_EndRedirect( &host.rd );
|
||||
}
|
||||
else Con_Printf( S_ERROR "Bad rcon_password.\n" );
|
||||
@@ -1342,9 +1345,8 @@ otherwise see code SV_UpdateMovevars()
|
||||
*/
|
||||
void SV_FullUpdateMovevars( sv_client_t *cl, sizebuf_t *msg )
|
||||
{
|
||||
movevars_t nullmovevars;
|
||||
const movevars_t nullmovevars = { 0 };
|
||||
|
||||
memset( &nullmovevars, 0, sizeof( nullmovevars ));
|
||||
MSG_WriteDeltaMovevars( msg, &nullmovevars, &svgame.movevars );
|
||||
}
|
||||
|
||||
@@ -1992,7 +1994,7 @@ static qboolean SV_Noclip_f( sv_client_t *cl )
|
||||
{
|
||||
edict_t *pEntity = cl->edict;
|
||||
|
||||
if( !Cvar_VariableInteger( "sv_cheats" ) || sv.background )
|
||||
if( sv.background || !Cvar_VariableInteger( "sv_cheats" ))
|
||||
return true;
|
||||
|
||||
if( pEntity->v.movetype != MOVETYPE_NOCLIP )
|
||||
@@ -2018,7 +2020,7 @@ static qboolean SV_Godmode_f( sv_client_t *cl )
|
||||
{
|
||||
edict_t *pEntity = cl->edict;
|
||||
|
||||
if( !Cvar_VariableInteger( "sv_cheats" ) || sv.background )
|
||||
if( sv.background || !Cvar_VariableInteger( "sv_cheats" ))
|
||||
return true;
|
||||
|
||||
pEntity->v.flags = pEntity->v.flags ^ FL_GODMODE;
|
||||
@@ -2039,7 +2041,7 @@ static qboolean SV_Notarget_f( sv_client_t *cl )
|
||||
{
|
||||
edict_t *pEntity = cl->edict;
|
||||
|
||||
if( !Cvar_VariableInteger( "sv_cheats" ) || sv.background )
|
||||
if( sv.background || !Cvar_VariableInteger( "sv_cheats" ))
|
||||
return true;
|
||||
|
||||
pEntity->v.flags = pEntity->v.flags ^ FL_NOTARGET;
|
||||
@@ -3036,7 +3038,7 @@ static qboolean SV_EntGetVars_f( sv_client_t *cl )
|
||||
return true;
|
||||
}
|
||||
|
||||
ucmd_t ucmds[] =
|
||||
static const ucmd_t ucmds[] =
|
||||
{
|
||||
{ "new", SV_New_f },
|
||||
{ "god", SV_Godmode_f },
|
||||
@@ -3056,7 +3058,7 @@ ucmd_t ucmds[] =
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
ucmd_t enttoolscmds[] =
|
||||
static const ucmd_t enttoolscmds[] =
|
||||
{
|
||||
{ "ent_list", SV_EntList_f },
|
||||
{ "ent_info", SV_EntInfo_f },
|
||||
@@ -3073,7 +3075,7 @@ SV_ExecuteUserCommand
|
||||
*/
|
||||
static void SV_ExecuteClientCommand( sv_client_t *cl, const char *s )
|
||||
{
|
||||
ucmd_t *u;
|
||||
const ucmd_t *u;
|
||||
|
||||
Cmd_TokenizeString( s );
|
||||
|
||||
@@ -3148,17 +3150,14 @@ connectionless packets.
|
||||
*/
|
||||
void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
{
|
||||
char *args;
|
||||
const char *pcmd;
|
||||
char buf[MAX_SYSPATH];
|
||||
int len = sizeof( buf );
|
||||
const char *pcmd, *args;
|
||||
|
||||
// prevent flooding from banned address
|
||||
if( SV_CheckIP( &from ) )
|
||||
if( SV_CheckIP( &from ))
|
||||
return;
|
||||
|
||||
MSG_Clear( msg );
|
||||
MSG_ReadLong( msg );// skip the -1 marker
|
||||
MSG_SeekToBit( msg, sizeof( uint32_t ) << 3, SEEK_CUR ); // skip the -1 marker
|
||||
|
||||
args = MSG_ReadStringLine( msg );
|
||||
Cmd_TokenizeString( args );
|
||||
@@ -3168,29 +3167,79 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
if( sv_log_outofband.value )
|
||||
Con_Reportf( "%s: %s : %s\n", __func__, NET_AdrToString( from ), pcmd );
|
||||
|
||||
if( !Q_strcmp( pcmd, "ping" )) SV_Ping( from );
|
||||
else if( !Q_strcmp( pcmd, "ack" )) SV_Ack( from );
|
||||
else if( !Q_strcmp( pcmd, "info" )) SV_Info( from, Q_atoi( Cmd_Argv( 1 )));
|
||||
else if( !Q_strcmp( pcmd, "bandwidth" )) SV_TestBandWidth( from );
|
||||
else if( !Q_strcmp( pcmd, "getchallenge" )) SV_GetChallenge( from );
|
||||
else if( !Q_strcmp( pcmd, "connect" )) SV_ConnectClient( from );
|
||||
else if( !Q_strcmp( pcmd, "rcon" )) SV_RemoteCommand( from, msg );
|
||||
else if( !Q_strcmp( pcmd, "netinfo" )) SV_BuildNetAnswer( from );
|
||||
else if( !Q_strcmp( pcmd, "s" )) SV_AddToMaster( from, msg );
|
||||
else if( !Q_strcmp( pcmd, "i" )) NET_SendPacket( NS_SERVER, 5, "\xFF\xFF\xFF\xFFj", from ); // A2A_PING
|
||||
else if( SV_SourceQuery_HandleConnnectionlessPacket( pcmd, from )) { } // function handles replies
|
||||
else if( !Q_strcmp( pcmd, "c" ) && sv_nat.value && NET_IsMasterAdr( from ))
|
||||
if( !svs.initialized )
|
||||
{
|
||||
netadr_t to;
|
||||
if( NET_StringToAdr( Cmd_Argv( 1 ), &to ) && !NET_IsReservedAdr( to ))
|
||||
SV_Info( to, PROTOCOL_VERSION );
|
||||
// only process rcon if server not initialized
|
||||
if( !Q_strcmp( pcmd, C2S_RCON ))
|
||||
SV_RemoteCommand( net_from, &net_message );
|
||||
|
||||
return;
|
||||
}
|
||||
else if( svgame.dllFuncs.pfnConnectionlessPacket( &from, args, buf, &len ))
|
||||
|
||||
if( !Q_strcmp( pcmd, A2S_GOLDSRC_INFO ) || pcmd[0] == A2S_GOLDSRC_PLAYERS || pcmd[0] == A2S_GOLDSRC_RULES )
|
||||
{
|
||||
// user out of band message (must be handled in CL_ConnectionlessPacket)
|
||||
if( len > 0 ) Netchan_OutOfBand( NS_SERVER, from, len, (byte*)buf );
|
||||
SV_SourceQuery_HandleConnnectionlessPacket( pcmd, from );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, A2A_NETINFO ))
|
||||
{
|
||||
SV_BuildNetAnswer( from );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, A2A_INFO ))
|
||||
{
|
||||
SV_Info( from, Q_atoi( Cmd_Argv( 1 )));
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, M2S_CHALLENGE ))
|
||||
{
|
||||
SV_AddToMaster( from, msg );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, M2S_NAT_CONNECT ))
|
||||
{
|
||||
SV_ConnectNatClient( from );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, C2S_BANDWIDTHTEST ))
|
||||
{
|
||||
SV_TestBandWidth( from );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, C2S_GETCHALLENGE ))
|
||||
{
|
||||
SV_GetChallenge( from );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, C2S_CONNECT ))
|
||||
{
|
||||
SV_ConnectClient( from );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, A2A_PING ))
|
||||
{
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, A2A_ACK );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, A2A_GOLDSRC_PING ))
|
||||
{
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, A2A_GOLDSRC_ACK );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, C2S_RCON ))
|
||||
{
|
||||
SV_RemoteCommand( from, msg );
|
||||
}
|
||||
else if( !Q_strcmp( pcmd, A2A_ACK ) || !Q_strcmp( pcmd, A2A_GOLDSRC_ACK ))
|
||||
{
|
||||
SV_Ack( from );
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[MAX_SYSPATH];
|
||||
int len = sizeof( buf );
|
||||
|
||||
if( svgame.dllFuncs.pfnConnectionlessPacket( &from, args, buf, &len ))
|
||||
{
|
||||
// user out of band message (must be handled in CL_ConnectionlessPacket)
|
||||
if( len > 0 )
|
||||
Netchan_OutOfBand( NS_SERVER, from, len, (byte*)buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_DPrintf( S_ERROR "bad connectionless packet from %s:\n%s\n", NET_AdrToString( from ), args );
|
||||
}
|
||||
}
|
||||
else Con_DPrintf( S_ERROR "bad connectionless packet from %s:\n%s\n", NET_AdrToString( from ), args );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -16,8 +16,6 @@ GNU General Public License for more details.
|
||||
#include "common.h"
|
||||
#include "server.h"
|
||||
|
||||
extern convar_t con_gamemaps;
|
||||
|
||||
/*
|
||||
=================
|
||||
SV_ClientPrintf
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user