Compare commits

..

968 Commits

Author SHA1 Message Date
Alibek Omarov
21f4d1486c 3rdparty: add MultiEmulator by 2010kohtep
* patched to be portable, turned into a static library
* integrated to the engine
2024-10-15 06:15:45 +03:00
Alibek Omarov
a32c702dbd engine: client: avoid useless check on empty clc_resourcelist, which will never be false 2024-10-15 06:15:22 +03:00
Alibek Omarov
23a5ed71de engine: easier MSG_EndBitWriting byte padding 2024-10-15 06:14:37 +03:00
Alibek Omarov
245dc97cfb engine: semi-correct printing GoldSrc client messages 2024-10-15 06:12:31 +03:00
Alibek Omarov
ece204c30f engine: common: add cvars net_send_debug and net_recv_debug to print server/client messages to console 2024-10-15 06:11:57 +03:00
Alibek Omarov
1bd59096fd engine: client: implement miscellaneous, often unused, GoldSrc protocol messages 2024-10-15 06:10:25 +03:00
Alibek Omarov
0b02c2c6a7 engine: client: fix disconnect on GoldSrc servers 2024-10-15 06:08:21 +03:00
Alibek Omarov
6a61a499e9 engine: client: don't send useless/empty clc_move commands while we're connecting to server 2024-10-15 06:07:57 +03:00
Alibek Omarov
6b1c283082 engine: client: fix svc_event parsing 2024-10-15 06:07:06 +03:00
Alibek Omarov
5402a9611e engine: common: fix discarded const qualifier 2024-10-14 19:41:36 +03:00
Alibek Omarov
43e06ccd45 engine: common: make some simple functions inlined 2024-10-14 19:20:47 +03:00
Alibek Omarov
f52c825bf5 engine: make some global variables static and const, make even more functions static if possible 2024-10-14 19:19:46 +03:00
Alibek Omarov
bf8b709372 engine: move pm_debug particle functions to client, as they are never used on server 2024-10-14 19:11:26 +03:00
Alibek Omarov
fdf82e5270 engine: client: cleanup tent and efx code, make global variables static, remove unused functions 2024-10-14 18:08:01 +03:00
Alibek Omarov
0224a1b66b engine: client: better debug messages for GoldSrc entities packet parsing 2024-10-14 17:59:17 +03:00
Alibek Omarov
505ad6d69b engine: server: reinitalize delta in case if delta was shutdown by client and some tables were omitted (movevars after using GoldSrc server) 2024-10-14 06:56:17 +03:00
Alibek Omarov
5bcd573821 engine: remove goldsrc meta delta table reinitialization 2024-10-14 06:54:41 +03:00
Alibek Omarov
c5a291d9c7 engine: minor refactoring 2024-10-14 05:17:21 +03:00
Alibek Omarov
232a8c1148 engine: common: net_ws: don't expect more than 5 splits for GoldSrc protocol 2024-10-14 05:17:03 +03:00
Alibek Omarov
663f6eaf5c ref: turn r_shadows into extended convar_t 2024-10-14 04:18:35 +03:00
Alibek Omarov
9d3210259c ref: set hullcolor (used by r_drawentities) as const 2024-10-14 04:15:48 +03:00
Alibek Omarov
4ec6c2f7cf engine: client: support vox sentence that starts with leading slash 2024-10-14 04:13:10 +03:00
Alibek Omarov
8452bec877 engine: client: reduce reads of cls.legacymode 2024-10-14 04:13:10 +03:00
Alibek Omarov
0d4296e0e1 engine: client: explicitly pass protocol to svc_time parser 2024-10-14 04:13:10 +03:00
Alibek Omarov
2b85da3bc9 engine: client: fix parsing svc_setpause and svc_goldsrc_timescale for GoldSrc protocol 2024-10-14 04:13:10 +03:00
Alibek Omarov
17f194b9a3 engine: client: consolidate usermsg registering and parsing for multiple protocols 2024-10-14 04:13:10 +03:00
Alibek Omarov
ff47fbaedc engine: client: another fix baselines and entities parsing for GoldSrc, ensure we always call MSG_EndBitWriting 2024-10-14 04:13:10 +03:00
Alibek Omarov
87c88f7463 engine: client: fix svc_particles parsing on GoldSrc protocol 2024-10-14 04:13:10 +03:00
Alibek Omarov
60fd5f7ab8 engine: client: stub svc_restoresound for legacy protocol, it's only used during save restore which is unuseful for us
* Set sequence flag for restored sound, even though we don't support sequences anymore.
2024-10-14 04:13:10 +03:00
Alibek Omarov
5ceab059dc engine: client: add function for parsing common protocol messages, which structure is enforced by server DLL compatibility 2024-10-14 04:13:10 +03:00
Alibek Omarov
67c898f9ad engine: client: improve server data parsing for GoldSrc, restore nick name and remove unuseful userinfo keys before connection 2024-10-14 04:13:10 +03:00
Alibek Omarov
d903187eea public: make crc value init functions inline, move hex2char/ex2string to crclib and make them private to it 2024-10-14 04:13:10 +03:00
54ac
653f0841e4 ref: gl: restore r_shadows (#1843) 2024-10-13 17:15:29 +03:00
Alibek Omarov
10bfadb556 engine: client: support svc_disconnect reason messages for GoldSrc protocol 2024-10-11 20:58:46 +03:00
Alibek Omarov
0b2cc066dd engine: fix signed integers encoding with alternate format for GoldSrc protocol 2024-10-11 20:36:09 +03:00
Alibek Omarov
60ab13d216 engine: client: always add [Xash3D] to the nickname on GoldSrc servers 2024-10-11 19:32:16 +03:00
Alibek Omarov
f90c658567 engine: client: skip voice data for GoldSrc protocol to avoid svc_bad 2024-10-11 19:31:41 +03:00
Alibek Omarov
0c54895877 engine: client: add unmunge function for consistency info for GoldSrc protocol 2024-10-11 18:41:17 +03:00
Alibek Omarov
4eb54328f8 engine: client: various connection setup fixes for GoldSrc proto
* always add "steam" to getchallenge message
* cdkey md5 should be sent with lowercase
* strip null terminator from connect message
2024-10-11 18:41:16 +03:00
Alibek Omarov
b1189db9c5 engine: client: avoid clc_move spam when we're connected but not spawned yet 2024-10-11 00:08:21 +03:00
Alibek Omarov
869578f1ba engine: client: lie about sv_version for GoldSrc protocol 2024-10-11 00:08:21 +03:00
Alibek Omarov
3320f776ce engine: client: implement correct clc_fileconsistency response for GoldSrc 2024-10-11 00:08:21 +03:00
Alibek Omarov
1d64635783 engine: correctly check for cls.legacymode, as it's not a boolean anymore 2024-10-11 00:08:21 +03:00
Alibek Omarov
bbb076c0d4 engine: client: voice: don't print about unsupported codec with empty string name 2024-10-10 23:40:23 +03:00
Alibek Omarov
fe2a4d0428 engine: common: net_encode: remove DT_SIGNED_GS flag just in case 2024-10-10 23:40:23 +03:00
Alibek Omarov
6bdc1941e6 engine: common: netchan: only compress with BZip2 when it's efficient 2024-10-10 23:40:23 +03:00
Alibek Omarov
9188905145 engine: client: fix map CRC match with GoldSrc protocol 2024-10-10 23:40:23 +03:00
Alibek Omarov
3f2fbb10d8 engine: client: only send continueloading for legacy protocol 2024-10-10 23:40:23 +03:00
Alibek Omarov
9c97235fe8 engine: client: implement GoldSrc connectionless print message 2024-10-10 23:40:23 +03:00
Alibek Omarov
70a13b47db engine: client: implement randomized cdkey for GoldSrc protocol 2024-10-10 23:40:22 +03:00
Alibek Omarov
18afaf0eaf engine: client: more accurate clc_move for GoldSrc protocol 2024-10-10 23:38:55 +03:00
Alibek Omarov
8b8c3d8116 scripts: waifulib: xcompile: define WebAssembly target as DEST_OS wasi 2024-10-10 16:13:54 +03:00
Alibek Omarov
514fc9fe43 public: reserve identifier for WebAssembly port 2024-10-10 16:13:20 +03:00
Alibek Omarov
5d8923d69c scripts: waifulib: sdl2: fix build on macOS 2024-10-10 15:44:32 +03:00
Alibek Omarov
5db880af57 engine: wscript: add an ability to build with SDL3 2024-10-10 06:13:56 +03:00
Alibek Omarov
c05db9ce58 waf: upgrade waifu to latest master 2024-10-10 06:13:32 +03:00
Alibek Omarov
04079abe00 scripts: waifulib: re-export sdl2.py from waifu repository, add sdl3 compatibility 2024-10-10 06:13:23 +03:00
Alibek Omarov
8054b69f73 readme: add GoldSrc protocol support, add RedHat/Fedora build instructions, better wording [skip ci] 2024-10-10 01:58:56 +03:00
SNMetamorph
b5ee777466 Documentation: added article about GoldSrc network protocol support 2024-10-10 01:52:44 +03:00
Alibek Omarov
96f3061709 ref: gl: show texture size in memory, skip empty pages, skip empty 0-th texture 2024-10-09 02:44:26 +03:00
Alibek Omarov
420c5a4ff3 ref: gl: set numeric value for wrappers macros, similar to build.h macros 2024-10-09 02:01:10 +03:00
Alibek Omarov
e8f6476e8c ref: gl: patch to compile with nanogl (nanogl doesn't impement glTexCoord3f) 2024-10-09 00:31:05 +03:00
Alibek Omarov
65ec35b732 engine: client: fix bug in temp entity parsing caused by find and replace 2024-10-08 23:02:02 +03:00
Alibek Omarov
8d731b5d15 engine: common: fix for dedicated again 2024-10-08 16:41:25 +03:00
Alibek Omarov
38c0dc4551 3rdparty: bzip2: properly use stdio-free version, don't include tests and utils to the build 2024-10-08 15:39:56 +03:00
Alibek Omarov
4d8cb0469f scripts: gha: build Linux binaries with bundled deps, to avoid external dependency on libbz2 2024-10-08 13:09:34 +03:00
Alibek Omarov
62cb8f5ba6 3rdparty: bzip2: forgot to add actual bz_version.h file 2024-10-08 13:07:42 +03:00
Alibek Omarov
97c75d96d5 3rdparty: bzip2: build with BZ_NO_STDIO 2024-10-08 13:06:02 +03:00
Alibek Omarov
f5ae806b31 ref: gl: add r_showtextures implementation by ncuxonaT
Main changes made by me besides engine differences:
* Text color changed to pure white for better readability
* An attempt to draw texture name in full size
2024-10-08 12:56:07 +03:00
Alibek Omarov
482dc3a5a5 engine: client: fix joining current protocol servers 2024-10-08 12:43:29 +03:00
Alibek Omarov
a8539ac004 3rdparty: bzip2: add pre-generated bz_version.h header as some generators (like cmake.py) don't understand subst yet 2024-10-08 12:27:41 +03:00
Alibek Omarov
9970c56218 engine: common: disable bzip2 for dedicated server, it's not used there 2024-10-08 12:14:37 +03:00
Alibek Omarov
480218412a engine: client: remove voidptr hack from IN_EngineAppendMove, just use usercmd_t directly 2024-10-08 04:07:03 +03:00
Alibek Omarov
6ae09d2866 engine: client: support GoldSrc signon and refactor parsing delta entities for current and legacy protocols 2024-10-08 04:07:03 +03:00
Alibek Omarov
609680b328 engine: client: support parsing GoldSrc event messages 2024-10-08 04:07:03 +03:00
Alibek Omarov
ccbe370c8e engine: client: add support for parsing GoldSrc messages 2024-10-08 04:07:03 +03:00
Alibek Omarov
9706e47643 engine: client: refactor and implement GoldSrc-specific parsing bits in common message parsing code 2024-10-08 03:28:02 +03:00
Alibek Omarov
d98361f782 engine: client: add support for parsing GoldSrc svc_temp_entity 2024-10-08 03:28:02 +03:00
Alibek Omarov
ba7c789ec9 engine: common: add GoldSrc delta support 2024-10-08 03:28:02 +03:00
Alibek Omarov
d128997d40 engine: common: add GoldSrc bitbuf operations, add support for GoldSrc signed integers 2024-10-08 03:28:02 +03:00
Alibek Omarov
61342547ce engine: common: add support for GoldSrc split packet 2024-10-08 03:28:02 +03:00
Alibek Omarov
c1a5f173b8 engine: common: add GoldSrc netchan support 2024-10-08 03:28:02 +03:00
Alibek Omarov
f5c5b7b2c8 engine: common: add buffer munge functions 2024-10-08 03:28:02 +03:00
Alibek Omarov
057b47555d 3rdparty: bzip2: add wscript for bzip2, check for system-wide bzip2, add readme note 2024-10-08 03:28:02 +03:00
Alibek Omarov
43299f6747 3rdparty: add bzip2 submodule 2024-10-08 03:28:02 +03:00
Alibek Omarov
03bf6cb719 engine: client: get rid of PROTOCOL_GOLDSRC_VERSION, as connprotocol_t enum does it's job 2024-10-08 03:27:32 +03:00
Alibek Omarov
3a1bb12830 engine: client: rename CL_LegacyMode to CL_Protocol 2024-10-08 03:27:09 +03:00
Alibek Omarov
5efa68757e engine: remove unused svc_deltapacketbones 2024-10-08 03:27:09 +03:00
Alibek Omarov
afaf5bf3ea engine: improve security a little bit by properly checking customization files starting with \!MD5
Implement basic test for COM_IsSafeFileToDownload

Move COM_ParseFileSafe test to libpublic
2024-10-08 03:22:53 +03:00
SNMetamorph
50c805826f engine: implemented handling SIGTERM signal for proper stopping dedicated server 2024-10-08 01:05:26 +03:00
Alibek Omarov
35ae9f4a64 engine: client: don't save thirdperson value, it's not used anywhere 2024-10-07 21:00:16 +03:00
Alibek Omarov
d7d96c02a2 engine: client: implement cvar showpause for GoldSrc compatibility 2024-10-07 20:59:44 +03:00
Alibek Omarov
dd03723144 readme: add libopus-dev to dependencies list on Debian/Ubuntu 2024-10-07 18:09:32 +03:00
xiaodo
26f07196ea engine: Format Codes. 2024-10-07 17:22:27 +03:00
xiaodo
8c291fdfe3 engine: fix CenterPrint Wrong Y Position. 2024-10-07 17:22:27 +03:00
xiaodoxd
d1e118f07c Fix CenterPrint Wrong X Position 2024-10-07 17:22:27 +03:00
Alibek Omarov
6c531c14e6 engine: common: cvar: compatibility hack for mods that depend on HL25 widescreen FOV
Fixes Natural Selection 3.3 beta 9.
2024-10-04 19:09:43 +03:00
Alibek Omarov
433213c915 engine: server: fix cvar description for mp_footsteps 2024-10-04 19:07:44 +03:00
Alibek Omarov
ab0c0b18c2 engine: server: remove limit on sv_zmax value as it breaks Natural Selection mod 2024-10-04 19:07:08 +03:00
Alibek Omarov
29fd5f9fbe engine: server: remove FCVAR_SERVER flag from sv_zmax
The problem is that FCVAR_SERVER flagged cvars get saved to listenserver.cfg.

The game code usually sets sv_zmax value to worldspawn parameters and
listenserver.cfg gets generated before server DLL gets initialized.
2024-10-04 19:04:34 +03:00
Alibek Omarov
882d8afc93 engine: server: stub SV_RestartDecals for dedicated server 2024-10-04 01:28:22 +03:00
Alibek Omarov
e11635d15c engine: server: slight refactoring, hide client calls under XASH_DEDICATED, remove useless dedicated stub 2024-10-04 01:22:59 +03:00
Alibek Omarov
5d79d93aac engine: server: use safe cvar unlinking for mods that deallocate cvars (like HL Unified SDK) 2024-10-03 15:32:14 +03:00
Alibek Omarov
7ccf651fd0 engine: cvar: implement safer cvar unlinking in case when game deallocates cvar 2024-10-03 15:32:14 +03:00
Alibek Omarov
67af41cce8 engine: common: net_ws: more minor refactoring, avoid memcpy for same type structs 2024-10-02 23:30:42 +03:00
Alibek Omarov
e2c96e62e1 engine: common: net_ws: drop IPv4 mapped as IPv6 support, it's an artifact from dual-stacking experiments and not used anymore 2024-10-02 23:26:28 +03:00
Alibek Omarov
2ecae442fc engine: common: net_ws: minor refactoring 2024-10-02 23:25:12 +03:00
Alibek Omarov
a1060b0eb5 engine: add v6only master servers, add v6only flag for NET_StringToAdrNB 2024-10-02 23:23:08 +03:00
Alibek Omarov
ddd8de888f engine: add macro XASH_NO_IPV6_RESOLVE to completely skip resolving addresses with family AF_INET6 2024-10-02 23:21:25 +03:00
Alibek Omarov
a758dffbc1 public: avoid useless copy in Q_timestamp 2024-10-02 22:18:16 +03:00
Alibek Omarov
87775faeca engine: common: properly check if we can destroy resolve mutexes. Add net_resolve_debug cvar to enable printing resolve thread debug messages. 2024-10-02 22:16:51 +03:00
Alibek Omarov
ef0fc46ed8 wscript: allow async resolving for NSwitch 2024-10-02 00:55:53 +03:00
Alibek Omarov
138b4fa247 wscript: allow async resolving for PSVita 2024-10-02 00:55:53 +03:00
Alibek Omarov
47d1f3459c engine: common: try to implement DNS resolve thread through SDL2 functions if SDL2 build is enabled 2024-10-02 00:55:53 +03:00
Alibek Omarov
4712aae834 engine: server: move autoprecaching wads after parsing reslists
An attempt to avoid assert() in HL Unified SDK.
2024-09-30 18:46:01 +03:00
Ivan Avdeev
2900ee1cde engine: allow specifying screenshot filenames in command directly 2024-09-30 17:15:09 +03:00
Alibek Omarov
c6c4178dd2 engine: client: set TE_SPRAY to collide with world, fixes c7ad8e4bf 2024-09-30 04:15:22 +03:00
Alibek Omarov
a3ce0e6b1b public: tests: test_efp: mark Test_ExtractFilePath as static 2024-09-30 04:00:28 +03:00
Alibek Omarov
0b1ad3b7f0 engine: imagelib: fix mismatched dealloc in a test 2024-09-30 04:00:28 +03:00
Alibek Omarov
37fb46f092 wscript: enable mismatched-dealloc and free-nonheap-object, now that we mark all malloc-like functions with malloc attribute 2024-09-30 04:00:28 +03:00
Alibek Omarov
bc8bf9a9fb engine: add const on delta functions 2024-09-30 04:00:28 +03:00
Alibek Omarov
9e28c98911 engine: print to stderr if writing message to logfile failed 2024-09-30 04:00:28 +03:00
Alibek Omarov
0a1269d52d filesystem: zip: fix non-heap object dealloc 2024-09-30 04:00:28 +03:00
Alibek Omarov
2e5bc31c9e filesystem: set malloc like attribute for imported zone memory allocator functions 2024-09-30 04:00:28 +03:00
Alibek Omarov
1b335fd945 ref: soft: set malloc like attribute for imported zone memory allocator functions 2024-09-30 04:00:28 +03:00
Alibek Omarov
0c8b2d007a ref: gl: set malloc like attribute for imported zone memory allocator functions 2024-09-30 04:00:28 +03:00
Alibek Omarov
9ee1b32e2d engine: set malloc like and warn_unused_result attributes on common allocation functions, fs, image and soundlib 2024-09-30 04:00:28 +03:00
Alibek Omarov
953ad98a16 engine: workaround buggy stringop-overflow 2024-09-30 04:00:28 +03:00
Alibek Omarov
1357057bd8 common: add GCC malloc and warn_unused_result attribute macro 2024-09-30 04:00:28 +03:00
Alibek Omarov
35c9323de6 public: make vec3_origin and identity matrix inlined 2024-09-30 00:15:47 +03:00
Alibek Omarov
13a0afef06 public: reorganize mathlib, inline more functions 2024-09-30 00:15:47 +03:00
Alibek Omarov
c7ad8e4bf6 engine: client: more accurate implementation of TE_SPRAY and TE_SPRITE_SPRAY 2024-09-29 20:36:09 +03:00
Alibek Omarov
f1754bdd5f wscript: disable cast-align diagnostic, it's mostly useless 2024-09-29 20:36:09 +03:00
Alibek Omarov
c462a1c500 wscript: add commented out freevgui subproject 2024-09-29 20:36:09 +03:00
Alibek Omarov
0bba184994 public: add VectorUnpack macro to read vector values into variables 2024-09-29 20:33:33 +03:00
Alibek Omarov
178602ea1f engine: fix loading map in Dark Future mod with broken mark surface id 2024-09-05 15:23:23 +03:00
Alibek Omarov
2eb8f88a20 engine: move attenuation none sound spatialize fix to bugcomp mode, as Xash native games use this 2024-09-05 13:50:15 +03:00
Alibek Omarov
96d11df06c Revert "engine: client: sounds with zero attenuation must get spatialized anyway"
This reverts commit 0870536405.
2024-09-05 13:27:54 +03:00
Alibek Omarov
950d210ec5 Revert ABI2, it wasn't meant to end up in master branch. 2024-09-05 04:31:50 +03:00
Alibek Omarov
55c1bddac5 ref: gl: implement generating VBO only when gl_vbo was set to 1
* Make it safer by creating a function that returns VBO state, was it
  generated or enabled by user
2024-09-05 04:10:56 +03:00
Alibek Omarov
ac50c762d7 ref: gl: slight refactoring, split large R_RenderBrushPoly to smaller functions
* Use R_RenderDetailsForSurface in R_AddSurfToVBO instead of copypaste
* Use existing VBO's R_CheckLightMap in R_RenderLightmapForSurface
2024-09-05 02:40:57 +03:00
Alibek Omarov
5c2ab150b3 ref: gl: move forcing gl_vbo to 0 after checking GL extensions out from R_GenerateVBO 2024-09-05 01:47:14 +03:00
Alibek Omarov
0870536405 engine: client: sounds with zero attenuation must get spatialized anyway 2024-09-05 01:28:55 +03:00
Alibek Omarov
b47ede477a engine: server: strip 64-bit string pool stuff for now, to not mess up abi2 2024-09-05 01:28:55 +03:00
Alibek Omarov
eef5cc17b3 breaking engine headers by replacing int with string_t where it's supposed to be 2024-09-05 01:28:55 +03:00
Alibek Omarov
ad2191333d engine: add _st64 prefix to load abi2 binaries 2024-09-05 01:28:55 +03:00
SNMetamorph
a85cac497d ref: disabled verbose reporting about tracer invalid color index 2024-09-03 15:31:51 +03:00
SNMetamorph
e0c69d7df5 gha: fixed binaries signing in Windows workflow 2024-08-30 07:34:40 +03:00
Alibek Omarov
ff3d91ceb4 engine: add aaaa.mentality.rip:27011 master server 2024-08-28 19:56:41 +03:00
Alibek Omarov
5777431577 engine: common: insert spaces between arguments in echo command 2024-08-22 16:45:42 +03:00
Alibek Omarov
cd86f80203 engine: common: make MSG_WriteOneBit inlined, as it's usually called with literal argument 2024-08-22 12:51:47 +03:00
Alibek Omarov
8c885d3f37 mainui: update 2024-08-22 12:50:01 +03:00
Alibek Omarov
dddb46a6d0 mainui: update 2024-08-21 18:14:21 +03:00
Alibek Omarov
6b0f378c5b engine: client: ensure requested (but failed) renderer won't be loaded twice 2024-08-21 12:18:06 +03:00
Alibek Omarov
9dd7f37d42 Revert "engine: client: add missing ref_null to R_CollectRendererNames"
This reverts commit 69ec810ed0.
2024-08-21 12:18:06 +03:00
Alibek Omarov
9f10fb6472 engine: client: ensure RefDll cvars have FCVAR_REFDLL flag, clean up them automatically. Don't unload failed renderer, it will be done in R_UnloadProgs 2024-08-21 12:18:06 +03:00
Alibek Omarov
64dbccb9bd engine: platform: sdl: do not call SDL_VideoQuit in R_Free_Video, as one failed renderer will shut down whole SDL video subsystem 2024-08-21 12:18:06 +03:00
Alibek Omarov
9a432a5a13 common: rewrite cvardef.h from scratch based on Quake definitions
* unify cvar.h and cvardef.h, enable private definitions only for refdll and engine

* add FCVAR_REFDLL for easier RefDll cvars cleanup
2024-08-21 12:18:06 +03:00
Alibek Omarov
842e494fa6 common: add macro for simultaneously checking data type size for ILP32 and LP64 2024-08-21 12:00:35 +03:00
Alibek Omarov
7fc9ee154a engine: client: fail with Sys_Error when no renderer is loaded, as we can't recover from it 2024-08-19 13:25:07 +03:00
Alibek Omarov
5f84010c2a engine: server: enable allocating 64-bit string pool closer to server library only for Linux amd64, as mmap() isn't reliable anywhere else 2024-08-19 13:22:04 +03:00
Alibek Omarov
3dcd6cb80b wscript: set crosscompiling msvc toolchain on 64-bit systems 2024-08-18 14:13:51 +03:00
Alibek Omarov
79e94bf766 Revert "scripts: gha: use 64-bit compiler for 32-bit target for faster compilation on Win32"
This reverts commit 3de370f3d5.
2024-08-18 14:13:01 +03:00
Alibek Omarov
3de370f3d5 scripts: gha: use 64-bit compiler for 32-bit target for faster compilation on Win32 2024-08-18 14:04:54 +03:00
Alibek Omarov
c84d2f4624 gha: first attempt at signing binaries 2024-08-18 13:52:02 +03:00
Alibek Omarov
380a9f7a6f scripts: add self-signed certificate for win32
* There is no infrastructure to use signtool during win32 builds yet.
2024-08-18 12:24:17 +03:00
Alibek Omarov
a6c7b67d0d filesystem: include errno.h for Win32 2024-08-17 17:32:50 +03:00
Alibek Omarov
c13c1f2577 public: wscript: always define alloca header as malloc.h on Win32 2024-08-17 13:17:48 +03:00
Alibek Omarov
151405618f engine: client: input: slight refactoring of mouse grabbing, add verbose output for debugging mouse issues 2024-08-16 12:59:54 +03:00
Alibek Omarov
70e11cc309 engine: platform: sdl: borderless fullscreen windows don't need to restore desktop resolution
* This fixes the case when we switch from windowed to borderless, minimize the window
  and restore makes it lose it's fullscreen state
2024-08-16 12:25:08 +03:00
Alibek Omarov
7619824d80 engine: platform: sdl: return correct value from SW_CreateBuffer on success 2024-08-16 11:36:36 +03:00
Alibek Omarov
f3d181b5ee engine: platform: psvita: explicitly export __aeabi_ul2f 2024-08-16 02:22:25 +03:00
Alibek Omarov
55055a70f0 engine: client: allocate mods list for UI on demand 2024-08-15 12:27:43 +03:00
Alibek Omarov
22d3ba674e engine: client: ensure demoheader will be written when we're recording demo and changed level 2024-08-14 19:10:00 +03:00
Alibek Omarov
ac487a2133 mainui: update 2024-08-14 10:29:42 +03:00
Alibek Omarov
4da3a14adc mainui: update 2024-08-13 19:25:32 +03:00
Alibek Omarov
69ec810ed0 engine: client: add missing ref_null to R_CollectRendererNames 2024-08-13 19:16:59 +03:00
Alibek Omarov
2df01316ce engine: client: add two new APIs for mainui to get extended new gameinfo structure 2024-08-13 18:28:07 +03:00
Alibek Omarov
3a67aefee2 filesystem: check rodir too when checking falldir existence too, just in case 2024-08-13 17:25:25 +03:00
Alibek Omarov
d114dffcb4 filesystem: add new gameinfo.txt key: demomap 2024-08-13 17:22:06 +03:00
Alibek Omarov
7bb5d9a67a gha: give github 20s to process remaining artifacts upload before downloading them. Upgrade Flatpak Docker image 2024-08-12 11:43:01 +03:00
Alibek Omarov
a6b1e57ae1 gha: simplify uploading releases by using gh cli tool 2024-08-12 11:26:36 +03:00
Alibek Omarov
c70c13eb5c gha: don't upload flatpak, action does it for us. Print found artifacts, as it seems actions/download-artifact sometimes skips some 2024-08-12 10:44:25 +03:00
Alibek Omarov
d905ea354e scripts: gha: do not waste time building bshift, just copy binary from mobile_hacks 2024-08-12 10:27:26 +03:00
Alibek Omarov
99cec81894 gha: update flatpak actions 2024-08-12 10:07:41 +03:00
Alibek Omarov
5d5bccf1bb gha: should've been doing this in a branch meh 2024-08-12 09:53:45 +03:00
Alibek Omarov
6fcf0a77af scripts: gha: fix typo 2024-08-12 09:43:02 +03:00
Alibek Omarov
e7477c0abf gha: update more actions, use gh delete release instead of delete-tag-and-release 2024-08-12 09:37:55 +03:00
Alibek Omarov
85540855c3 gha: update actions/checkout and actions/upload-artifact 2024-08-12 09:12:32 +03:00
Alibek Omarov
2dc220b42f gha: add build for macOS ARM and x86
Very barebones, doesn't build universal app, doesn't build dmg
2024-08-12 09:12:13 +03:00
Alibek Omarov
2d6cadbf1b waf: update to latest waifu 2024-08-12 08:38:52 +03:00
Alibek Omarov
340871e03a engine: platform: sdl: correct the message about glblit in ref_soft 2024-08-11 18:32:10 +03:00
Alibek Omarov
e222a74960 ref: soft: fail to the engine if CreateBuffer has failed (otherwise it sits in infinite loop) 2024-08-11 18:28:45 +03:00
Alibek Omarov
ab499d5095 scripts: waifulib: vgui: fix vgui_support getting automatically enabled on x86 machines with unsupported OS 2024-08-11 18:08:20 +03:00
Alibek Omarov
a5f7027229 readme: better wording 2024-08-10 15:03:07 +03:00
Alibek Omarov
bf5cf897e2 readme: add IPA pronounciation for word 'Xash' 2024-08-10 15:02:31 +03:00
Alibek Omarov
d33c1af549 wscript: don't force 32-bit for OSX users, as OSX don't support launching 32-bit applications since Catalina
Add `-4` or `--32bits` configure flag to specifically target 32-bit engine
2024-08-10 15:01:42 +03:00
Alibek Omarov
677464d04d ref: rename glpoly_t to glpoly2_t to make the changes more obvious and easier to notice 2024-08-10 13:46:00 +03:00
Alibek Omarov
d2d6ed8bd4 filesystem: fix zip_t and pack_t definition so it have true standard flexible array member 2024-08-10 13:46:00 +03:00
Alibek Omarov
bd2a44dbdd engine: common: fix fragbuf_t definition so it has true standard flexible array member 2024-08-10 13:46:00 +03:00
Alibek Omarov
e9ee4beb9f engine: client: fix rawchan_t definition so it has true standard flexible array member 2024-08-10 13:46:00 +03:00
Alibek Omarov
3b3f057f6f engine: common: fix winding_t definition so it has true standard flexible array member 2024-08-10 13:46:00 +03:00
Alibek Omarov
a9dec51e59 ref: fix glpoly_t definition so it has true standard flexible array member 2024-08-10 13:46:00 +03:00
Alibek Omarov
257312ad7c 3rdparty: update extras 2024-08-10 13:45:41 +03:00
Владислав Сухов
6ee8a2dfa7 scripts: sailfish: bump engine version to 0.21 2024-08-09 12:41:47 +03:00
Владислав Сухов
75c5e9cfa7 engine: bump engine version to 0.21 2024-08-09 12:41:47 +03:00
Gleb Mazovetskiy
1a94f2b585 Enable vsync by default
This is the first setting I change after installing xash3d-fwgs. Some distros even patch xash3d-fwgs to enable vsync by default (e.g. Batocera).

Let's enable vsync by default here.
2024-08-09 09:14:50 +03:00
Alibek Omarov
f0b4c42c68 engine: common: faster and simpler Netchan_OutOfBand 2024-08-08 04:37:16 +03:00
Alibek Omarov
9be061735f engine: client: fix misleading gcc warning about printf format string not being literal 2024-08-08 04:36:40 +03:00
Alibek Omarov
6bfa525080 engine: common: faster and simpler MSG_WriteString 2024-08-08 04:35:55 +03:00
Alibek Omarov
8fcaf18897 engine: client: remove useless copy in NetAPI_SendRequest 2024-08-08 04:32:58 +03:00
Alibek Omarov
f558cde266 engine: client: fix build with -Wincompatible-pointer-types-discards-qualifiers 2024-08-08 04:31:51 +03:00
Alibek Omarov
b508a33f5d engine: client: minor refactoring in CL_DecayLights, get rid of pointer iterating in for-loop 2024-08-07 09:23:09 +03:00
Alibek Omarov
b4db99006b engine: client: always print timedemo result 2024-08-07 08:46:55 +03:00
Alibek Omarov
8994f079a5 engine: common: don't uselessly copy data in Netchan_OutOfBound when playing a demo 2024-08-07 02:28:58 +03:00
Alibek Omarov
b2d184cfa5 engine: common: add unit tests for net_buffer functions 2024-08-07 02:28:13 +03:00
Alibek Omarov
92dc92379f engine: client: minor refactoring, turn quake stats into an enum 2024-08-06 08:42:23 +03:00
Alibek Omarov
2a6862ceb9 engine: soundlib: fix buffer overflow with truncated WAV files containing CoolEdit cue mark 2024-08-06 08:41:36 +03:00
Alibek Omarov
4c569e1d5f engine: client: ensure loading plaque was removed after we request spawn on legacy protocol 2024-08-03 11:27:45 +03:00
Alibek Omarov
4420ffd49e engine: fix buffer overflow in Sys_PrintLog 2024-08-03 11:27:45 +03:00
Alibek Omarov
fb7f57cf6a engine: client: switch efrags to dynamic allocation (as suggested on insideqc by @mh) 2024-08-03 11:27:45 +03:00
Alibek Omarov
8be3bdac5d engine: client: add command listdemo to show information about demo file (isn't really useful, just reads file header) 2024-08-03 11:01:17 +03:00
Alibek Omarov
2785376bd3 ref: remove unused function declarations 2024-08-03 09:14:56 +03:00
Alibek Omarov
d6e77e531d engine: fix memory leak in netchan
frag_message_buf wasn't always freed alongside with fragbuf_t
instead of ensuring frag_message_buf being freed, I turned it into
a flexible array member
2024-08-03 08:40:33 +03:00
Alibek Omarov
e686b1410d engine: client: set default fullscreen value in vid_fullscreen cvar definition 2024-07-31 00:53:58 +03:00
Alibek Omarov
2c23a1e0a0 engine: platform: sdl: fix going fullscreen after manually changing VIDRESTART cvars (like width and height) 2024-07-31 00:53:29 +03:00
Alibek Omarov
47eb9e8c8f engine: client: replace same struct type memcpys by assignments 2024-07-31 00:06:22 +03:00
Alibek Omarov
712b354421 engine: common: replace same struct type memcpys by assignments 2024-07-31 00:06:22 +03:00
Alibek Omarov
18ef4922de engine: server: replace same struct type memcpys by assignments 2024-07-31 00:06:22 +03:00
Alibek Omarov
274f9d5846 filesystem: replace same struct type memcpys by assignments 2024-07-31 00:06:15 +03:00
Alibek Omarov
f6fa085fe4 ref: gl: replace same struct type memcpys by assignments 2024-07-31 00:06:07 +03:00
Alibek Omarov
9ab0f04ba5 ref: null: replace same struct type memcpys by assignments 2024-07-31 00:05:57 +03:00
Alibek Omarov
fb7854f1ef ref: soft: replace same struct type memcpys by assignments 2024-07-31 00:05:44 +03:00
Владислав Сухов
1086c31503 engine: client: in_touch.c: make the voicechat and spray buttons multiplayer only 2024-07-30 17:52:28 +03:00
Alibek Omarov
3a47248a09 extras: update submodule 2024-07-30 15:34:20 +03:00
Владислав Сухов
71a333261b engine: client: in_touch.c: added voicechat touch button 2024-07-30 15:33:35 +03:00
Alibek Omarov
5ea2e295c1 engine: prevent rescanning filesystem when new player connects or on late precache
By reusing a padding hole in resource_t structure, we put a bit indicating that this archive
was already mounted by filesystem and skip it.

Because we associate this with resource, theoretical use of late precache with archives
will rescan filesystem and allow using newly downloaded assets.
2024-07-30 15:25:48 +03:00
Alibek Omarov
1fc7547a53 engine: client: clean up scr_viewsize remnants, don't tell client.dll scr_viewsize cvar value 2024-07-30 15:25:20 +03:00
Alibek Omarov
a7d63649f8 engine: add checks to verify resource_t, customization_t and HPAK data structs sizes 2024-07-30 15:25:20 +03:00
Alibek Omarov
2f26fcdc2a public: disallow backslashes in COM_PathSlashFix 2024-07-30 15:25:20 +03:00
Alibek Omarov
107d4cdd61 engine: client: fix buffer overrun in S_TrimEnd 2024-07-30 15:25:20 +03:00
Alibek Omarov
52f9aad4d0 filesystem: add new call to fs_stdio C API to check whether we support that archive format 2024-07-30 15:25:20 +03:00
Alibek Omarov
7bb5175084 Turn downloaded/ and custom/ into com_strings.h definitions, like sound path and saves path 2024-07-30 15:25:20 +03:00
Alibek Omarov
dd570b616b engine: client: properly exit from touch editor to menu when user have chosen to cancel and reset 2024-07-29 05:11:41 +03:00
Alibek Omarov
943a30af04 engine: client: add privileged flag to touch_in_menu and touch_enable 2024-07-29 05:08:35 +03:00
Alibek Omarov
eabed60e56 engine: automatically turn-on touch emulation while editing touch from menu 2024-07-29 05:06:10 +03:00
Alibek Omarov
f793413a79 mainui: update 2024-07-29 05:05:20 +03:00
Alibek Omarov
f4a3b8571d engine: fix inverted check in debug log output
Why there is even this check in the first place???
2024-07-29 04:48:21 +03:00
Alibek Omarov
da6586b847 ref: gl: fix white border around the screen in Base Defense mod 2024-07-28 23:58:09 +03:00
Alibek Omarov
4a5f34089d engine: client: fix TriColor4fRendermode 2024-07-28 20:50:20 +03:00
Alibek Omarov
90da9659d1 engine: client: vgui: enable texturing in VGUI by default, just in case reset color too 2024-07-28 20:03:32 +03:00
Alibek Omarov
2e30acf611 engine: client: voice: allow restoring voice after toggling voice_enable while connected to server 2024-07-28 17:12:32 +03:00
Alibek Omarov
5554d13f7f engine: client: fix buffer overflow in voice sound mixer 2024-07-28 16:41:20 +03:00
Alibek Omarov
a5ef33b302 mainui: update 2024-07-28 14:51:09 +03:00
Alibek Omarov
9a2588f7eb engine: client: console: fix a rare crash when we're in game, console is enabled but it's empty
With ui_allowconsole toggle it's easy to reproduce: join game without console, go to menu,
enable console and return back to game.
2024-07-28 14:48:40 +03:00
Alibek Omarov
cac5852e68 ref: enable multiplayer high defintion model in menu preview 2024-07-28 14:45:10 +03:00
Alibek Omarov
d52d50e283 engine: client: set user name as default value for name cvar. Add ui_username cvar with user name. 2024-07-28 14:44:03 +03:00
Alibek Omarov
6911da8581 engine: client: add ui_allowconsole command that enables console
To be used by UI
2024-07-28 13:32:52 +03:00
Alibek Omarov
e70f9a67b8 engine: host: always enable console for dedicated 2024-07-26 11:08:34 +03:00
Alibek Omarov
173aa7333a scripts: waifulib: vgui: add option to disable vgui platform support checks, try to lookup DEST_CPU subdirectories for prebuilt library 2024-07-24 07:04:53 +03:00
Alibek Omarov
2396b2d4db ref: gl: add VBO generating/uploading times 2024-07-22 22:24:19 +03:00
Alibek Omarov
6120c0daec engine: print command line args alongside developer level during init 2024-07-22 22:15:56 +03:00
Alibek Omarov
790f9bde54 engine: client: hack mobile API init because of incorrectly defined export in hlsdk-portable 2024-07-21 21:18:00 +03:00
Alibek Omarov
7a469fb481 engine: always use original player hulls for pmove trace, because mods can write invalid data in pmove->player_{mins,maxs} 2024-07-21 11:01:18 +03:00
Alibek Omarov
d4a2011a59 wscript: add configuration option for building xar 2024-07-21 05:36:58 +03:00
Alibek Omarov
9165832caf mainui: update 2024-07-21 05:34:23 +03:00
Владислав Сухов
d274a5c13c Documentation: supported-mod-list: added new supported mods (from mobile_hacks branch of hlsdk-portable) 2024-07-21 05:16:30 +03:00
Владислав Сухов
e6bd15c68b Documentation: supported-mod-list: fix dead links 2024-07-21 05:16:30 +03:00
Alibek Omarov
38bef99f98 engine: client: fix opening Quake demos 2024-07-21 05:01:31 +03:00
Alibek Omarov
95ff9e7165 engine: client: prevent empty lightstyle console flood 2024-07-21 05:01:16 +03:00
Alibek Omarov
2fddbdddee engine: client: fix ScreenFade under quake compatibility mode 2024-07-21 04:33:46 +03:00
Alibek Omarov
465e812ed9 engine: client: fix EF_DIMLIGHT under quake compatibility mode 2024-07-21 04:33:31 +03:00
Alibek Omarov
3b1fb79a85 engine: client: use Host_IsQuakeCompatible instead of checking host.features bit 2024-07-21 04:32:38 +03:00
Alibek Omarov
0f8f35b415 engine: fix alias model loading 2024-07-21 04:15:56 +03:00
Alibek Omarov
a133b1c2a9 engine: remove unused texFlags argument in Mod_LoadSpriteModel 2024-07-21 03:04:21 +03:00
Alibek Omarov
fa74acb5f0 Revert "engine: client: make client engfuncs const"
This reverts commit 14ae9b312d.
2024-07-21 02:53:28 +03:00
Alibek Omarov
836b4c358f Revert "engine: server: make physic engfuncs const"
This reverts commit 5af9511505.
2024-07-21 02:53:23 +03:00
Alibek Omarov
982e32d108 engine: client: don't mistakingly tell user about failed mobile api, when it's just not used by client.dll 2024-07-21 02:07:38 +03:00
Alibek Omarov
024a335505 engine: move wcon definitions to platform.h 2024-07-21 02:06:51 +03:00
Alibek Omarov
963cbf61e4 filesystem: fix loading libraries from archives on Windows 2024-07-21 01:49:34 +03:00
Alibek Omarov
6d98d2c7c3 engine: check XASH3D_GAME if -game argument wasn't found, do not override default base directory
Clarify that `--gamedir` configure option and `XASH_GAMEDIR` macro specify base directory
2024-07-21 01:04:50 +03:00
Alibek Omarov
64726f13e1 engine: client: more accurate R_BeamKill reimplementation
Reverse engineered from HL25 hw.so
2024-07-19 07:13:14 +03:00
Alibek Omarov
85dfaaa2c2 engine: imagelib: add LUMP_TEXGAMMA palette kind to only pass HL textures through texgamma, not Quake 2024-07-19 06:34:51 +03:00
Alibek Omarov
42a915b04a wscript: enforce -Werror=format-extra-args 2024-07-18 01:28:35 +03:00
Alibek Omarov
42a8aa6c66 mainui: update 2024-07-18 01:27:30 +03:00
Alibek Omarov
56464d3291 engine: when colorizing standard output, use bold text, as it makes it more visible (especially with black text) 2024-07-17 22:53:35 +03:00
Alibek Omarov
aed96ee753 engine: common: reduce large static arrays amount for logging by adding generic function accepting va_list 2024-07-17 22:27:20 +03:00
Alibek Omarov
a937320c65 engine: wscript: add ffmpeg hidden option, just to make it easier for me to switch between branches 2024-07-17 22:27:20 +03:00
Alibek Omarov
a81a0cb059 engine: client: make menu engfuncs const 2024-07-16 15:23:03 +03:00
Alibek Omarov
5af9511505 engine: server: make physic engfuncs const 2024-07-16 15:23:03 +03:00
Alibek Omarov
14ae9b312d engine: client: make client engfuncs const 2024-07-16 15:23:03 +03:00
Alibek Omarov
2d3e5c2e0b engine: client: make renderer engfuncs const 2024-07-16 15:23:03 +03:00
Alibek Omarov
17950fec3e filesystem: make engfuncs const 2024-07-16 15:23:03 +03:00
Alibek Omarov
2009140da8 ref: make gReffuncs const 2024-07-16 15:23:03 +03:00
Alibek Omarov
2a394eee62 filesystem: make g_api const 2024-07-16 15:23:03 +03:00
Alibek Omarov
09a7585643 engine: soundlib: super micro-optimization, reallocate buffer in Image_Copy rather than allocating and copying 2024-07-16 05:11:06 +03:00
Alibek Omarov
a09084ceba engine: imagelib: super micro-optimization, reallocate buffer in Image_Copy rather than allocating and copying 2024-07-16 05:10:29 +03:00
Alibek Omarov
147e5dceff engine: request SDL to ungrab mouse before signaling debugger to stop 2024-07-16 05:09:02 +03:00
Alibek Omarov
3510afd30b engine: zone: allow moving allocation from one pool to another during realloc 2024-07-16 05:06:44 +03:00
Alibek Omarov
d3586c2143 engine: soundlib: add support for converting stereo to mono and back, attempt to simplify conversion boilerplate 2024-07-16 05:05:50 +03:00
Alibek Omarov
56ba2325c1 engine: client: skip drawing 2D during changelevel before the client was active
* Prevents screen garbage on GPUs with tile-based renderers like Adreno and ImgTec
2024-07-11 09:01:19 +03:00
Alibek Omarov
b77a4ed3a1 engine: client: ignore changelevel for old protocol
* Prevents engine from drawing too early during reconnect to a
  legacy coop server
2024-07-11 08:59:42 +03:00
Alibek Omarov
9b86c3127a engine: properly disconnect from online game when loading local game (save, newgame or a level) 2024-07-10 12:32:33 +03:00
Alibek Omarov
0da7ffe45f engine: client: reset video after last screen update in begin loading plaque. Because update screen supposedly should draw the whole screen now, gl_clear hack shouldn't be required anymore 2024-07-10 11:59:54 +03:00
Alibek Omarov
30b78d9559 mainui: update 2024-07-10 11:32:30 +03:00
Alibek Omarov
c16abc0b85 engine: server: first check for dedicated server in SV_IsSimulating, as CL_Active()/CL_IsInConsole() don't make sense if we're running dedicated server already 2024-07-10 10:35:47 +03:00
Alibek Omarov
708c691cdb engine: fix XASH_DEDICATED check 2024-07-10 10:34:57 +03:00
Alibek Omarov
31c20ac4d8 engine: client: don't call Host_IsDedicated when getting split size for client 2024-07-10 10:34:30 +03:00
Alibek Omarov
1458014a29 engine: remove unused CL_IsInMenu, don't check for Host_IsDedicated in SCR_BeginLoadingPlaque, it's useless 2024-07-10 10:24:22 +03:00
Alibek Omarov
1c84a5c8ad engine: platform: sdl: disable restoring desktop resolution for mobile platforms, as it leads to unwanted window minimize (which correctly implemented by SDL by the way) 2024-07-09 19:52:11 +03:00
Alibek Omarov
6728b843f7 engine: platform: android: use RTLD_NOW in dlopen()
We basically use RTLD_NOW everywhere in the engine these days,
only platform code is behind that
2024-07-09 16:50:37 +03:00
Alibek Omarov
1b55104d51 editorconfig: add IDEA exported config 2024-07-09 16:46:51 +03:00
Alibek Omarov
76978bfd47 scripts: gha: change Android project URL, update Android CLI tools and NDK 2024-07-09 08:56:14 +03:00
Alibek Omarov
6ff3231dab engine: change current working directory before initializing filesystem_stdio 2024-07-09 08:45:27 +03:00
Alibek Omarov
64716e6b42 filesystem: request win32 error string in wide chars and then transform it to UTF-8 using our utflib 2024-07-09 08:25:15 +03:00
Alibek Omarov
a1191eb4ab engine: platform: win32: request error string in wide chars and then transform it to UTF-8 using our utflib 2024-07-09 08:24:58 +03:00
Alibek Omarov
166bed732e engine: crashhandler: few improvements for win32 crashhandler
* Larger message buffer
* Print version at first line
* Tell SDL2 to ungrab mouse
2024-07-08 05:56:20 +03:00
Alibek Omarov
02cb12e4b4 mainui: update 2024-07-08 05:49:24 +03:00
Alibek Omarov
159467ad44 engine: add IPv6 master server 2024-07-07 21:18:02 +03:00
Alibek Omarov
2a006086c5 mainui: update 2024-07-07 06:51:47 +03:00
Alibek Omarov
e0dc1eec93 engine: client: more reliable way to find the payload the netinfo response 2024-07-07 06:49:54 +03:00
Alibek Omarov
ab130ee92c engine: client: fix infostring truncation in NetAPI requests 2024-07-07 06:17:38 +03:00
Alibek Omarov
dabbe09918 engine: add NetAPI flag to send NetAPI requests to old protocol servers 2024-07-07 06:17:15 +03:00
Alibek Omarov
296a7ac11d engine: client: fix NetAPI request sending 2024-07-07 06:16:46 +03:00
Alibek Omarov
6bbf08893e engine: add NetAPI to extended menu API 2024-07-07 03:39:09 +03:00
Alibek Omarov
f8b958738a engine: client: rework NetAPI response parsing 2024-07-07 03:30:34 +03:00
Alibek Omarov
1b4427f13f engine: server: rework NetAPI responses
players list and rules are now actually useful
2024-07-07 03:29:27 +03:00
Alibek Omarov
e55577fd26 engine: get rid of some size constants passed to Info_SetValueForKey, use sizeof instead 2024-07-07 03:02:02 +03:00
Alibek Omarov
c42960ec2a engine: server: mark some cvars and movevars as server cvars, so they get reported in rules query
Bring back sv_contact cvar, as it makes sense to get this from rules query
2024-07-07 03:01:59 +03:00
Alibek Omarov
c033d4b65c engine: server: optimize source query 2024-07-07 02:34:43 +03:00
Alibek Omarov
dc6f03b4e4 engine: server: add function SV_HavePassword that correctly checks whether this server have set up password 2024-07-07 02:10:48 +03:00
Alibek Omarov
b6967a432a engine: add NetAPI flag NET_ERROR_FORBIDDEN 2024-07-07 02:05:25 +03:00
Alibek Omarov
7d0467863c engine: server: add cvar to not expose current player list, or if server has a password 2024-07-07 01:59:56 +03:00
Alibek Omarov
a0b72d3995 engine: server: light sv_query.c refactoring, use Netchan_OutOfBand instead of manually creating out of band packet 2024-07-07 01:55:03 +03:00
Alibek Omarov
5fe4b867f3 engine: server: do not expose some cvars in rules, some of them just don't make sense 2024-07-07 01:51:50 +03:00
Alibek Omarov
40af058406 engine: client: console: add conback.dds by request, don't fail on texture that cannot be loaded 2024-07-06 22:30:05 +03:00
Alibek Omarov
b4376a6a8c engine: client: make a common function for sending out userinfo changes 2024-07-06 06:09:19 +03:00
Alibek Omarov
457422c679 engine: server: fix possible byte overflow when sending sound with attenuation == 4.0f 2024-07-06 05:50:53 +03:00
Alibek Omarov
080eba948f engine: server: fix sound not being overriden when an entity sound came from has an aiment set
This check was added 10+ years ago in 8f6f3fc (viewable in Xash3DArchive) and
probably doesn't make any sense anymore.
2024-07-06 05:32:20 +03:00
Alibek Omarov
eff86defd9 public: fix Q_equal for case when applying epsilon doesn't change the value 2024-07-04 07:55:32 +03:00
Alibek Omarov
fcb463d400 engine: client: flush demoheader before copying it 2024-07-04 07:23:48 +03:00
Alibek Omarov
efee8149e2 filesystem: remove unneeded cast to fs_offset_t in write() call 2024-07-04 07:23:13 +03:00
Alibek Omarov
bc32f37fce public: use Q_strchr in COM_FixSlashes 2024-07-04 06:42:49 +03:00
Alibek Omarov
58bfa247a4 public: add test case for COM_FixSlashes 2024-07-04 06:42:35 +03:00
Alibek Omarov
59b9b31604 public: avoid useless copies in Q_pretifymem 2024-07-04 06:39:18 +03:00
Alibek Omarov
844af709c0 public: simplify Q_colorstr and Q_strnlwr 2024-07-04 06:38:50 +03:00
Alibek Omarov
bb6e2d6885 public: add Q_colorstr and Q_strnlwr tests 2024-07-04 06:38:09 +03:00
Alibek Omarov
6243dc7913 public: simplify Q_ato{i,f} implementation 2024-07-04 06:30:59 +03:00
Alibek Omarov
45c4362ae6 public: add Q_ato{i,f,v} test 2024-07-04 06:29:46 +03:00
Alibek Omarov
a0230b7e00 engine: client: console: minor refactoring, move common NXPrintf code to Con_NXPrintfv 2024-07-04 05:49:33 +03:00
Alibek Omarov
768755c31a engine: client: use Con_Printf instead of Con_Print (which is just printing to console, not the logging) 2024-07-03 04:22:28 +03:00
Alibek Omarov
3088c7f198 scripts: gha: set proper PKG_CONFIG_PATH when building 32-bit SDL 2024-07-02 19:26:39 +03:00
Alibek Omarov
c8469071bf scripts: gha: add remaining wayland dependencies 2024-07-02 19:15:02 +03:00
Alibek Omarov
115fc301b5 scripts: gha: fix installing pulseaudio dependency for 32-bit build 2024-07-02 19:02:54 +03:00
Alibek Omarov
bc449b8e95 scripts: gha: enable JACK in automatic builds 2024-07-02 18:59:13 +03:00
Alibek Omarov
74bbc0fe7e scripts: gha: install pulse, jack and wayland development files for SDL to detect them 2024-07-02 18:58:53 +03:00
Alibek Omarov
c73fa3d7a6 filesystem: fix mounting wads again
Because of the mounting order, VFS fails to automatically find unpacked WADs
2024-06-28 18:00:40 +03:00
Alibek Omarov
5694610478 filesystem: fix writedir being prepended to rodir path when searching for library
* Refactor generating shortName
* Refactor library origin checks
2024-06-27 08:16:56 +03:00
Alibek Omarov
ec107dfba5 filesystem: load on-disk archives like PAK and PK3 through VFS (disk-only for now)
* Track from which archive the file has been opened and provide needed functions for it
2024-06-27 07:31:11 +03:00
Alibek Omarov
64aa476330 editorconfig: add Visual Studio options (generated) 2024-06-27 07:18:10 +03:00
Alibek Omarov
42f6719e8d filesystem: drop direct path hacks for WAD files, let VFS decide how to open WAD archives 2024-06-27 05:55:06 +03:00
Alibek Omarov
244b9dc02b wscript: disable -Wformat=2 back (it wasn't supposed to be pushed anyway) 2024-06-24 20:01:29 +03:00
Alibek Omarov
fe3644a417 engine: client: add simple debugging tool that shows entities number, model and movetype (to be extended) 2024-06-22 08:19:19 +03:00
Alibek Omarov
e18b61e041 Fixes for -Wformat=2 on 64-bit targets 2024-06-22 07:31:37 +03:00
Alibek Omarov
d054782693 engine: client: fix broken legacy demos playing
Fixes: ff4221fbe7 ("engine: client: write correct cls.legacymode/net_protocol value for demos")
2024-06-22 07:30:47 +03:00
Alibek Omarov
d56e53a347 Replace hardcoded functions names by __func__ macro
* while we're here, fix some possible bugs
* and fix -Wformat=2

s/__FUNCTION__/__func__/g

awawawa
2024-06-19 06:53:42 +03:00
Alibek Omarov
3503c721ac engine: client: console: simplify loading console background image 2024-06-19 03:35:28 +03:00
Alibek Omarov
0fab5f07d0 Revert "engine: common: mod_studio: reject models with split textures files that cannot be loaded"
This reverts commit 3256236ba2.
2024-06-18 22:50:06 +03:00
Alibek Omarov
b0d12f8bf9 engine: client: fix build
Forgot to stage these changes two commits ago =/
2024-06-18 00:01:54 +03:00
Alibek Omarov
9fe58aaabc engine: client: send expected cvar not found string for old protocol cvar query 2024-06-17 23:44:05 +03:00
Alibek Omarov
03c8ea14cc engine: client: mute music if not in focus 2024-06-17 20:32:04 +03:00
Alibek Omarov
260edc2a08 ref: gl: try to match texture slot and texture object handle because of buggy games 2024-06-15 19:21:26 +03:00
Alibek Omarov
b41591a527 ref: gl: decreate alphatest value for lightmapped sprites to make them easier to see
With 0.5 they're too tiny
2024-06-15 19:07:17 +03:00
Alibek Omarov
4e9481451b mainui: update 2024-06-15 17:22:52 +03:00
Alibek Omarov
95b48da37d engine: allow to change hardcoded path to custom.hpk 2024-06-15 17:22:26 +03:00
Alibek Omarov
1b36785177 engine: common: hpak: rename hpk_maxsize to hpak_max_size to avoid Valve's defaults
While we're here:
* Increase it to 64 MiB.
* Make it privileged.
* Add hpk_maxsize stub command as a deprecation notice.
2024-06-15 16:55:25 +03:00
Alibek Omarov
8bc76e3d58 engine: host: do not specifically check timedemo or vsync in Host_CalcSleep, because it's already has been checked in Host_CalcFPS 2024-06-15 13:57:12 +03:00
Alibek Omarov
1a5e2b907d engine: client: minor refactoring for cls.demoplayback check 2024-06-15 13:56:25 +03:00
Alibek Omarov
3717e5c2e0 engine: client: simplify server message parsing by moving common code out of protocol-specific parsing funcs 2024-06-15 13:51:02 +03:00
Alibek Omarov
33a1416199 engine: common: net_chan: remove unneeded check for demo and remote address in netchan, as it's handled in client and server already 2024-06-15 13:44:26 +03:00
Alibek Omarov
ff4221fbe7 engine: client: write correct cls.legacymode/net_protocol value for demos 2024-06-15 13:43:18 +03:00
Alibek Omarov
486bca82e8 engine: add quake svc messages names 2024-06-15 11:04:30 +03:00
Alibek Omarov
611d07fc16 engine: client: redefine legacymode from qboolean to an enum with selected protocol. Remove protocol auto-guess hack, it's useless since connect accept accepts protocol string 2024-06-15 10:52:26 +03:00
Alibek Omarov
f7e12586cf engine: platform: sdl: we must notify the engine about the unpressed button when text input was activated 2024-06-15 08:44:19 +03:00
Alibek Omarov
f62aa051c8 engine: common: make netchan cvars static 2024-06-15 08:44:19 +03:00
Alibek Omarov
2b6b898102 engine: client: make some cvars static 2024-06-15 08:44:19 +03:00
Alibek Omarov
1dd0444531 engine: server: comment out unused cvars, make some static 2024-06-15 08:44:19 +03:00
Alibek Omarov
ba9eb01c1f engine: server: replace timeout cvar by sv_timeout cvar for consistency with GoldSrc 2024-06-15 08:44:19 +03:00
Alibek Omarov
73a8144e75 engine: client: reduce console spam about not precached model to dev level 1 2024-06-15 08:44:18 +03:00
Alibek Omarov
6aef422de6 ref: remove unneeded dlight pointer increment 2024-06-15 08:44:18 +03:00
Alibek Omarov
5f4b8b60cb engine: client: make remote print messages more obvious 2024-06-15 08:44:18 +03:00
Alibek Omarov
3256236ba2 engine: common: mod_studio: reject models with split textures files that cannot be loaded 2024-06-14 11:34:42 +03:00
Alibek Omarov
b102727320 engine: client: try to not save passwords to console history 2024-06-14 11:34:37 +03:00
Alibek Omarov
3434005e66 engine: common: make Host_IsLocalGame and Host_IsLocalClient inlined 2024-06-13 01:20:14 +03:00
Alibek Omarov
b3026a7991 engine: client: don't use CL_Active/CL_GetMaxClients wrappers as they are only intended to be either passed to DLL or used in common/server code 2024-06-13 01:19:38 +03:00
Alibek Omarov
0a051832a8 engine: client: do not mute sounds in menu with multiplayer, the bug already been solved different way 2024-06-13 01:07:49 +03:00
Alibek Omarov
2dbafbda02 engine: common: mod_studio: fix NULL mod->cache.data if model has split texture file but none was loaded 2024-06-12 23:37:30 +03:00
Alibek Omarov
240b6fb6f2 engine: fix possible unprivileged config execute with fake extension 2024-06-12 11:16:31 +03:00
Alibek Omarov
4163d3655a engine: reformat and reorder host_parm_s struct, remove now unused host.daemonize and host.enabledll 2024-06-12 11:16:26 +03:00
Alibek Omarov
2c7bf49fc9 engine: host: avoid some of unnecessary double-to-float conversions 2024-06-12 10:20:09 +03:00
Alibek Omarov
739592e50d engine: host: refactoring, reduce usage of global variables a bit 2024-06-12 10:20:09 +03:00
Alibek Omarov
393e31e509 engine: move finding root/readonly directory to FS initialization, remove unused host.rodir, host.rootidr 2024-06-12 10:20:09 +03:00
Alibek Omarov
a1dceacc8f engine: remove unused host.hMutex and host.hInst 2024-06-12 10:20:09 +03:00
Alibek Omarov
cf26c87872 engine: remove unused host.decalList and host.numdecals 2024-06-12 10:20:09 +03:00
Alibek Omarov
21195b3491 engine: increase logo and hpak limits, add cl_logomaxdim cvar to limit decal size (set to 96, default HL logo size is 64) 2024-06-11 07:47:01 +03:00
Alibek Omarov
3f66f6a6a5 ref: null: update to RefAPI 8 2024-06-11 06:30:17 +03:00
Alibek Omarov
daae4f2f80 engine: ref_api: bump RefAPI to version 8 2024-06-11 06:18:09 +03:00
Alibek Omarov
4e2708c1ac engine: bring back texture replacement 2024-06-11 06:16:26 +03:00
Alibek Omarov
d57d8e0d5d ref: soft: fix R_DrawStretchPic and Draw_Fill with OpenMP enabled 2024-06-11 02:07:49 +03:00
Alibek Omarov
9577a6af21 ref: moved VGUI support API implementation to the engine 2024-06-11 02:07:49 +03:00
Alibek Omarov
107a6aed01 ref: move PARM_SURF_SAMPLESIZE handling to the engine 2024-06-11 02:07:49 +03:00
Alibek Omarov
2c2045d413 ref: move PARM_SKY_SPHERE handling to the engine 2024-06-11 02:07:49 +03:00
Alibek Omarov
30fe471d2b ref: move loading skybox into the engine 2024-06-11 02:07:44 +03:00
Alibek Omarov
5ab6979633 ref: move common quake sky cloud loading to the engine 2024-06-10 22:47:39 +03:00
SNMetamorph
ec5e9cb6e3 engine: client: send engine build information to masterserver 2024-06-10 20:53:59 +03:00
Alibek Omarov
f4b4546197 engine: temporarily fix loading studio models with split texture model 2024-06-10 14:57:00 +03:00
Alibek Omarov
f047749e61 engine: move studio model truncation into separate function, disable it by default 2024-06-10 13:34:02 +03:00
Alibek Omarov
87840ce91d engine: fix potential buffer overflow in Mod_StudioTexName
* Model names are 64 bytes wide, adding texture character means we needs 65 byte wide string.
* It never gets stored in memory anyway.
2024-06-10 13:28:01 +03:00
Alibek Omarov
bf31e9f634 engine: fix NO_ASAN macro usage with MSVC 2024-06-09 09:37:16 +03:00
Alibek Omarov
f86d84daed engine: platform: sdl: initialize window name string when building with old SDL 2024-06-09 09:16:45 +03:00
Alibek Omarov
41ed920d35 common: xash3d_types: fix build 2024-06-09 09:16:07 +03:00
Alibek Omarov
df23ddb545 engine: server: fix signed integer overflow in challenge generator 2024-06-09 07:05:24 +03:00
Alibek Omarov
767556ccad engine: temporarily disable ASan in MSG_WriteUBitLong (evil!) 2024-06-09 07:03:59 +03:00
Alibek Omarov
f9dab2ad19 engine: server: rename sv_allow_upload to sv_allowupload for compatibility 2024-06-09 07:02:50 +03:00
Alibek Omarov
66cb3a6120 engine: client: add room_off variable to toggle sound effects processing for GoldSrc compatibility
* Fixes Sven-Coop 4.8 client.
* Declare dsp_off deprecated.
2024-06-09 03:51:43 +03:00
Tuldok
7672a370da engine: Crashhandler support for Windows-on-ARM (arm/arm64) 2024-06-08 21:35:55 +03:00
Alibek Omarov
870e47ed03 engine: ensure character signness when checking for nonprintable characters 2024-06-07 22:22:13 +03:00
Alibek Omarov
32d4bdb80f engine: fix UTF-8 sequence input
Fixes: 2e0fc3e4c1 ("engine: client: do not repeatedly check cl_charset value, use generic Con_UtfProcessChar")
2024-06-07 22:16:32 +03:00
Alibek Omarov
929dfd2c71 mainui: update 2024-06-03 09:04:47 +03:00
Alibek Omarov
f437af6451 mainui: update 2024-06-03 07:57:10 +03:00
Alibek Omarov
413a0fb2e5 engine: client: improve accumulating rounding error, thanks @SNMetamorph for suggestion 2024-06-02 13:09:10 +03:00
Alibek Omarov
793adadb06 mainui: update 2024-06-02 12:51:30 +03:00
Alibek Omarov
999b43b89f engine: implement changing cursor type in gameui 2024-06-02 12:24:14 +03:00
Alibek Omarov
bd60c88c7d ref: soft: fix build with OpenMP under Visual Studio 2024-06-02 11:39:54 +03:00
Alibek Omarov
23b9a2eddf waf.bat: add checks for newer pythons, remove checks for pythons below 2.7 2024-06-02 11:39:54 +03:00
Alibek Omarov
0b57d97c8c vgui_support: update submodule 2024-06-02 11:35:57 +03:00
Alibek Omarov
6255293dd4 engine: fix using OpenMP PHS generation under Visual Studio 2024-06-02 10:34:10 +03:00
Alibek Omarov
04136d95a3 filesystem: fix build warning 2024-06-02 10:33:33 +03:00
Alibek Omarov
40aa29e42a ci: remove freebsd-13-2 task 2024-06-02 10:04:04 +03:00
Alibek Omarov
a709f30da9 engine: soundlib: libmpg: add wrappers on top of libc read & lseek in case they don't match internal mpg123 types
(we better migrate to upstream libmpg at some point)
2024-06-02 09:19:17 +03:00
Alibek Omarov
0796c14e79 engine: client: fix framerate depending player move 2024-06-02 04:15:17 +03:00
Alibek Omarov
a9c0a4be23 engine: server: add cvar to disable bandwidth test on server side 2024-06-01 05:27:35 +03:00
Alibek Omarov
3e1209d3a4 engine: client: do not rely on host.downloadcount when connecting to the server with HTTP enabled
* Replace cl.downloadUrl by cl.http_download
2024-06-01 04:30:21 +03:00
Alibek Omarov
caf14c1b7c engine: soundlib: libmpg: fix the inconsistent use of offset types in lseek() 2024-05-31 03:35:39 +03:00
Alibek Omarov
27f7d2c8d2 engine: common: ban few more executable types for COM_IsSafeFileToDownload 2024-05-31 00:43:28 +03:00
Alibek Omarov
8ee430eda2 engine: common: double check that resource starting with !MD5 doesn't have any extension 2024-05-31 00:42:44 +03:00
Alibek Omarov
484e4cb225 engine: common: net_ws: less verbose HTTP client, fix printing header size in case of an error 2024-05-31 00:07:14 +03:00
Alibek Omarov
b080ad9954 engine: moved link_t helpers to sv_world.c from world.c and made them static 2024-05-30 07:31:03 +03:00
Alibek Omarov
f6625d9188 engine: common: remove unused et_name array 2024-05-30 07:22:21 +03:00
Alibek Omarov
1eb2816bc4 engine: client: manually call FS_Rescan if we downloaded an archive while connecting to server 2024-05-30 06:48:17 +03:00
Alibek Omarov
077be5aaf3 engine: client: only strip DEFAULT_SOUNDPATH from t_sound resources 2024-05-30 06:47:46 +03:00
Alibek Omarov
d59875f114 engine: common: for automatic wad precache to work, we need to count the real wad usage on dedicated 2024-05-30 06:18:15 +03:00
Alibek Omarov
e89191ed39 engine: common: automatically precache wad files required by loaded map
Makes it easier to host server with multiplayer maps and broken .res files.
2024-05-30 05:58:41 +03:00
Alibek Omarov
ea21438637 engine: netchan: append .ztmp extension instead of replacing original extension
* so we don't send wrong file that has same name but different extension

* validate filename size so it won't get truncated in fragbuf_t
2024-05-30 04:50:58 +03:00
Alibek Omarov
0d2e8333e8 common: remove unused boneinfo.h header 2024-05-29 12:25:23 +03:00
Alibek Omarov
338399e622 engine: common: implement PHS calculation like in QuakeWorld/GoldSrc 2024-05-29 05:58:51 +03:00
Alibek Omarov
27cab8aad5 scripts: waifulib: compiler_optimizations: set HAVE_OPENMP=1 define if openmp feature was enabled during the build 2024-05-29 05:41:47 +03:00
Alibek Omarov
1545a49b4c engine: client: only allocate debug hulls polygons when they're requested
* Make the appropriate changes in ref_gl
2024-05-29 05:41:47 +03:00
Alibek Omarov
3ca15250e8 engine: common: use Mod_PointInLeaf in Mod_GetPVSForPoint instead of traversing nodes manually 2024-05-29 05:41:47 +03:00
Alibek Omarov
6cbac51731 engine: common: add function for compressing visdata 2024-05-29 05:41:47 +03:00
Alibek Omarov
e310c666b1 engine: common: add phs flag to Mod_FatPVS, unused currently 2024-05-29 05:41:47 +03:00
Alibek Omarov
677b0170aa engine: server: remove recalculating viewpoint for PVS hack, as it causes issues with inconsistency between real and "restored" view positions 2024-05-29 05:41:47 +03:00
Alibek Omarov
9150b770e4 engine: common: mod_bmodel: add function Mod_DecompressVisTo that will copy fat vis data into the provided buffer 2024-05-29 05:41:47 +03:00
Alibek Omarov
2ad6511c31 public: add Q_memor routine that binary OR's data from src to dst
Supposed to be compiled with optimizations enabled.
2024-05-29 05:41:33 +03:00
Alibek Omarov
0848f28d83 waf: upgrade to latest master 2024-05-26 19:32:14 +03:00
Alibek Omarov
5d9bc950ce wscript: do not load msvc manually, it will be loaded by compiler_{c,cxx} 2024-05-25 22:40:25 +03:00
Alibek Omarov
714da79395 mainui: update 2024-05-25 22:25:33 +03:00
Alibek Omarov
823fe9ebbd waf: upgrade to waf 2.1.1/waifu 1.3.0. Try to fix most optparse->argparse migration issues 2024-05-25 04:58:28 +03:00
Alibek Omarov
4bf72b5383 engine: forbid accessing cvars starting with con_ and scr_ through stufftext
Some stupid servers might mess up with console cvars values.
2024-05-25 02:26:42 +03:00
Alibek Omarov
51945f002b engine: server: check for invoker entity when filtering out host client during entities thinking 2024-05-23 02:06:54 +03:00
Alibek Omarov
bcca9387de engine: server: sv_pmove: always set FEV_NOTHOST for events coming from PMove (like GoldSrc) 2024-05-23 01:51:42 +03:00
Alibek Omarov
b8417fa46d ref: soft: search parent in both entity lists when drawing MOVETYPE_FOLLOW entities
Fixes the issue in Brutal Half-Life beta 2 with invisible scientist skin.

Fixes: 6862b14e59 ("ref: soft: only draw MOVETYPE_FOLLOW studio model if it's parent is visible")
2024-05-19 06:31:46 +03:00
Alibek Omarov
85b0699288 ref: gl: search parent in both entity lists when drawing MOVETYPE_FOLLOW entities
Fixes the issue in Brutal Half-Life beta 2 with invisible scientist skin.

Fixes: dc1d65f621 ("ref: gl: only draw MOVETYPE_FOLLOW studio model if it's parent is visible")
2024-05-19 06:29:22 +03:00
Alibek Omarov
6c03fb0226 engine: client: first attempt to use utflib to replace Con_UtfProcessCharForce calls 2024-05-15 05:25:53 +03:00
Alibek Omarov
a084dea07c public: add functions to convert from Unicode codepoints into CP1251 or CP1252 2024-05-15 05:07:18 +03:00
Alibek Omarov
2e0fc3e4c1 engine: client: do not repeatedly check cl_charset value, use generic Con_UtfProcessChar 2024-05-15 05:06:57 +03:00
Alibek Omarov
24f4d410ce filesystem: take FS_Read improvements from DarkPlaces and proper fix for buffer overflow 2024-05-15 03:43:02 +03:00
Alibek Omarov
052e0445ab engine: client: console: cleanup input buffer from line feed characters before pushing it to the console history 2024-05-15 03:08:22 +03:00
Alibek Omarov
758c908d5a public: add buffer size parameter to COM_RemoveLineFeed 2024-05-15 03:06:57 +03:00
Alibek Omarov
3917c2589d filesystem: fix buffer overflow in FS_Read when we pass single byte buffer to it with one character sitting in ungetc 2024-05-15 02:45:01 +03:00
Alibek Omarov
f4a77308ec engine: soundlib: fix possible buffer overflow in Sound_ConvertUpsample 2024-05-06 15:45:49 +03:00
Alibek Omarov
103b9724f9 scripts: waifulib: compiler_optimizations: fix linking OpenMP 2024-05-06 15:36:26 +03:00
Alibek Omarov
75a315ecf0 engine: client: add optional (compile time for now) setting to reconfigure engine to use 48kHz sounds 2024-05-06 15:10:34 +03:00
Alibek Omarov
63b3b9ef6d engine: client: fix missing upsampling for >32kHz sounds 2024-05-06 15:09:52 +03:00
Alibek Omarov
a6c2cfe89b engine: avoid constants in Q_strncpy third argument, where possible 2024-05-06 14:27:26 +03:00
Alibek Omarov
5120657386 engine: fix possible buffer overflow in S_StreamGetCurrentState 2024-05-06 06:53:22 +03:00
Alibek Omarov
e754de46d1 engine: client: fix buffer overflow in S_FindName 2024-05-06 06:42:47 +03:00
Alibek Omarov
5d718aa0d6 scripts: waifulib: compiler_optimizations: add flag for building with OpenMP (not used anywhere in the engine but let's keep it) 2024-05-06 06:42:15 +03:00
Alibek Omarov
55fcbc8880 engine: soundlib: implement linear interpolation in Sound_ResampleInternal
* split resampling into three functions
* added resampling using SDL_AudioCVT, it's slow, so isn't enabled by default
2024-05-06 06:41:23 +03:00
Alibek Omarov
e19aa001b2 engine: client: ref_common: slight refactoring, reorder ref_state_t 2024-05-06 01:59:50 +03:00
Alibek Omarov
b447ea9c18 engine: client: remove unused fields in client_static_t 2024-05-06 01:59:14 +03:00
Alibek Omarov
13274655d4 engine: client: sound: slight refactoring, removed unused s_listener.velocity 2024-05-06 01:30:06 +03:00
Alibek Omarov
3723ac60ef engine: client: s_mix: _inline -> static 2024-05-06 00:51:32 +03:00
Alibek Omarov
da578f47f1 engine: client: fix sounds being paused in menu and then blasted all at the same time in multiplayer 2024-05-06 00:41:38 +03:00
Alibek Omarov
433e7de686 engine: clean up unused soundlib flags, set SOUND_LOOPED flag on looped sounds 2024-05-05 06:16:57 +03:00
Alibek Omarov
e18e9ae2ea engine: platform: sdl: ignore keyboard events if text mode is active 2024-05-04 11:05:17 +03:00
Alibek Omarov
27d5123a61 mainui: update 2024-05-03 16:55:17 +03:00
Alibek Omarov
89b9f9ffe2 github: update SDL to 2.30.3 2024-05-03 16:04:13 +03:00
Alibek Omarov
a17b8aaa13 public: fix parameter name omitted error for older compilers 2024-05-03 16:01:24 +03:00
Alibek Omarov
e210969612 scripts: gha: build_linux: spew config.log on build failure 2024-05-03 15:57:26 +03:00
Alibek Omarov
1208356b92 ref: gl: gl2_shim: remove unused ALLOCA_H include 2024-05-03 15:53:57 +03:00
Alibek Omarov
d7cd74fe2f wscript: no need to pass PACKAGING into env 2024-05-03 15:45:20 +03:00
Alibek Omarov
31b63e9939 wscript: exclude executing large file test for PSVita 2024-05-03 15:44:35 +03:00
Alibek Omarov
b99c2c2df1 wscript: do not execute test for test for large files 2024-05-03 15:38:35 +03:00
Alibek Omarov
94d3eff9ce engine: host: fix build with Q_strchrnul returning const char * 2024-05-03 15:31:20 +03:00
Alibek Omarov
b78e9961c6 public: fix build on Windows
stristr doesn't exist actually
2024-05-03 15:30:42 +03:00
Alibek Omarov
b0704ca5d6 mainui: update 2024-05-03 06:38:21 +03:00
Alibek Omarov
31c0934108 engine: fix parsing -bugcomp flags, assume bugcomp flags only starts with alphabetic character 2024-05-03 06:28:48 +03:00
Alibek Omarov
37083c8aef ref: soft: mark sw_drawflat and sw_draworder as cheats 2024-05-01 00:52:45 +03:00
Alibek Omarov
af23b0c67b public: crtlib: refactoring with new macros, use system strlcpy/strlcat if possible 2024-04-30 02:20:14 +03:00
Alibek Omarov
a9e83fb9cf wscript: move std defining macros into libpublic's sdk_includes target, so we don't accidentally feed submodules our macros 2024-04-29 05:29:53 +03:00
Alibek Omarov
51126e1691 mainui: update 2024-04-29 05:28:41 +03:00
Alibek Omarov
dd410a2de5 engine: implement small Message Rewrite Facitility that allows to run mods that directly write internal GoldSrc messages 2024-04-28 06:59:18 +03:00
Alibek Omarov
7ccb0b5c02 public: make simple ctype functions inlined 2024-04-28 06:59:18 +03:00
Alibek Omarov
7f3e62e456 public: remove unneeded copy in Q_atov 2024-04-28 06:59:18 +03:00
Alibek Omarov
fcfc29d7ea public: fix variables types in COM_HashKey, they are all supposed to be unsigned integers 2024-04-28 06:59:18 +03:00
Alibek Omarov
2f3429a144 engine: common: base_cmd: use flexible array to store basecmd name 2024-04-28 06:59:18 +03:00
Alibek Omarov
20782693f4 engine: server: rename symbols for svs, sv and SV_DropClient to avoid AMXModX trying to acquire their pointers 2024-04-28 06:59:18 +03:00
Alibek Omarov
0cfb354374 common: add RENAME_SYMBOL macro that renames symbol for compatibility with nasty mods (also reformat this portion, while we're at it) 2024-04-28 06:59:18 +03:00
Alibek Omarov
9be5b7c6c9 engine: physint: empty-define ALLOC_CHECK if not defined by SDK, so this header can be freely moved to another SDK 2024-04-28 06:59:18 +03:00
Alibek Omarov
e7653d2ea6 engine: soundlib: fix searching for a RIFF/WAVE chunks in streams 2024-04-27 10:51:56 +03:00
Alibek Omarov
1494887e29 engine: soundlib: snd_wav: replace strncmp by IsFourCC helper function 2024-04-26 06:29:38 +03:00
Alibek Omarov
42dab2b1a5 engine: soundlib: snd_wav: attempt to fix misleading warning about truncated file 2024-04-26 06:25:18 +03:00
Alibek Omarov
36a0c1fb17 ref: if the entity is opaque, check the renderfx too, it might become translucent 2024-04-26 04:15:21 +03:00
Alibek Omarov
60c6767337 filesystem: copy absolute path to library in FS_FindLibrary for compatibility
Extend fullPath for longer absolute paths.
2024-04-22 04:02:46 +03:00
Alibek Omarov
75451cc7fa engine: client: print correct message names in legacymode 2024-04-22 04:02:46 +03:00
Alibek Omarov
db10035d9d engine: add GoldSrc protocol definitions 2024-04-22 04:02:46 +03:00
Alibek Omarov
de21d845ec engine: don't forget to put newline at the end of overflowed console message 2024-04-21 20:21:17 +03:00
Alibek Omarov
320f8466e6 engine: hpak: don't print error about missing custom.hpak in quiet mode 2024-04-21 20:05:37 +03:00
Alibek Omarov
f3208e95b2 engine: server: remove misleading message about interface version in case when GetEntityAPI2 has failed
Add message when GetEntityAPI was used instead
2024-04-21 20:05:34 +03:00
Alibek Omarov
ea34bc8652 engine: turn bugcomp into flags that can be enabled/disabled separately 2024-04-21 16:52:15 +03:00
Alibek Omarov
3daf014af8 wscript: always enable -Werror=implicit-function-declaration 2024-04-20 20:48:01 +03:00
Alibek Omarov
ca9d3d262a engine: common: net_encode: directly call MSG_ReadSBitLong for DT_TIMEWINDOW_*, don't do the multiplier check for DT_TIMEWINDOW_BIG 2024-04-20 20:48:01 +03:00
Alibek Omarov
a08f5e439d engine: common: net_encode: fix comparing DT_TIMEWINDOW_* fields
Fixes: 35783bcec2 ("engine: common: net_encode: fix inaccuracy in DT_TIMEWINDOW_* encoding")
2024-04-19 01:51:25 +03:00
Alibek Omarov
8f6771dff4 engine: common: zone: check that Mem_FindPool might return NULL (it can if Sys_Error was called inside of a Sys_Error) 2024-04-19 00:14:26 +03:00
Alibek Omarov
cd47c6b5b3 engine: common: zone: disallow migrating allocations from one pool to another, as this isn't practically used anywhere 2024-04-19 00:14:26 +03:00
Alibek Omarov
1f4f3d7fda engine: common: zone: remove mempool sentinels as pools aren't subject to buffer overflow or double free anymore 2024-04-19 00:14:26 +03:00
Alibek Omarov
e81b5144b3 engine: common: zone: use realloc for managing mem pools
rearrange data in memheader_s to avoid unnecessary paddings
2024-04-19 00:14:26 +03:00
Alibek Omarov
9ec1caed53 engine: common: zone: implement dummy Q_realloc for XASH_CUSTOM_SWAP 2024-04-19 00:14:26 +03:00
Alibek Omarov
ca3b4a9d7f engine: host: oops 2024-04-18 16:48:41 +03:00
Alibek Omarov
87ac217887 engine: common: net_encode: add bitmask operation to delta tests 2024-04-18 16:44:15 +03:00
Alibek Omarov
213650db8f engine: exit with non-zero return code if engine tests are failed 2024-04-18 16:36:18 +03:00
Alibek Omarov
ac46164a6e engine: common: net_encode: implement basic delta tests 2024-04-17 20:27:22 +03:00
Alibek Omarov
6d12d84e94 engine: common: net_encode: apply post_multiplier to integer fields, like GoldSrc does 2024-04-17 06:23:22 +03:00
Alibek Omarov
2a18cde60c engine: common: net_encode: fix applying integer clamp before multiplier
Without this fix, data still might overflow after applying multiplier
and potentially send incorrect data.
2024-04-17 06:16:44 +03:00
Alibek Omarov
35783bcec2 engine: common: net_encode: fix inaccuracy in DT_TIMEWINDOW_* encoding
By avoiding double rounding, we get more accurate time on client when timebase
gets rounded down and target time gets rounded up:

```
>>> round(123.1) - round(124.51)
-2
>>> round(123.1 - 124.51)
-1
```
2024-04-17 06:09:52 +03:00
Alibek Omarov
1677835b45 engine: common: simplify bit buffer operations
Yields a small performance boost
2024-04-08 07:24:53 +03:00
Alibek Omarov
2f2780cb1b ref: null: fix crashes 2024-04-08 07:23:56 +03:00
Alibek Omarov
95b134b5a6 ci: fix cirrus CI configuration file 2024-04-06 06:58:15 +03:00
Alibek Omarov
f60e856f35 engine: server: replace useless call to SV_Serverinfo to a direct access 2024-04-06 06:58:15 +03:00
Alibek Omarov
2ec0d25d85 Documentation: add note about environment variables 2024-04-05 20:15:38 +03:00
Alibek Omarov
fcd0982524 engine: server: free 64-bit string pool last when unloading library 2024-04-05 19:45:24 +03:00
Alibek Omarov
6881ee742d engine: server: fix incorrect NULL check in pfnCvar_RegisterServerVariable 2024-04-05 18:45:15 +03:00
Alibek Omarov
f070bbef3c engine: server: make EDICT_NUM inlined 2024-04-04 20:42:25 +03:00
Alibek Omarov
dd8c66d90e engine: common: fix possible NULL dereference in LZSS_Compress 2024-04-04 20:42:25 +03:00
Alibek Omarov
f995d055b5 filesystem: fix possible NULL dereference 2024-04-04 20:42:25 +03:00
Alibek Omarov
fed65dd497 engine: imagelib: fix possible NULL dereference 2024-04-04 20:42:25 +03:00
Alibek Omarov
c896425ad9 engine: server: make changelevel commands compatible with GoldSrc 2024-04-04 00:21:28 +03:00
Alibek Omarov
4107bd4e0f engine: common: quickly assume that map is valid when generating maps.lst if mpfilter is set or game is multiplayer only 2024-04-03 06:13:43 +03:00
Alibek Omarov
156b2b2b10 engine: server: remove MAP_HAS_SPAWNPOINT checks 2024-04-03 05:52:42 +03:00
Alibek Omarov
13a063bf7d mainui: update 2024-04-02 04:05:49 +03:00
Alibek Omarov
ef786b7d79 engine: client: fix sprites transparency in Night at the Office 2024-04-02 02:18:49 +03:00
Alibek Omarov
5c0c1b1226 ref: gl: make g_posenum in alias renderer static 2024-03-30 03:52:50 +03:00
Alibek Omarov
d041b2aa27 engine: fix error_on_exit data type 2024-03-26 17:15:34 +03:00
Alibek Omarov
f6d489e038 engine: server: register str64stats command that prints string pool usage statistics 2024-03-26 17:15:15 +03:00
Alibek Omarov
d34fedea69 engine: server: cleanup unused variables 2024-03-25 05:50:04 +03:00
Alibek Omarov
80b3f90091 engine: server: more accurate SV_ParseEdict
* Add removing trailing spaces, like GoldSrc does
* Pass classname first to allow game to override it
* Remove FL_CUSTOMENTITY flag usage, GoldSrc doesn't set this flag for "custom"
  export entities
* Fix possible memory leak
2024-03-25 05:49:59 +03:00
SNMetamorph
2a4fafc3f9 engine: voice: added voice_transmit_scale cvar to configure outcoming voice audio volume 2024-03-23 23:37:03 +03:00
SNMetamorph
9b3ccf5f04 engine: voice: output_buffer renamed to compress_buffer 2024-03-23 23:37:03 +03:00
SNMetamorph
f59ac2360a engine: voice: made voice_scale to influence incoming voice audio volume 2024-03-23 23:37:03 +03:00
Alibek Omarov
ff21fb42e6 engine: client: create separate Opus decoders for each player
Turns out, we can't re-use same decoder for different streams.
2024-03-20 18:41:52 +03:00
Alibek Omarov
288cac69de public: add small utility library for unicode stuff 2024-03-19 21:34:18 +03:00
Alibek Omarov
2640b6d869 engine: host: remove misleading message about TAB-autocompletion in dedicated mode 2024-03-19 21:24:21 +03:00
Alibek Omarov
d8910b0e38 engine: platform: linux: do not search sd_notify if NOTIFY_SOCKET isn't set 2024-03-19 21:23:53 +03:00
Alibek Omarov
049bed555e engine: host: fit -help into 80 columns terminal 2024-03-19 21:13:28 +03:00
Alibek Omarov
fe5944720b engine: use common strings to name the engine, makes branding easier for custom forks 2024-03-19 21:11:10 +03:00
Alibek Omarov
665c46b281 filesystem: minor logging opened archives change 2024-03-19 20:42:10 +03:00
Alibek Omarov
975ab6785e engine: make log starting and ending messages shorter, so it fits into standard 80 columns term 2024-03-19 20:41:46 +03:00
Alibek Omarov
6fa4dbfba2 public: build: use XASH_BUILD_BRANCH define set by Waf. Expect XASH_BUILD_{BRANCH,COMMIT} to be always set. 2024-03-19 19:34:30 +03:00
SNMetamorph
0506a1dfce engine: sys_con: added VCS branch name printing to log file header 2024-03-19 19:31:54 +03:00
SNMetamorph
908a9930e6 public: added Q_buildbranch function, needed for better logging 2024-03-19 19:31:54 +03:00
SNMetamorph
7d7e72196b engine: host: enabled printing current developer level 2024-03-19 19:31:54 +03:00
SNMetamorph
7cc67157e5 engine: sys_con: fixed incorrect logging init messages order 2024-03-19 19:31:54 +03:00
SNMetamorph
b7ff9c7a24 engine: sys_con: added missing title for log messages 2024-03-19 19:31:54 +03:00
Alibek Omarov
aab1fa1ba2 wscript: move gitversion load to libpublic, define XASH_BUILD_BRANCH, use unknown-{commit,branch} if detecting git version was failed 2024-03-19 19:30:52 +03:00
Alibek Omarov
effeba2f44 waf: upgrade to waifu 1.2.0 2024-03-19 19:24:49 +03:00
Alibek Omarov
e039ef35c0 filesystem: don't check for SDL whether we can load Android assets, because filesystem doesn't know anything about SDL
Replace it with runtime check instead.
2024-03-11 23:25:10 +03:00
Alibek Omarov
599a1f026e engine: client: fix missing comma 2024-03-11 22:56:52 +03:00
Alibek Omarov
39cba17f01 filesystem: android: try to fix compiling-in AAsset mounting code 2024-03-11 21:49:33 +03:00
SNMetamorph
17e106f96d ref: gl: invalidate texture units state cache when texture deletes 2024-03-09 22:12:35 +03:00
Alibek Omarov
081cf9132b engine: client: read console_history.txt as binary, skip empty and repeating lines, reimplement it through FS_Gets for fun 2024-03-08 15:25:36 +03:00
Alibek Omarov
6a7e027248 engine: common: add joy_ prefix to automatically filterable cvars 2024-03-08 15:25:36 +03:00
Alibek Omarov
27100e7751 engine: client: hook sensitivity cvar registration and make it priveleged cvar 2024-03-08 15:25:36 +03:00
Alibek Omarov
75d9ed341a Create FUNDING.yml 2024-03-07 09:41:18 +03:00
Alibek Omarov
1a0867523d engine: system: parent messagebox to main window when dealing with Sys_Error 2024-03-05 17:12:51 +03:00
Alibek Omarov
7584bbe47e engine: client: fix sound mute when losing focus 2024-03-03 19:00:50 +03:00
Andrey Akhmichin
505b6cc264 utils: mdldec: boneweights fix. 2024-03-01 20:26:18 +03:00
Alibek Omarov
24f23908be engine: platform: stub Sys_DebuggerPresent on unsupported platforms 2024-02-27 05:17:01 +03:00
Alibek Omarov
43bd73f37b engine: platform: that's why commit --amend and/or rebase --interactive your fixes in your patches before proposing them 2024-02-27 04:59:54 +03:00
mittorn
bb2753cbfc engine/system: add asm-based raise implementation for arm and aarch64, making Sys_DebugBreak more relevant, use tgkill instead of kill 2024-02-27 04:54:55 +03:00
mittorn
5568eccc8a ref/r_sprite: move dframetype to inner block 2024-02-27 04:17:21 +03:00
mittorn
c3b2cc4423 waifulib/compiler_optimizations: disable no-semantic-interposition for gcc4 in release builds too 2024-02-27 04:16:14 +03:00
mittorn
d84130219f crashhandler: set host.crashed before messagebox to allow platform code handle crashed state in different way 2024-02-27 04:14:37 +03:00
mittorn
d97d4d6c42 filesystem: add XASH_ANDROID_ASSETS macro for aassets switch 2024-02-27 04:04:54 +03:00
mittorn
15798aaf52 ref/r_sprite: move dframetype to inner block 2024-02-27 04:04:54 +03:00
mittorn
e53892e827 ref_gl: fix loop scope in ripple code 2024-02-27 04:04:54 +03:00
mittorn
cb12af69ed gl2shim: add SOFTFP_LINK support for gles3compat 2024-02-27 04:04:54 +03:00
mittorn
e82050a4bc gl2shim: fix gcc 4.9 build 2024-02-27 04:04:54 +03:00
mittorn
e4edd2da45 platform/posix: check for non-zero dladdr ret 2024-02-27 04:04:54 +03:00
mittorn
4f80922358 waf/compiler_optimizations: remove no-semantic-interposition for gcc4 2024-02-27 04:04:54 +03:00
mittorn
ae7ed03376 ref_soft: fix crash when y < -height 2024-02-27 04:04:54 +03:00
mittorn
c082e46662 imagelib: fix for loop scope 2024-02-27 04:04:54 +03:00
mittorn
b0bbcab6b4 ref_soft,ref_gl: fix unaligned read in sprite code 2024-02-27 04:04:54 +03:00
SNMetamorph
0fc83080ec engine: server: allowed bandwidth test on listen servers 2024-02-26 19:41:32 +03:00
SNMetamorph
73883b504f engine: client: improved bandwidth test logic 2024-02-26 19:41:32 +03:00
SNMetamorph
8efc9d74e8 engine: server: fixed test packet buffer was not being created 2024-02-26 19:41:32 +03:00
mittorn
373321ff00 ref/gl: do not set type on 1D textures on GLES (will fallback to 2D) 2024-02-26 16:08:37 +03:00
Alibek Omarov
a508467aac engine: client: silently ignore if server didn't sent local player info in delta at spawn
The bug happens somewhere in server, not sure where or how. Remove Host_Error so mods
can be played again.
2024-02-26 11:48:46 +03:00
Alibek Omarov
abbe993e80 3rdparty: gl4es: update 2024-02-26 11:20:04 +03:00
Alibek Omarov
c644e4d569 3rdparty: nanogl: update, fix link error with missing glTexEnvfv 2024-02-26 11:06:09 +03:00
Alibek Omarov
c200e008f1 wscript: disable gl-wes-v2 renderer from Android builds 2024-02-26 10:55:42 +03:00
Alibek Omarov
e95a2da6d0 engine: platform: sdl: slightly rework previous patch to not call SDL each frame and check for NULL pointers 2024-02-23 20:55:32 +03:00
Alibek Omarov
8afca1a79c engine: server: allow starting game from custom map 2024-02-23 20:54:32 +03:00
Alibek Omarov
827c9ca857 filesystem: restore original Xash behavior with unreferenced keys in gameinfo.txt/liblist.gam 2024-02-23 20:54:32 +03:00
Alibek Omarov
2416635ba3 common: validate extended surfaces size 2024-02-23 20:54:32 +03:00
Alibek Omarov
39eec89580 engine: increase elights limit up to 128 2024-02-23 20:54:32 +03:00
Sheridan Kane Rathbun
98d88266a6 engine: platform: sdl: fix incorrect mouse cursor positioning on high-dpi displays (#1623)
Signed-off-by: SheridanR <sheridan.rathbun@gmail.com>
2024-02-23 20:54:17 +03:00
mittorn
0f3359fc05 ref_gl: do not apply overbright color if lightscale correction used 2024-02-22 21:02:34 +03:00
mittorn
6c77608c34 ref_gl: implement color-modulate overbrigths with gl_vbo using texture GL_COMBINE 2024-02-22 21:02:34 +03:00
Alibek Omarov
abdff6eff6 mainui: update 2024-02-22 15:43:49 +03:00
Alibek Omarov
95a75465c9 common: remove FORCEINLINE and NOINLINE macros, we don't use them in engine 2024-02-22 15:43:37 +03:00
Alibek Omarov
119926805f mainui: update 2024-02-21 03:39:11 +03:00
Alibek Omarov
f749b5cb4b 3rdparty: nanogl: update 2024-02-21 02:57:18 +03:00
Alibek Omarov
c29ad6b598 scripts: waifulib: compiler_optimizations: add option to use profiling 2024-02-21 02:57:07 +03:00
Alibek Omarov
4c5dfb963e engine: zone: few more tunings for realloc 2024-02-21 00:59:02 +03:00
Alibek Omarov
e11f9e05d4 engine: server: add GetNativeObject to server's PhysicsAPI 2024-02-19 17:49:37 +03:00
Alibek Omarov
5c8b5b3511 Documentation: extensions: add doc about native-object 2024-02-19 17:49:37 +03:00
Alibek Omarov
2ea7162287 engine: gameui: add GetNativeObject to extended menu API 2024-02-19 17:49:37 +03:00
Alibek Omarov
e62ab51842 engine: platforms: android: platforms aren't expected to get NULL or zero sized native object names anymore 2024-02-19 17:49:37 +03:00
Bohdan Shulyar
f1bc9b87b1 platform: android: port to SDL 2024-02-19 17:47:40 +03:00
Alibek Omarov
a9bddaac64 engine: platform: win32: do not call filesystem functions if filesystem_stdio was failed to load 2024-02-19 06:27:24 +03:00
Alibek Omarov
6cef6f6a75 engine: zone: refactoring 2024-02-19 06:13:54 +03:00
Alibek Omarov
25ea6ed500 scripts: waifulib: don't use relative path while creating ZIP file (so cwd might not be equal to sources path) 2024-02-19 05:00:12 +03:00
Alibek Omarov
3d5173f257 engine: zone: implement Mem_Realloc through standard realloc 2024-02-19 04:22:16 +03:00
Alibek Omarov
05ff0d6020 engine: cmd: remove unused global variable 2024-02-17 22:17:22 +03:00
Alibek Omarov
3cea12627e engine: client: add cl_trace_stufftext from old engine 2024-02-17 22:16:39 +03:00
Alibek Omarov
b59b7c1a8d engine: server: better error message for missing spawn functions 2024-02-17 22:15:41 +03:00
Alibek Omarov
dd2c369df3 engine: imagelib: fix integer overflow on huge images when calculating reflectivity 2024-02-17 22:14:27 +03:00
Andrey Akhmichin
8b79e49a0f engine: server: execute maps/<mapname>_unload.cfg on server deactivation. 2024-02-16 17:57:26 +03:00
Andrey Akhmichin
4ea6eba8f2 engine: server: execute maps/<mapname>_load.cfg before entities precaching. 2024-02-16 17:57:26 +03:00
Andrey Akhmichin
f649076bc3 engine: server: execute map change config file before entities precaching. 2024-02-16 17:57:26 +03:00
Andrey Akhmichin
8ecffa4663 engine: server: define new "disconcfgfile" cvar. 2024-02-16 17:57:26 +03:00
Andrey Akhmichin
e90b83849a engine: server: execute map change config file in singleplayer. 2024-02-16 17:57:26 +03:00
Andrey Akhmichin
d517b9717a engine: server: define new "_sv_override_scientist_mdl" cvar for Uplink's scientist model. 2024-02-16 17:57:26 +03:00
Alibek Omarov
2c0d6e06be engine: server: return NULL in SV_ClientBy{Id,Name} if client array isn't allocated 2024-02-15 13:56:47 +03:00
Alibek Omarov
dec71850a1 engine: console: allow changing background filtering 2024-02-13 15:34:33 +03:00
Alibek Omarov
b1860972c6 engine: font: fix inverted check, fix potential division by zero 2024-02-13 15:33:51 +03:00
Alibek Omarov
1f4c9b67da engine: server: don't init or send voice chat in singleplayer 2024-02-13 15:09:26 +03:00
Alibek Omarov
c2da125358 engine: client: as an experiment, let users override default font rendermode through hud_fontrender and con_fontrender cvars 2024-02-09 07:25:47 +03:00
Alibek Omarov
31fa990d44 engine: gamma: fix gamma changes not caught if gamma cvar was set during frame 2024-02-09 06:29:30 +03:00
Alibek Omarov
d3e60c7d84 engine: gamma: higher brightness limit for compatibility 2024-02-09 06:28:31 +03:00
Alibek Omarov
e2424b4303 engine: server: clean up userinfo and fullupdate throttle on client connect 2024-02-07 23:27:02 +03:00
Alibek Omarov
240563cd1b engine: client: set r_lighting_modulate to 0.6 and save it to config for old Xash mods that use it internally 2024-02-07 23:22:27 +03:00
Alibek Omarov
d708cd58fb mainui: update 2024-02-07 23:22:27 +03:00
Alibek Omarov
491b503f96 engine: common: optimize COM_LoadFile/COM_LoadFileForMe removing double allocation 2024-02-07 23:22:27 +03:00
Alibek Omarov
636a2228f6 filesystem: add new API function LoadFileMalloc that returns a pointer that can be freed using standard free() 2024-02-07 23:22:27 +03:00
Alibek Omarov
bb03e2597c filesystem: allow to pass custom allocation functions to LoadFile 2024-02-07 23:22:27 +03:00
Alibek Omarov
21c828ee40 engine: sounds: remove extra logging 2024-02-05 15:57:59 +03:00
Alibek Omarov
132c9de142 engine: host: add the most important command line flag help string 2024-02-05 15:28:18 +03:00
Alibek Omarov
9d9507d77f engine: change mobility API license to Unlicense, as with build.h
See GitHub issue: https://github.com/FWGS/hlsdk-portable/issues/259

Signed-off-by: Alibek Omarov <a1ba.omarov@gmail.com>
2024-02-05 15:01:03 +03:00
Alibek Omarov
7daa6c3451 engine: server: use soundlist to acquire random sounds for physics 2024-02-05 12:49:31 +03:00
Alibek Omarov
c8e1ffe0dd engine: client: use soundlist to acquire random sounds for temp entities 2024-02-05 12:49:31 +03:00
Alibek Omarov
b5f02324a6 engine: add basic sounds.lst implementation 2024-02-05 12:49:27 +03:00
Alibek Omarov
47f5dfdcfd common: define macros for color codes for easier access 2024-02-05 12:49:27 +03:00
Alibek Omarov
33da68b013 engine: client: move reseting gamma changed flag to the end of the frame for custom renderers 2024-02-05 03:41:15 +03:00
Alibek Omarov
618ec83c9d engine: client: don't trigger CheckGamma if there is no screenshot action 2024-02-05 03:40:14 +03:00
Alibek Omarov
85de61ebc8 engine: client: fix userid not being written to player info on userinfo change 2024-02-05 02:58:46 +03:00
Alibek Omarov
2feaae59f7 engine: client: bring back r_lighting_modulate, as a compatibility cvar 2024-02-02 13:52:17 +03:00
Alibek Omarov
2550d7fbd3 public: tests: remove linuxunkabi remnants 2024-02-01 02:54:22 +03:00
Alibek Omarov
565f717804 ref: add ref_null renderer that does nothing
This was sitting in my git stash for months. Let's publish it now.
2024-02-01 02:45:19 +03:00
Alibek Omarov
b56c83a2f9 Documentation: add a note about musl 2024-01-31 23:59:28 +03:00
Alibek Omarov
bf17996f72 public: remove linuxunkabi 2024-01-31 23:59:28 +03:00
Alibek Omarov
a3acb1c85b engine: gamma: validate gamma cvars in local games too 2024-01-30 17:55:36 +03:00
Alibek Omarov
d4d63301e0 mainui: update 2024-01-30 17:50:31 +03:00
Alibek Omarov
e9af0c9810 ref: gl: wscript: remove all libs dependencies from gles3compat, added by mistake 2024-01-30 17:40:59 +03:00
Alibek Omarov
131ad9c790 3rdparty: update submodules 2024-01-30 17:28:12 +03:00
Alibek Omarov
bfcaba54dc wscript: move werror flags into uselib 2024-01-30 17:24:17 +03:00
Alibek Omarov
f67736180b engine: client: allow nearest filtering for loading and pause icons 2024-01-29 05:59:29 +03:00
Alibek Omarov
725b7ea7f9 common: render_api: rename TF_ALLOW_NEAREST_TOGGLE to just TF_ALLOW_NEAREST, it's just shorter 2024-01-29 05:59:06 +03:00
Alibek Omarov
600d574376 ref: gl: make use of new TF_ALLOW_NEAREST_TOGGLE flag 2024-01-29 05:50:59 +03:00
Alibek Omarov
04f42df7d5 common: render_api: new flag TF_ALLOW_NEAREST_TOGGLE that allows toggling nearest filtering for TF_NOMIPMAP textures 2024-01-29 05:48:42 +03:00
Alibek Omarov
ab15662d78 ref: gl: fix toggling nearest filter on TF_NOMIPMAP textures 2024-01-29 05:48:08 +03:00
Alibek Omarov
072b0cef27 ref: gl: small refactoring on filter choosing for newly uploaded texture 2024-01-29 05:47:10 +03:00
Alibek Omarov
e274c62cfc ref: gl: use TextureFilteringEnabled to decide whether texture will have nearest filtering or linear 2024-01-29 05:44:14 +03:00
Alibek Omarov
a28d45fdb2 engine: console: fix TF_NEAREST missing from quake fixed font 2024-01-29 05:42:22 +03:00
Alibek Omarov
6ca5f7c6fb engine: client: request if font texture has nearest filtering from the renderer 2024-01-29 05:41:16 +03:00
Alibek Omarov
af316bff14 engine: client: add hud_scale_minimal_width to limit scaling factor and potentially avoid unsupported hud sprites resolutions 2024-01-29 04:58:07 +03:00
Alibek Omarov
c8945caefc engine: net_buffer: remove unused MSG_SeekToByte 2024-01-28 20:01:29 +03:00
Alibek Omarov
8c61a2f021 engine: server: cleanup server.h header from unused functions prototypes 2024-01-28 11:35:53 +03:00
Alibek Omarov
0b24810927 engine: client: clean up client.h from unused function prototypes, or move them to appropriate C file 2024-01-28 11:17:06 +03:00
Alibek Omarov
b3d8fb03bf engine: client: add generic handler for simple types of screenshots commands 2024-01-28 10:43:37 +03:00
Alibek Omarov
02c5890c2f ref: soft: cleanup after RefAPI changes, remove unused functions 2024-01-28 10:00:51 +03:00
Alibek Omarov
0579e40857 engine: server: remove unused DumpHashString function 2024-01-28 10:00:51 +03:00
Alibek Omarov
c77f290bc6 engine: remove Netsplit_SendLong, as we're not planning to support old protocol on server side 2024-01-28 10:00:51 +03:00
Alibek Omarov
7bf9407177 ref: gl: remove R_TextureRandomTiling, it's handled by R_TextureAnimation (random tiling as a feature still broken) 2024-01-28 10:00:51 +03:00
Alibek Omarov
b41fe076ae engine: server: exclude expired IP filters from check 2024-01-28 10:00:51 +03:00
Alibek Omarov
a7c422fde6 engine: platform: make Platform_SetTimer static inline to not fix unused-function 2024-01-28 10:00:51 +03:00
Alibek Omarov
568a394a40 wscript: enable -Wunused-functions 2024-01-28 10:00:51 +03:00
Alibek Omarov
2b6a550405 engine: clean up common.h header from unused function prototypes, or move them to appropriate header or C file 2024-01-28 10:00:17 +03:00
Alibek Omarov
7200f0da7e 3rdparty: gl-wes-v2: update 2024-01-28 09:55:18 +03:00
Alibek Omarov
d3c3c26618 ref: gl: vgl_shim: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
7152393089 ref: soft: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
661e60720d ref: gl: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
bf959da7ff engine: libmpg: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
75d476f9df engine: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
b077822f4d filesystem: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
6d3f188675 public: fix -Wmissing-prototypes 2024-01-28 09:55:18 +03:00
Alibek Omarov
0231f5e8ac wscript: warn about missing-prototypes by default for C 2024-01-28 09:55:18 +03:00
Alibek Omarov
901b35d4b1 ref: soft: rework @SNMetamorph's fix for avoiding crash when no world is set (like Customize menu with enabled 3D view) 2024-01-27 17:31:34 +03:00
Alibek Omarov
eaafd0ff13 ref: gl: rework @SNMetamorph's fix for avoiding crash when no world is set (like Customize menu with enabled 3D view) 2024-01-27 17:31:26 +03:00
Alibek Omarov
963d9b8f2a ref: soft: remove useless R_CountDynamicLights function 2024-01-27 17:16:01 +03:00
Alibek Omarov
5696c9c96a ref: gl: remove useless R_CountDynamicLights function 2024-01-27 17:15:57 +03:00
Alibek Omarov
862b9e68be engine: server: fix possible null pointer dereference 2024-01-25 16:21:55 +03:00
Alibek Omarov
2f2890cd11 engine: client: use PARM_TEX_FILTERING to figure out whether we should apply half-texel trick to HUD textures when scaling 2024-01-25 05:50:11 +03:00
Alibek Omarov
482aa840e7 ref: soft: add PARM_TEX_FILTERING handler (stub) 2024-01-25 05:47:12 +03:00
Alibek Omarov
4599983c8e ref: gl: add PARM_TEX_FILTERING handler 2024-01-25 05:46:54 +03:00
Alibek Omarov
11172838f2 engine: ref_api: add PARM_TEX_FILTERING into RefAPI to query if filtering is enabled for selected texture 2024-01-25 05:43:51 +03:00
Alibek Omarov
47bc50b8c6 engine: client: fix taking console color from colors.lst 2024-01-25 04:22:20 +03:00
Alibek Omarov
7c82766a5c readme: add sourcehut builds badge [skip ci] 2024-01-24 21:10:21 +03:00
Alibek Omarov
5d6cf62405 engine: client: voice: open microphone only after server sends svc_voiceinit to us and shutdown immediately after disconnect 2024-01-24 20:52:21 +03:00
Alibek Omarov
edc08e39ef common: move FORCEINLINE from port.h to xash3d_types.h, alongside other compiler-specific attributes 2024-01-24 20:51:34 +03:00
Alibek Omarov
a9846e765d waf: upgrade to latest waifu 2024-01-23 21:34:49 +03:00
Alibek Omarov
aa54309d5c engine: wscript: fix pthreads check by explicitly checking it in C mode 2024-01-23 21:23:23 +03:00
Alibek Omarov
443317bedf wscript: fix RPATH under OpenBSD 2024-01-23 21:03:10 +03:00
Alibek Omarov
ffd320507f ci: enable builds.sr.ht 2024-01-23 20:42:09 +03:00
Alibek Omarov
60df08c11c engine: crashhandler: fix build for NetBSD AMD64 2024-01-23 20:25:17 +03:00
Alibek Omarov
7d464df107 engine: platform: linux: define portability macro for sigevent (oh, glibc...) 2024-01-23 19:22:56 +03:00
Alibek Omarov
296f89acf9 engine: platform: linux: fix build with musl (and probably other libcs) using portability macro 2024-01-23 18:57:33 +03:00
mittorn
5f31417bae ref_gl: fix missing vboarray split transition on some maps 2024-01-19 21:28:49 +03:00
Alibek Omarov
150d98bd15 ref: gl: fix stuck single lightmap texture object when using VBO after updating lightmap 2024-01-19 09:57:11 +03:00
Alibek Omarov
f162fbd806 ref: gl: fix fog with enabled overbrights and no vbo 2024-01-19 06:19:42 +03:00
Alibek Omarov
7d8ea61ac2 ref: gl: move glBegin/glEnd outside of the loop in CL_DrawTracers 2024-01-17 02:46:38 +03:00
Alibek Omarov
40041e30eb engine: console: add cvar con_oldfont to toggle usage between fonts.wad fonts or gfx.wad legacy font 2024-01-15 18:11:08 +03:00
Alibek Omarov
a247e139bf engine: fix dedicated build 2024-01-15 02:08:30 +03:00
Alibek Omarov
00b2ca7f5a ref: gl: remove duplicates from gl_export.h 2024-01-15 02:08:30 +03:00
Alibek Omarov
e58007aab3 wscript: disable /showIncludes based msvcdeps for now, it causes issues with non-English locales 2024-01-14 13:36:49 +03:00
Alibek Omarov
dca862a838 engine: host: execute valid rc script if game was started from -game parameter using default launcher 2024-01-14 10:58:27 +03:00
Alibek Omarov
7e71e20714 engine: client: add cvar scr_drawversion to hide engine version in screenshots (sorry, Uncle Mike!) 2024-01-14 10:58:04 +03:00
Alibek Omarov
cee6862924 engine: client: try to prepend media/ if audio stream couldn't be opened 2024-01-14 10:58:04 +03:00
Alibek Omarov
a8cc68f6b9 ref: gl: fix ripple water is being blurry with gl_texture_nearest after startup 2024-01-14 10:56:58 +03:00
Alibek Omarov
2af0adb629 mainui: update 2024-01-13 05:51:39 +03:00
Alibek Omarov
628ac376ed engine: client: s_dsp: refactoring from hldsp 2024-01-13 05:29:43 +03:00
Alibek Omarov
251e6ac1dc engine: client: s_dsp: use Cvar_DirectSet 2024-01-13 05:29:12 +03:00
Alibek Omarov
9b6518376c engine: cvar: add Cvar_DirectSetValue function 2024-01-13 05:18:30 +03:00
Alibek Omarov
6c3fee7f27 engine: cvar: move common checks if cvar can be updated into generic function 2024-01-13 05:18:09 +03:00
Alibek Omarov
c111a59639 github: set 32-bit windows builds to vs2019, upgrade SDL2 2024-01-13 05:05:54 +03:00
Alibek Omarov
ba9bb70924 common: remove unused gamma definitions 2024-01-13 05:03:58 +03:00
Alibek Omarov
6acc97b0ef engine: client: restore my copyright on my DSP implementation from old engine branch 2024-01-13 00:56:03 +03:00
Alibek Omarov
cd681d4303 engine: replace anorms.h with compatible header from GPL WinQuake sources 2024-01-12 23:13:22 +03:00
Alibek Omarov
46f30e215c common: replace netadr.h with compatible definition from GPL Quake-2 sources 2024-01-12 23:09:38 +03:00
Alibek Omarov
2ae038c01c common: fix broken STATIC_ASSERT macro again 2024-01-12 23:00:56 +03:00
Alibek Omarov
aaa9fbd50f common: replace kbutton.h with compatible defintion from GPL WinQuake sources 2024-01-12 17:20:30 +03:00
Alibek Omarov
51d4716bcb engine: client: rewrite trimming silence at the beginning and ending of the VOX word from scratch 2024-01-12 03:27:05 +03:00
Alibek Omarov
045caacfee engine: client: drop skipping random 0.1 second of an ambient sound 2024-01-12 03:27:05 +03:00
Andrey Akhmichin
95a5c670a2 utils: mdldec: res: activities.txt: remove completely useless ACT_VM_* activities. 2024-01-10 14:38:01 +03:00
Andrey Akhmichin
30259e1573 Documentation: opensource-mods.md: update. 2024-01-10 14:37:52 +03:00
Bohdan Shulyar
8b884132b7 ci: fix missing libs on nswitch 2024-01-10 14:37:43 +03:00
Alibek Omarov
266f9a6bc6 engine: client: add support for parsing IPv6 server list 2024-01-09 16:59:06 +03:00
Alibek Omarov
58177d9251 mainui: update 2024-01-09 04:58:11 +03:00
Alibek Omarov
69e801d6b8 engine: fix bug where user stucks after loading map/save while being connected to remote server 2024-01-09 04:16:52 +03:00
Alibek Omarov
388cc3061f mainui: update 2024-01-09 03:55:28 +03:00
Alibek Omarov
c9d29b3955 ref: gl: fix overbrights with VBO 2024-01-09 03:55:07 +03:00
Alibek Omarov
371025dc8e engine: dedicated: add TextureToGamma stub for imagelib 2024-01-09 03:55:07 +03:00
Alibek Omarov
cf7a79bff3 ref: gl: particles aren't supposed to care about gamma 2024-01-09 03:55:07 +03:00
Alibek Omarov
55dfa1bf44 ref: soft: reorder applying light gamma 2024-01-09 03:55:07 +03:00
Alibek Omarov
519c8a032a ref: soft: adapt studio renderer to new gamma implementation 2024-01-09 03:55:07 +03:00
Alibek Omarov
c15822f375 ref: soft: don't depend on light gamma in recursive light point 2024-01-09 03:55:07 +03:00
Alibek Omarov
0e91deec19 ref: soft: remove unused scale (remnants of r_lightmap_modulate), use integer values for non-interpolated lightstyles 2024-01-09 03:55:07 +03:00
Alibek Omarov
87b204c661 ref: gl: remove unused scale (remnants of r_lightmap_modulate), use integer values for non-interpolated lightstyles 2024-01-09 03:55:07 +03:00
Alibek Omarov
caefa0b7b9 engine: remove cvar r_lighting_modulate, it's some unindentifiable legacy 2024-01-09 03:55:07 +03:00
Alibek Omarov
a311923d4e engine: imagelib: apply texgamma to palette (ideally should be applied only to BSP/WAD textures) 2024-01-09 03:55:07 +03:00
Alibek Omarov
ee4cb39f3e ref: gl: adapt alias renderer to new gamma implementation (untested) 2024-01-09 03:55:07 +03:00
Alibek Omarov
18436a70eb ref: gl: support overbrights, change the gamma applying order closer to the original renderer 2024-01-09 03:55:00 +03:00
Alibek Omarov
8298053e6a ref: gl: don't depend on lightgamma in recursive light point 2024-01-09 03:33:39 +03:00
Alibek Omarov
9304a0041d ref: gl: support kRenderFxLightMultiplier
* add undocumented kRenderFxLightMultiplier to const.h
2024-01-09 03:33:39 +03:00
Alibek Omarov
64f92003fa ref: gl: adapt studio lightning to new gamma
* more accurate SHADE_LAMBERT value (extracted from v_lambert1 global variable)
2024-01-09 03:33:39 +03:00
Alibek Omarov
be0a241244 engine: client: add tests for new gamma implementation 2024-01-09 03:33:39 +03:00
Alibek Omarov
df6546d5b1 engine: client: add new gamma implementation
* immediately expose it in RefAPI. Bump RefAPI to version 7.
* remove VID_StartupGamma, it's not used anymore
* remove stub lightgamma and direct cvars
* add a temporary check for v_direct and v_lightgamma default values
2024-01-09 03:33:24 +03:00
Alibek Omarov
a0c31120d9 ref: add R_GammaChanged function that engine calls on every gamma change 2024-01-07 03:35:23 +03:00
Alibek Omarov
c0757bd84c ref: gl: remove vid_gamma/vid_brightness changed cvar value check 2024-01-07 03:35:23 +03:00
Alibek Omarov
9fa32a9cf4 ref: soft: remove vid_gamma/vid_brightness changed cvar value check 2024-01-07 03:35:23 +03:00
Ruslan Piasetskyi
15bc09b06b engine: platform: linux: Add gettid definition for old systems
The gettid() library support was added in glibc 2.30. Earlier glibc
versions did not provide a wrapper for this system call, necessitating
the use of syscall(2).

Also, put _GNU_SOURCE definition in the guard to avoid the warning:
  ../engine/platform/linux/sys_linux.c:16: warning: "_GNU_SOURCE" redefined
   #define _GNU_SOURCE

  <command-line>: note: this is the location of the previous definition
2024-01-06 13:43:35 +03:00
Alibek Omarov
315aea1991 filesystem: support mods liblist.gam/gameinfo.txt with relative paths to game libs 2024-01-05 04:34:33 +03:00
Alibek Omarov
380422a6dc engine: client: refactor CL_AddEntityEffects, bring everything to GoldSrc behavior
Some effects are meant only for playeres, others only for normal entities
2024-01-05 04:10:45 +03:00
Alibek Omarov
be26ecf1c9 engine: client: don't spawn model effects for players, like GoldSrc 2024-01-05 04:09:20 +03:00
Alibek Omarov
d2bbe9dfd2 engine: client: don't spawn multiple model effects 2024-01-05 04:08:52 +03:00
Alibek Omarov
9c929c1405 engine: client: don't spawn particles if time is stopped 2024-01-05 02:59:47 +03:00
Alibek Omarov
9551240680 engine: host: fix -Werror=parentheses 2024-01-05 02:35:16 +03:00
Alibek Omarov
6605d0456c engine: host: force ENGINE_STEP_POSHISTORY_LERP for Counter-Strike and Condition Zero 2024-01-05 02:27:37 +03:00
Alibek Omarov
99e8f7b486 engine: host: fix warning about incompatible features bits 2024-01-05 02:26:25 +03:00
Alibek Omarov
5ac8f63741 ref: soft: replace skin texture num bound by a proper check, fixes wrong skin on flags in Adrenaline Gamer 2024-01-05 02:25:18 +03:00
Alibek Omarov
9d3949a948 ref: gl: replace skin texture num bound by a proper check, fixes wrong skin on flags in Adrenaline Gamer 2024-01-05 02:25:10 +03:00
Alibek Omarov
5bd1dd34b3 ci: disable freebsd-12 task 2024-01-04 22:15:08 +03:00
Alibek Omarov
6862b14e59 ref: soft: only draw MOVETYPE_FOLLOW studio model if it's parent is visible 2024-01-04 22:02:14 +03:00
Alibek Omarov
dc1d65f621 ref: gl: only draw MOVETYPE_FOLLOW studio model if it's parent is visible 2024-01-04 22:02:09 +03:00
Alibek Omarov
fba3a2b67f ref: soft: return NULL in GetEntityByIndex and ModelHandle 2024-01-04 21:47:03 +03:00
Alibek Omarov
b946c8455d ref: gl: return NULL in GetEntityByIndex and ModelHandle just in case 2024-01-04 21:46:44 +03:00
Alibek Omarov
c56e876043 engine: client: don't reset runfuncs for demoplayback 2024-01-04 06:11:15 +03:00
Alibek Omarov
9773d11464 engine: client: disable MOVETYPE_TOSS interpolation in old protocol, but keep animtime hack for them 2024-01-04 05:53:04 +03:00
Alibek Omarov
3c28b11754 engine: client: cl_demo: fix usercmd in demo playback
I have no explanation why this works but it kinda does?
2024-01-04 05:48:45 +03:00
Alibek Omarov
f2584dcb9d engine: host: better engine features print 2024-01-04 05:31:01 +03:00
Alibek Omarov
ce73838f1b engine: add a function that validates requested features bits 2024-01-04 05:30:18 +03:00
Alibek Omarov
49f972a7c9 engine: add new engine feature ENGINE_STEP_POSHISTORY_LERP that enables CStrike's MOVETYPE_STEP lerp based on position history 2024-01-04 05:05:03 +03:00
Alibek Omarov
1ae01d89de engine: client: correctly support ENGINE_COMPUTE_STUDIO_LERP feature flag without STUDIO_INTERPOLATION_FIX enabled 2024-01-04 03:35:16 +03:00
Alibek Omarov
8e54e18c8f engine: client: disable STUDIO_INTERPOLATION_FIX 2024-01-04 03:32:59 +03:00
Alibek Omarov
18136e5320 engine: client: implement HL25's cl_fixmodelinterpolationartifacts cvar 2024-01-04 03:32:36 +03:00
Alibek Omarov
a29f1899d3 engine: client: remove unused extrapolate variable in CL_PureOrigin 2024-01-03 19:06:46 +03:00
Alibek Omarov
0f804ffc30 engine: client: use extra precision for interpolation 2024-01-03 19:02:09 +03:00
Alibek Omarov
620a4b4894 engine: client: wrong check order, fix previous commit 2023-12-31 06:35:38 +03:00
Alibek Omarov
4cf87c2c23 engine: client: prevent memory corruption on old protocol when server didn't sent local player info in delta at spawn 2023-12-31 06:24:53 +03:00
Alibek Omarov
f031c31b77 engine: client: try another workaround for backwards animtime 2023-12-31 06:12:00 +03:00
Alibek Omarov
c2447d8634 engine: client: stupid hack to allow monsters interpolation on a very specific old protocol engine mod 2023-12-31 05:03:10 +03:00
Alibek Omarov
ae9c1d9f18 engine: remove single-binary option. Now platforms that don't need external launcher, shall set env.DISABLE_LAUNCHER 2023-12-30 23:45:17 +03:00
Alibek Omarov
0132eb6e44 ref: gl: restore usage of FWORLD_CUSTOM_SKYBOX flag, do direct checks instead of PARM check, remove unused tr.fCustomSkybox 2023-12-30 16:55:31 +03:00
Alibek Omarov
f12df54226 ref: soft: remove unused tr.fCustomSkybox 2023-12-30 16:54:56 +03:00
Alibek Omarov
d971055927 engine: move PARM_SKY_SPHERE handling out of engine to renderer, after all renderers might or might not support sky spheres 2023-12-30 16:54:37 +03:00
Alibek Omarov
6059538d77 ref: gl: use direct host.features instead of PARM_FEATURES 2023-12-30 16:41:51 +03:00
Alibek Omarov
17deba0606 ref: gl: use direct cl.paused instead of PARM_GAMEPAUSED 2023-12-30 16:41:39 +03:00
Alibek Omarov
82a2d272ad ref: gl: use direct host.features instead of PARM_FEATURES 2023-12-30 16:41:22 +03:00
Alibek Omarov
707a9228e1 engine: ref_api: draft RefAPI 6.
Remove timings from ref_globals_t struct

Remove R_UpdateRefState accordingly.

Remove unused PARMs

Remove reduntant functions
2023-12-30 16:36:13 +03:00
Alibek Omarov
59ddfb787f ref: soft: remove GetPredictedOrigin() call 2023-12-30 16:36:13 +03:00
Alibek Omarov
acdf1da995 ref: soft: remove GetMoveVars() call 2023-12-30 16:36:13 +03:00
Alibek Omarov
f1cdab91eb ref: soft: remove usage of PARM_VIEWENT_INDEX and PARM_PLAYER_INDEX 2023-12-30 16:36:13 +03:00
Alibek Omarov
05d5abe4db ref: soft: remove usage of PARM_MAX_CLIENTS 2023-12-30 16:36:13 +03:00
Alibek Omarov
44e017a410 ref: soft: convert to usage of ref_host_t to get real engine time 2023-12-30 16:36:13 +03:00
Alibek Omarov
64f3884f23 ref: soft: convert to usage of ref_client_t to get client time 2023-12-30 16:36:13 +03:00
Alibek Omarov
6386782674 ref: soft: acquire engine pointers 2023-12-30 16:36:13 +03:00
Alibek Omarov
8084687e50 ref: gl: remove GetPredictedOrigin call 2023-12-30 16:36:13 +03:00
Alibek Omarov
6c16de55c0 ref: gl: remove GetMoveVars() call 2023-12-30 16:36:13 +03:00
Alibek Omarov
537237ef62 ref: gl: remove usage of PARM_VIEWENT_INDEX and PARM_PLAYER_INDEX 2023-12-30 16:36:13 +03:00
Alibek Omarov
4dfc3f34cb ref: gl: remove usage of PARM_MAX_CLIENTS 2023-12-30 16:36:13 +03:00
Alibek Omarov
d22bbb4213 ref: gl: remove usage of PARM_WORLD_VERSION 2023-12-30 16:36:13 +03:00
Alibek Omarov
0e3b14e9a5 ref: gl: remove usage of PARM_NUMMODELS 2023-12-30 16:36:13 +03:00
Alibek Omarov
afb0540aa3 ref: gl: convert to usage of ref_host_t to get real engine time 2023-12-30 16:36:13 +03:00
Alibek Omarov
4d802d8901 ref: gl: convert to usage of ref_client_t to get client time 2023-12-30 16:36:13 +03:00
Alibek Omarov
6a4bf4965f ref: gl: acquire engine pointers 2023-12-30 16:36:13 +03:00
Alibek Omarov
a3c9538d12 engine: client: add support for new PARMs
Reorganize internal engine structs, carefully check structs compatibility before casting types
2023-12-30 16:36:13 +03:00
Alibek Omarov
632264809f engine: ref_api: add PARMs to get pointers to engine data like cl, host, world, etc. Partially expose cl and host. 2023-12-30 16:36:13 +03:00
Alibek Omarov
bcfabbe802 engine: do not save configs when we closing because of the errors 2023-12-28 22:42:12 +03:00
Alibek Omarov
c244cfc937 engine: do not save configs when we closing because of the errors 2023-12-28 22:40:10 +03:00
Andrey Akhmichin
520fc33394 utils: mdldec: fix wrong conditions. 2023-12-28 20:36:39 +03:00
Alibek Omarov
f705a7cd26 common: xash3d_types: another attempt to properly check static asserts availability 2023-12-28 17:32:07 +03:00
Alibek Omarov
65bfff69d0 engine: wscript: always require librt on Linux since we need it for Platform_SetTimer implementation 2023-12-27 04:14:19 +03:00
Alibek Omarov
9d8ba03f5e common: xash3d_types: fix static_assert macro 2023-12-27 03:10:41 +03:00
Alibek Omarov
778b8ede58 engine: platform: linux: add forgotten _GNU_SOURCE at the top of the file to enable gettid extension 2023-12-27 03:10:20 +03:00
Alibek Omarov
f8a1a2ed71 engine: platform: linux: add missing math.h include 2023-12-26 18:56:30 +03:00
mittorn
b4a7c266b5 platform/linux: implement debug timers and cl_maxframetime to catch very long frames on debugger 2023-12-25 14:22:20 +03:00
mittorn
a488f79852 ref_gl: workaround freezes on adreno with vbo on dlighted decals 2023-12-25 14:21:21 +03:00
Alibek Omarov
b290046503 ref: gl: remove hidden parm -gl-allow-vbo-dontuse needed to activate VBO renderer 2023-12-19 17:55:10 +03:00
Dmitry Toroshchin
e8409cee8b ref_gl: vbo: do not do zero-length drawcalls (fix glError on vivante) 2023-12-19 17:55:10 +03:00
mittorn
1d4d355b38 ref_gl: vbo: fix binding garbade texture after changelevel, fix wpoly counter 2023-12-19 17:55:10 +03:00
mittorn
dfe12535a5 ref_gl: vbo: disable R_TextureRandomTiling implementation until will be fixed 2023-12-19 17:55:10 +03:00
mittorn
74946100f1 ref_gl: fix not restoring static lightmap after decals 2023-12-19 17:55:10 +03:00
mittorn
9a1717915c ref_gl: vbo: apply a1batross's patch for uint index switch 2023-12-19 17:55:10 +03:00
mittorn
3691eb6e48 ref_gl: vbo: fix incorrect lightmap index, optimize loading maps with very big lightmap count, fix clouds drawing after VBO 2023-12-19 17:55:10 +03:00
mittorn
3bb7471fd3 ref_gl: vbo: fix lightmap0 processing, remove ilightmap 2023-12-19 17:55:10 +03:00
mittorn
74e09ddb12 ref_gl: change state management in vbo renderer 2023-12-19 17:55:10 +03:00
mittorn
6b73d056b2 ref_gl: vbo dlights refactiring 2023-12-19 17:55:10 +03:00
mittorn
3e7847551a ref_gl: add ability to skip uploading unused data (disabled) 2023-12-19 17:55:10 +03:00
mittorn
91d92935fa ref_gl: try avoid gpu locking on dlights in vbo renderer 2023-12-19 17:55:10 +03:00
mittorn
eff033298a ref_gl: disable singlepass detail renderer, use correct fog color multipliers in VBO 2023-12-19 17:55:10 +03:00
mittorn
3a8f4961bc ref_gl: fix rarely broken texturechain on some big maps 2023-12-19 17:55:10 +03:00
mittorn
b81f94518a ref_gl: fix out-by-one when all lightstyles are used. Also fix broken in this case in vbo after previous fix 2023-12-19 17:55:10 +03:00
Alibek Omarov
96f7f5457d engine: print all supported and enabled features 2023-12-17 17:51:15 +03:00
Alibek Omarov
498ec6b4f1 engine: client: print enabled features after server connect if it's not a local game 2023-12-17 17:44:05 +03:00
Alibek Omarov
607e62a1ae engine: client: sanitize legacy protocol supported engine features flags
Do not enable what can't be enabled in current protocol.
2023-12-17 17:44:05 +03:00
Alibek Omarov
d41a80bc2c engine: add mask to sanitize possible engine features bits 2023-12-17 17:43:51 +03:00
Alibek Omarov
643bec4071 engine: client: set max FPS when recording with fps_max 0 2023-12-16 22:02:26 +03:00
Alibek Omarov
a7e84230c3 ref: gl: use world version to enable large lightmaps for BSP2 automatically 2023-12-15 07:38:25 +03:00
Alibek Omarov
c96cf7e22d engine: expose world version through RefAPI 2023-12-15 07:38:07 +03:00
Alibek Omarov
46c61660cf engine: expose world BSP version through world global structure 2023-12-15 07:37:40 +03:00
Alibek Omarov
f6fecce52b wscript: do not recurse into ref_soft when BSP2 is enabled 2023-12-15 07:29:38 +03:00
Alibek Omarov
54a5947a3c engine: remove MSGBOX macro 2023-12-15 06:40:04 +03:00
Andrey Akhmichin
521bc675a2 utils: mdldec: smd.c: simplify proper bone rotation code. 2023-12-14 14:55:40 +03:00
Andrey Akhmichin
845cee2578 utils: mdldec: smd.c: prevent division by zero. 2023-12-14 14:54:49 +03:00
Alibek Omarov
93ceb0e4ed engine: client: split the sprites indices only when loading new sprite. Scan the whole array when searching.
Fixes incorrect sprite loading in XDM
2023-12-14 03:12:47 +03:00
Alibek Omarov
13aab4e59c engine: server: fix off-by-one error in Voice_Set/GetClientListening 2023-12-13 14:56:55 +03:00
Alibek Omarov
36c2f9e9f2 engine: refactor rcon redirect, don't make it depend on global object 2023-12-13 14:56:27 +03:00
Alibek Omarov
514da0ffa9 engine: host: do not depend on Sys_Sleep accuracy, instead allocate a timewindow that decrases with each skipped frame 2023-12-11 07:12:44 +03:00
Alibek Omarov
37b8d5da79 mainui: update 2023-12-11 07:12:30 +03:00
Alibek Omarov
b5d602d953 wscript: enable -Werror=alloc-size and -Walloc-zero 2023-12-11 07:11:40 +03:00
Alibek Omarov
c926fee13c filesystem: report an error when opening file was unsuccessful, with the exception for non-existent files 2023-12-11 07:10:51 +03:00
Alibek Omarov
a675806c91 engine: imagelib: img_ktx2: don't allow to load images with no mip levels 2023-12-11 07:06:12 +03:00
Alibek Omarov
683c4874f8 common: add ALLOC_CHECK macro that enables attribute alloc_size on GCC that allows to prevent suspicious allocation sizes 2023-12-09 19:00:25 +03:00
Alibek Omarov
20ced857b4 engine: client: use physents array when tracing physents =/ 2023-12-09 16:45:35 +03:00
Alibek Omarov
c6c86f9665 public: make hash case-insensitive again 2023-12-07 06:46:49 +03:00
Alibek Omarov
1e0107944f engine: make sys_timescale non-cheat, like host_framerate 2023-12-07 00:50:56 +03:00
Alibek Omarov
21797f9ac8 ref: gl: fix solor to color 2023-12-06 05:22:02 +03:00
mittorn
c800b34cd4 ref_api: add R_Flush method 2023-12-06 04:13:27 +03:00
Alibek Omarov
1612e2d669 engine: client: GetRefAPI now must return REF_API_VERSION to prevent possible issue when ref library wasn't recompiled on version bump 2023-12-06 04:13:27 +03:00
Alibek Omarov
26d229c8ca engine, ref: RefAPI 5. Simplify remap calls 2023-12-06 04:13:03 +03:00
Alibek Omarov
9c66e86be1 engine, ref: RefAPI 5. Remove unused calls 2023-12-06 04:13:03 +03:00
Alibek Omarov
7e9f87de2d engine, ref: eliminate calls to global arrays, instead store array pointers at renderer side 2023-12-06 04:13:03 +03:00
Alibek Omarov
67737446ac mainui: update 2023-12-06 04:12:33 +03:00
Andrey Akhmichin
dabed4f9eb utils: mdldec: add separate directories creation for sequences and textures. 2023-12-05 11:18:47 +03:00
Andrey Akhmichin
f9b6389248 utils: mdldec: create full destination path into "Kratisto's mdldec" maner. 2023-12-05 11:18:47 +03:00
Alibek Omarov
9ec1e259b4 engine: platform: sdl: unused variable cleanup 2023-12-05 10:48:47 +03:00
Alibek Omarov
0c2d480d89 engine: client: unused variables cleanup 2023-12-05 10:47:55 +03:00
Alibek Omarov
350d8ccb7b engine: common: cvar: unused variables cleanup 2023-12-05 10:46:26 +03:00
Alibek Omarov
0c512d0431 engine: server: unused variables cleanup 2023-12-05 10:46:03 +03:00
Alibek Omarov
3bf55c9ea4 filesystem: zip: hide CRC checks under common macro 2023-12-04 03:01:11 +03:00
Alibek Omarov
9994c57796 filesystem: fix updating gameinfo.txt from rodir 2023-12-04 03:00:51 +03:00
Alibek Omarov
3f724b6b17 filesystem: remove some really unused variables 2023-12-04 03:00:29 +03:00
Alibek Omarov
255773b4de ref: gl: remove useless calls to glGetString if we're running under GL4ES 2023-12-04 02:53:51 +03:00
Alibek Omarov
5b73a788da ref: gl: disable unused variable warning for GL functions defintions 2023-12-04 02:53:27 +03:00
Alibek Omarov
748b06a00e wscript: warn about unused variables 2023-12-04 02:53:07 +03:00
Alibek Omarov
273bccdc9a engine: nswitch: fix compiling by removing stdc++ from SDL2 dependencies as we link it later (#1519) 2023-12-02 20:25:51 +03:00
Alibek Omarov
f0a2362da3 engine: wscript: another try, link nswitch port using gcc and not g++ 2023-12-02 19:29:30 +03:00
Alibek Omarov
be8ade23e8 engine: wscript: add -nostdlib++ for nswitch so we avoid implicit linking to standard C++ library (we link it explicitly ourselves) 2023-12-02 19:21:44 +03:00
Alibek Omarov
6814908d80 scripts: gha: enable verbose build for nswitch port 2023-12-02 19:08:34 +03:00
Alibek Omarov
08dbfc45d3 ref: gl: refactor getting edge position, texture and lightmap coords 2023-12-02 18:02:18 +03:00
Alibek Omarov
89f9b3df68 public: make simple bbox functions inline 2023-12-02 18:01:57 +03:00
Alibek Omarov
40c9a2fb82 engine: make Mod_SampleSizeForFace accept const surface 2023-12-02 18:01:57 +03:00
Andrey Akhmichin
a34c22fb10 engine: client: add support for "mp3 playfile/loopfile" commands. 2023-12-02 01:10:38 +03:00
Alibek Omarov
e161ff0f7a mainui: update 2023-11-27 19:25:36 +03:00
Alibek Omarov
fee42eab5a mainui: update 2023-11-27 19:05:48 +03:00
Alibek Omarov
2d2e03f235 engine: server: reset edict in ParseSaveTables like GoldSrc does which fixes messed up entities in mods that have advanced save-restore system (thanks to vasiavasiavasia95 for figuring out this bug) 2023-11-27 18:42:50 +03:00
Alibek Omarov
4c3c3529e9 engine: network: rename length variable to something that makes sense. Add usage line to http_addcustomserver 2023-11-26 23:20:46 +03:00
Alibek Omarov
7051b844ff engine: network: set HTTP buffer to 8kb on all systems, without depending on random constant like BUFSIZ 2023-11-26 23:19:49 +03:00
Alibek Omarov
68377435c8 engine: server: remove legacy light -> light_level entity key rewrite 2023-11-26 02:23:52 +03:00
Henry Ford
652b1804a8 wscript: make libdl optional for systems that include it in libc 2023-11-25 14:29:52 +03:00
Henry Ford
e7e1677786 engine: common: comply with C89 in OpenBSD wai_getExecutablePath 2023-11-25 14:29:52 +03:00
Henry Ford
f330aac113 engine: common: dont inlcude ucontext.h on OpenBSD where it doesnt exist 2023-11-25 14:29:52 +03:00
Henry Ford
dbdd330cf7 wscript: try to find alloca in stdlib.h on platforms without alloca.h or malloc.h 2023-11-25 14:29:52 +03:00
Andrey Akhmichin
c448c7b0b1 utils: mdldec: avoid double ".smd" extension output. 2023-11-22 11:05:34 +03:00
Andrey Akhmichin
8d7b9c2f01 utils: mdldec: always write trailing slash for non-empty destination path. 2023-11-22 11:03:28 +03:00
Alibek Omarov
b6a235445a vgui_support: update submodule 2023-11-22 11:02:25 +03:00
Alibek Omarov
9fcd4baa87 engine: client: gameui: expose animated_title and hd_background flags to main menu API 2023-11-22 11:01:18 +03:00
Alibek Omarov
fb0102eb8e filesystem: add support for two new liblist.gam keys: animated_title and hd_background 2023-11-22 11:01:18 +03:00
Alibek Omarov
9c1afaa372 filesystem: fix noskills being written as nomodels in gameinfo.txt 2023-11-22 11:01:18 +03:00
Alibek Omarov
1d1a6badb5 filesystem: VFileSystem009: HL25 compatibility (one single new method) 2023-11-22 11:01:18 +03:00
Andrey Akhmichin
2d41c9cb15 utils: mdldec: texture.c: add Targa image format output support. 2023-11-22 10:56:57 +03:00
Alibek Omarov
722cbe1f02 filesystem: forgot to add defaults.h include 2023-11-20 18:52:05 +03:00
Alibek Omarov
8ac2c241c4 mainui: update 2023-11-20 17:33:40 +03:00
Alibek Omarov
dd11f73951 filesystem: respect DEFAULT_MAX_EDICTS value 2023-11-20 17:32:35 +03:00
Alibek Omarov
a443547d4d common: defaults: add default macro for default gameinfo max_edicts value 2023-11-20 17:32:19 +03:00
Andrey Akhmichin
7a795edeb5 utils: mdldec: better validation checks. 2023-11-20 00:19:14 +03:00
Andrey Akhmichin
a8cbfb8dda Documentation: opensource-mods.md: update link to cs16-client. 2023-11-20 00:15:26 +03:00
SNMetamorph
5216cccef4 engine: server: added singleplayer check for userinfo update 2023-11-20 00:14:30 +03:00
SNMetamorph
a87f399e68 engine: client: revert export for pfnSPR_Load and pfnSPR_Frames functions
This needed for native support GoldSrc Monitor utility.
2023-11-20 00:14:06 +03:00
Andrey Akhmichin
dd310ab851 ci: upgrade freebsd tasks. 2023-11-20 00:13:42 +03:00
Andrey Akhmichin
16cc0ca0fe ref: gl: gl2_shim: replace "malloc.h" header with ALLOCA_H macro. 2023-11-20 00:13:04 +03:00
Alibek Omarov
83d26ad233 engine: server: add sv_allow_autoaim cvar 2023-11-20 00:11:10 +03:00
Alibek Omarov
d1f9a8f2db mainui: updates for HL25 2023-11-19 23:43:46 +03:00
Alibek Omarov
a2e1071808 game_launch: force link libm on Linux to workaround HL25 bug
HL25 doesn't link libm probably because of toolchain updates, where
--Wl,--as-needed became the default.

hl_linux is linked to libm which is why they probably didn't noticed this bug.

Workaround until Valve fixes it: https://github.com/ValveSoftware/halflife/issues/3492
2023-11-19 23:43:46 +03:00
Alibek Omarov
0aa8a2891c engine: client: add gles3compat to renderers list 2023-11-03 17:03:27 +03:00
Alibek Omarov
c0ceab7513 wscript: enable ref_gles3compat for Android 2023-11-03 17:01:47 +03:00
Velaron
5c90e716cb engine: platform: android: refactoring 2023-11-03 16:40:06 +03:00
Velaron
0073225549 scripts: gha: Android deps and build scripts 2023-11-03 16:36:55 +03:00
Alibek Omarov
d03a64602b wscript: change defaults for Android 2023-11-03 16:34:21 +03:00
Alibek Omarov
d67a4234cc filesystem: android: simplify code, get getAssets method only once, remove unneeded casts and memsets (where Mem_Calloc is used) 2023-11-03 16:29:57 +03:00
Alibek Omarov
0d37244490 filesystem: add missing const to 2nd argument of stringlistappend 2023-11-03 16:23:52 +03:00
Velaron
6426919cb5 filesystem: add Android assets support 2023-11-03 16:23:03 +03:00
Alibek Omarov
0a0d63663a filesystem: link with libandroid 2023-11-03 16:22:59 +03:00
Alibek Omarov
71b06801ef engine: platform: android: remove dead code 2023-11-03 14:48:28 +03:00
Alibek Omarov
cfc7b35927 engine: client: don't leave the user without mouse cursor if they enabled m_ignore 2023-11-03 14:48:28 +03:00
Alibek Omarov
76564958d1 engine: host: hide -nativeegl for Android SDL builds 2023-11-03 14:48:28 +03:00
Alibek Omarov
a464c3dd66 scripts: waifulib: compiler_optimizations: rename release build type to humanrights with kept compatibility 2023-11-02 14:33:00 +03:00
367 changed files with 24284 additions and 12780 deletions

27
.builds/alpine.yml Normal file
View File

@@ -0,0 +1,27 @@
image: alpine/latest
packages:
- build-base
- sdl2-dev
- freetype-dev
- fontconfig-dev
- opus-dev
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-alpine-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-alpine-amd64.tar.bz2

30
.builds/debian-arm64.yml Normal file
View File

@@ -0,0 +1,30 @@
image: debian/sid
arch: amd64
packages:
- build-essential
- python-is-python3
- libsdl2-dev
- libfreetype-dev
- libfontconfig-dev
- libopus-dev
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-debian-arm64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-debian-arm64.tar.bz2

29
.builds/debian.yml Normal file
View File

@@ -0,0 +1,29 @@
image: debian/sid
packages:
- build-essential
- python-is-python3
- libsdl2-dev
- libfreetype-dev
- libfontconfig-dev
- libopus-dev
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure -8 --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-debian-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-debian-amd64.tar.bz2

29
.builds/freebsd.yml Normal file
View File

@@ -0,0 +1,29 @@
image: freebsd/latest
packages:
- lang/python
- devel/pkgconf
- devel/sdl20
- print/freetype2
- x11-fonts/fontconfig
- audio/opus
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
./waf configure --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
./waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-freebsd-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-freebsd-amd64.tar.bz2

29
.builds/netbsd.yml Normal file
View File

@@ -0,0 +1,29 @@
image: netbsd/latest
packages:
- python311
- SDL2
- freetype2
- fontconfig
- libopus
- pkgconf
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
python3.11 waf configure --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
python3.11 waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-netbsd-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-netbsd-amd64.tar.bz2

26
.builds/openbsd.yml Normal file
View File

@@ -0,0 +1,26 @@
image: openbsd/latest
packages:
- python3
- sdl2
- opus
sources:
- https://git.sr.ht/~a1batross/xash3d-fwgs
tasks:
- client: |
cd xash3d-fwgs
python3 waf configure --enable-tests --enable-engine-tests build install --destdir=bin
- server: |
cd xash3d-fwgs
python3 waf configure --reconfigure --dedicated build install --destdir=bin
- run-tests: |
cd xash3d-fwgs/bin
export SDL_VIDEODRIVER=wayland
./xash3d -runtests
./xash -runtests
rm -rf valve/gameinfo.txt test_*
- package: |
cd xash3d-fwgs/bin
tar -cjvf xash3d-fwgs-openbsd-amd64.tar.bz2 *
artifacts:
- xash3d-fwgs/bin/xash3d-fwgs-openbsd-amd64.tar.bz2

View File

@@ -1,34 +1,22 @@
task:
name: freebsd-12-amd64
freebsd_instance:
image_family: freebsd-12-3
setup_script:
- pkg update
- pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-13-amd64
freebsd_instance:
image_family: freebsd-13-1
setup_script:
- pkg update
- pkg install -y git sdl2 python fontconfig
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task: task:
name: freebsd-14-amd64 name: freebsd-14-amd64
freebsd_instance: freebsd_instance:
image_family: freebsd-14-0-snap image_family: freebsd-14-0
setup_script: setup_script:
- pkg update - pkg update
- pkg install -y git sdl2 python fontconfig - pkg install -y pkgconf git sdl2 python fontconfig opus
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-15-amd64
freebsd_instance:
image_family: freebsd-15-0-snap
setup_script:
- pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus
- git submodule update --init --recursive - git submodule update --init --recursive
test_script: test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated - ./scripts/cirrus/build_freebsd.sh dedicated

View File

@@ -1,9 +1,365 @@
# EditorConfig is awesome: https://EditorConfig.org # this file is just a suggestion, you might follow it, you might not
root = true root = true
[*] [*]
charset = latin1 charset = utf-8
end_of_line = lf end_of_line = lf
indent_style = tab indent_style = tab
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
# Visual C++ Formatting settings
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = new_line
cpp_new_line_before_open_brace_type = new_line
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = new_line
cpp_new_line_before_open_brace_lambda = new_line
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = false
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = true
cpp_space_between_empty_parameter_list_parentheses = true
cpp_space_after_keywords_in_control_flow_statements = false
cpp_space_within_control_flow_statement_parentheses = true
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = true
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = true
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = right
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = one_liners
# IDEA settings
ij_c_add_brief_tag = false
ij_c_add_getter_prefix = true
ij_c_add_setter_prefix = true
ij_c_align_dictionary_pair_values = false
ij_c_align_group_field_declarations = false
ij_c_align_init_list_in_columns = true
ij_c_align_multiline_array_initializer_expression = false
ij_c_align_multiline_assignment = false
ij_c_align_multiline_binary_operation = false
ij_c_align_multiline_chained_methods = false
ij_c_align_multiline_for = true
ij_c_align_multiline_ternary_operation = false
ij_c_array_initializer_comma_on_next_line = false
ij_c_array_initializer_new_line_after_left_brace = false
ij_c_array_initializer_right_brace_on_new_line = false
ij_c_array_initializer_wrap = off
ij_c_assignment_wrap = off
ij_c_binary_operation_sign_on_next_line = false
ij_c_binary_operation_wrap = off
ij_c_blank_lines_after_class_header = 0
ij_c_blank_lines_after_imports = 1
ij_c_blank_lines_around_class = 1
ij_c_blank_lines_around_field = 0
ij_c_blank_lines_around_field_in_interface = 0
ij_c_blank_lines_around_method = 1
ij_c_blank_lines_around_method_in_interface = 1
ij_c_blank_lines_around_namespace = 0
ij_c_blank_lines_around_properties_in_declaration = 0
ij_c_blank_lines_around_properties_in_interface = 0
ij_c_blank_lines_before_imports = 1
ij_c_blank_lines_before_method_body = 0
ij_c_block_brace_placement = next_line
ij_c_block_brace_style = next_line
ij_c_block_comment_at_first_column = true
ij_c_catch_on_new_line = false
ij_c_class_brace_style = next_line
ij_c_class_constructor_init_list_align_multiline = true
ij_c_class_constructor_init_list_comma_on_next_line = false
ij_c_class_constructor_init_list_new_line_after_colon = never
ij_c_class_constructor_init_list_new_line_before_colon = if_long
ij_c_class_constructor_init_list_wrap = normal
ij_c_copy_is_deep = false
ij_c_create_interface_for_categories = true
ij_c_declare_generated_methods = true
ij_c_description_include_member_names = true
ij_c_discharged_short_ternary_operator = false
ij_c_do_not_add_breaks = false
ij_c_do_while_brace_force = never
ij_c_else_on_new_line = false
ij_c_enum_constants_comma_on_next_line = false
ij_c_enum_constants_wrap = off
ij_c_for_brace_force = never
ij_c_for_statement_new_line_after_left_paren = false
ij_c_for_statement_right_paren_on_new_line = false
ij_c_for_statement_wrap = off
ij_c_function_brace_placement = next_line
ij_c_function_call_arguments_align_multiline = true
ij_c_function_call_arguments_align_multiline_pars = false
ij_c_function_call_arguments_comma_on_next_line = false
ij_c_function_call_arguments_new_line_after_lpar = false
ij_c_function_call_arguments_new_line_before_rpar = false
ij_c_function_call_arguments_wrap = normal
ij_c_function_non_top_after_return_type_wrap = normal
ij_c_function_parameters_align_multiline = true
ij_c_function_parameters_align_multiline_pars = false
ij_c_function_parameters_comma_on_next_line = false
ij_c_function_parameters_new_line_after_lpar = false
ij_c_function_parameters_new_line_before_rpar = false
ij_c_function_parameters_wrap = normal
ij_c_function_top_after_return_type_wrap = normal
ij_c_generate_additional_eq_operators = true
ij_c_generate_additional_rel_operators = true
ij_c_generate_class_constructor = true
ij_c_generate_comparison_operators_use_std_tie = false
ij_c_generate_instance_variables_for_properties = ask
ij_c_generate_operators_as_members = true
ij_c_header_guard_style_pattern = ${PROJECT_NAME}_${FILE_NAME}_${EXT}
ij_c_if_brace_force = never
ij_c_in_line_short_ternary_operator = true
ij_c_indent_block_comment = true
ij_c_indent_c_struct_members = 4
ij_c_indent_case_from_switch = true
ij_c_indent_class_members = 4
ij_c_indent_directive_as_code = false
ij_c_indent_implementation_members = 0
ij_c_indent_inside_code_block = 4
ij_c_indent_interface_members = 0
ij_c_indent_interface_members_except_ivars_block = false
ij_c_indent_namespace_members = 4
ij_c_indent_preprocessor_directive = 0
ij_c_indent_visibility_keywords = 0
ij_c_insert_override = true
ij_c_insert_virtual_with_override = false
ij_c_introduce_auto_consts = false
ij_c_introduce_auto_vars = false
ij_c_introduce_const_params = false
ij_c_introduce_const_vars = false
ij_c_introduce_constexpr_consts = false
ij_c_introduce_generate_property = false
ij_c_introduce_generate_synthesize = true
ij_c_introduce_globals_to_header = true
ij_c_introduce_prop_to_private_category = false
ij_c_introduce_static_consts = true
ij_c_introduce_use_ns_types = false
ij_c_ivars_prefix = _
ij_c_ivars_suffix =
ij_c_keep_blank_lines_before_end = 2
ij_c_keep_blank_lines_before_right_brace = 2
ij_c_keep_blank_lines_in_code = 2
ij_c_keep_blank_lines_in_declarations = 2
ij_c_keep_case_expressions_in_one_line = false
ij_c_keep_control_statement_in_one_line = false
ij_c_keep_directive_at_first_column = true
ij_c_keep_first_column_comment = false
ij_c_keep_line_breaks = true
ij_c_keep_nested_namespaces_in_one_line = false
ij_c_keep_simple_blocks_in_one_line = false
ij_c_keep_simple_methods_in_one_line = false
ij_c_keep_structures_in_one_line = false
ij_c_lambda_capture_list_align_multiline = false
ij_c_lambda_capture_list_align_multiline_bracket = false
ij_c_lambda_capture_list_comma_on_next_line = false
ij_c_lambda_capture_list_new_line_after_lbracket = false
ij_c_lambda_capture_list_new_line_before_rbracket = false
ij_c_lambda_capture_list_wrap = off
ij_c_line_comment_add_space = false
ij_c_line_comment_at_first_column = true
ij_c_method_brace_placement = end_of_line
ij_c_method_call_arguments_align_by_colons = true
ij_c_method_call_arguments_align_multiline = false
ij_c_method_call_arguments_special_dictionary_pairs_treatment = true
ij_c_method_call_arguments_wrap = off
ij_c_method_call_chain_wrap = off
ij_c_method_parameters_align_by_colons = true
ij_c_method_parameters_align_multiline = false
ij_c_method_parameters_wrap = off
ij_c_namespace_brace_placement = next_line
ij_c_parentheses_expression_new_line_after_left_paren = false
ij_c_parentheses_expression_right_paren_on_new_line = false
ij_c_place_assignment_sign_on_next_line = false
ij_c_property_nonatomic = true
ij_c_put_ivars_to_implementation = true
ij_c_refactor_compatibility_aliases_and_classes = true
ij_c_refactor_properties_and_ivars = true
ij_c_release_style = ivar
ij_c_retain_object_parameters_in_constructor = true
ij_c_semicolon_after_method_signature = false
ij_c_shift_operation_align_multiline = true
ij_c_shift_operation_wrap = normal
ij_c_show_non_virtual_functions = false
ij_c_space_after_colon = true
ij_c_space_after_colon_in_foreach = true
ij_c_space_after_colon_in_selector = false
ij_c_space_after_comma = true
ij_c_space_after_cup_in_blocks = false
ij_c_space_after_dictionary_literal_colon = true
ij_c_space_after_for_semicolon = true
ij_c_space_after_init_list_colon = true
ij_c_space_after_method_parameter_type_parentheses = false
ij_c_space_after_method_return_type_parentheses = false
ij_c_space_after_pointer_in_declaration = false
ij_c_space_after_quest = true
ij_c_space_after_reference_in_declaration = false
ij_c_space_after_reference_in_rvalue = false
ij_c_space_after_structures_rbrace = true
ij_c_space_after_superclass_colon = true
ij_c_space_after_type_cast = false
ij_c_space_after_visibility_sign_in_method_declaration = true
ij_c_space_before_autorelease_pool_lbrace = true
ij_c_space_before_catch_keyword = true
ij_c_space_before_catch_left_brace = true
ij_c_space_before_catch_parentheses = false
ij_c_space_before_category_parentheses = true
ij_c_space_before_chained_send_message = true
ij_c_space_before_class_left_brace = true
ij_c_space_before_colon = true
ij_c_space_before_colon_in_foreach = true
ij_c_space_before_comma = false
ij_c_space_before_dictionary_literal_colon = true
ij_c_space_before_do_left_brace = true
ij_c_space_before_else_keyword = true
ij_c_space_before_else_left_brace = true
ij_c_space_before_export_lbrace = true
ij_c_space_before_for_left_brace = true
ij_c_space_before_for_parentheses = false
ij_c_space_before_for_semicolon = false
ij_c_space_before_if_left_brace = true
ij_c_space_before_if_parentheses = false
ij_c_space_before_init_list = false
ij_c_space_before_init_list_colon = true
ij_c_space_before_method_call_parentheses = false
ij_c_space_before_method_left_brace = true
ij_c_space_before_method_parentheses = false
ij_c_space_before_namespace_lbrace = true
ij_c_space_before_pointer_in_declaration = true
ij_c_space_before_property_attributes_parentheses = false
ij_c_space_before_protocols_brackets = true
ij_c_space_before_quest = true
ij_c_space_before_reference_in_declaration = true
ij_c_space_before_superclass_colon = true
ij_c_space_before_switch_left_brace = true
ij_c_space_before_switch_parentheses = false
ij_c_space_before_template_call_lt = false
ij_c_space_before_template_declaration_lt = true
ij_c_space_before_try_left_brace = true
ij_c_space_before_while_keyword = true
ij_c_space_before_while_left_brace = true
ij_c_space_before_while_parentheses = false
ij_c_space_between_adjacent_brackets = false
ij_c_space_between_operator_and_punctuator = false
ij_c_space_within_empty_array_initializer_braces = true
ij_c_spaces_around_additive_operators = true
ij_c_spaces_around_assignment_operators = true
ij_c_spaces_around_bitwise_operators = true
ij_c_spaces_around_equality_operators = true
ij_c_spaces_around_lambda_arrow = true
ij_c_spaces_around_logical_operators = true
ij_c_spaces_around_multiplicative_operators = true
ij_c_spaces_around_pm_operators = false
ij_c_spaces_around_relational_operators = true
ij_c_spaces_around_shift_operators = true
ij_c_spaces_around_unary_operator = false
ij_c_spaces_within_array_initializer_braces = true
ij_c_spaces_within_braces = false
ij_c_spaces_within_brackets = false
ij_c_spaces_within_cast_parentheses = false
ij_c_spaces_within_catch_parentheses = true
ij_c_spaces_within_category_parentheses = false
ij_c_spaces_within_empty_braces = false
ij_c_spaces_within_empty_function_call_parentheses = true
ij_c_spaces_within_empty_function_declaration_parentheses = true
ij_c_spaces_within_empty_lambda_capture_list_bracket = false
ij_c_spaces_within_empty_template_call_ltgt = false
ij_c_spaces_within_empty_template_declaration_ltgt = false
ij_c_spaces_within_for_parentheses = true
ij_c_spaces_within_function_call_parentheses = true
ij_c_spaces_within_function_declaration_parentheses = true
ij_c_spaces_within_if_parentheses = true
ij_c_spaces_within_lambda_capture_list_bracket = false
ij_c_spaces_within_method_parameter_type_parentheses = false
ij_c_spaces_within_method_return_type_parentheses = false
ij_c_spaces_within_parentheses = true
ij_c_spaces_within_property_attributes_parentheses = false
ij_c_spaces_within_protocols_brackets = false
ij_c_spaces_within_send_message_brackets = false
ij_c_spaces_within_structured_binding_list_bracket = false
ij_c_spaces_within_switch_parentheses = true
ij_c_spaces_within_template_call_ltgt = false
ij_c_spaces_within_template_declaration_ltgt = false
ij_c_spaces_within_template_double_gt = false
ij_c_spaces_within_while_parentheses = true
ij_c_special_else_if_treatment = true
ij_c_structured_binding_list_align_multiline = false
ij_c_structured_binding_list_align_multiline_bracket = false
ij_c_structured_binding_list_comma_on_next_line = false
ij_c_structured_binding_list_new_line_after_lbracket = false
ij_c_structured_binding_list_new_line_before_rbracket = false
ij_c_structured_binding_list_wrap = off
ij_c_superclass_list_after_colon = never
ij_c_superclass_list_align_multiline = true
ij_c_superclass_list_before_colon = if_long
ij_c_superclass_list_comma_on_next_line = false
ij_c_superclass_list_wrap = on_every_item
ij_c_tag_prefix_of_block_comment = at
ij_c_tag_prefix_of_line_comment = back_slash
ij_c_template_call_arguments_align_multiline = false
ij_c_template_call_arguments_align_multiline_pars = false
ij_c_template_call_arguments_comma_on_next_line = false
ij_c_template_call_arguments_new_line_after_lt = false
ij_c_template_call_arguments_new_line_before_gt = false
ij_c_template_call_arguments_wrap = off
ij_c_template_declaration_function_body_indent = false
ij_c_template_declaration_function_wrap = split_into_lines
ij_c_template_declaration_struct_body_indent = false
ij_c_template_declaration_struct_wrap = split_into_lines
ij_c_template_parameters_align_multiline = false
ij_c_template_parameters_align_multiline_pars = false
ij_c_template_parameters_comma_on_next_line = false
ij_c_template_parameters_new_line_after_lt = false
ij_c_template_parameters_new_line_before_gt = false
ij_c_template_parameters_wrap = off
ij_c_ternary_operation_signs_on_next_line = false
ij_c_ternary_operation_wrap = off
ij_c_type_qualifiers_placement = before
ij_c_use_modern_casts = true
ij_c_use_setters_in_constructor = true
ij_c_while_brace_force = never
ij_c_while_on_new_line = false
ij_c_wrap_property_declaration = off

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
custom: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/donate.md

View File

@@ -24,14 +24,9 @@ jobs:
# - os: ubuntu-aarch64-20.04 # - os: ubuntu-aarch64-20.04
# targetos: linux # targetos: linux
# targetarch: aarch64 # targetarch: aarch64
- os: ubuntu-20.04
# - os: ubuntu-20.04 targetos: android
# targetos: android targetarch: multiarch
# targetarch: 32
# - os: ubuntu-20.04
# targetos: android
# targetarch: 64
# - os: ubuntu-20.04 # - os: ubuntu-20.04
# targetos: motomagx # targetos: motomagx
# targetarch: armv6 # targetarch: armv6
@@ -45,84 +40,85 @@ jobs:
- os: windows-latest - os: windows-latest
targetos: win32 targetos: win32
targetarch: amd64 targetarch: amd64
- os: windows-latest - os: windows-2019 # always use the oldest possible for 32-bit because of older compilers, and better support of certain legacy OSes
targetos: win32 targetos: win32
targetarch: i386 targetarch: i386
- os: macos-14 # in GitHub documentation, it's an ARM64 machine
targetos: apple
targetarch: arm64
- os: macos-12 # in GitHub documentation, it's an x86 machine
targetos: apple
targetarch: amd64
env: env:
SDL_VERSION: 2.28.1 SDL_VERSION: 2.30.3
GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CPU_ARCH: ${{ matrix.targetarch }}
ANDROID_SDK_TOOLS_VER: 4333796
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Install dependencies - name: Install dependencies
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
- name: Build engine - name: Build engine
env:
FWGS_PFX_PASSWORD: ${{ secrets.FWGS_PFX_PASSWORD }}
run: bash scripts/gha/build_${{ matrix.targetos }}.sh run: bash scripts/gha/build_${{ matrix.targetos }}.sh
- name: Upload engine (artifacts) - name: Upload engine (artifacts)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }} name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
path: artifacts/* path: artifacts/*
flatpak: flatpak:
name: "Flatpak"
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
include: include:
- app: su.xash.Engine.Compat.i386 - app: su.xash.Engine.Compat.i386
container: container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08 image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08
options: --privileged options: --privileged
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Build flatpak (Compat.i386) - name: Build flatpak (Compat.i386)
uses: FWGS/flatpak-github-actions/flatpak-builder@v6.1 uses: FWGS/flatpak-github-actions/flatpak-builder@v6.3
with: with:
bundle: ${{ matrix.app }}.flatpak bundle: ${{ matrix.app }}.flatpak
manifest-path: scripts/flatpak/${{ matrix.app }}.yml manifest-path: scripts/flatpak/${{ matrix.app }}.yml
- name: Upload engine (artifacts)
uses: actions/upload-artifact@v3
with:
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
path: artifacts/*
release: release:
name: "Upload releases" name: "Upload releases"
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build, flatpak] needs: [build, flatpak]
if: ${{ github.event_name == 'push' }} if: ${{ github.event_name == 'push' }}
steps: steps:
- name: Remove old release - name: Remove old release, fetch artifacts, repackage binaries and upload new release
uses: FWGS/delete-tag-and-release@v0.2.1-dev env:
with: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }} RELEASE_TAG: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }}
delete_release: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch artifacts
uses: actions/download-artifact@v3.0.1
with:
path: artifacts/
- name: Repackage binaries and allow GitHub to process removed release for few seconds
run: | run: |
cd artifacts/ gh release delete "$RELEASE_TAG" \
for i in artifact-* su.xash.Engine.*; do --yes \
--cleanup-tag \
--repo "$GITHUB_REPOSITORY" || true
sleep 20s
gh run download "$GITHUB_RUN_ID" \
--dir artifacts/ \
--repo "$GITHUB_REPOSITORY"
pushd artifacts/
echo "Found artifacts:"
ls
for i in $(find -mindepth 1 -maxdepth 1 -type d); do
mv "$i"/* . mv "$i"/* .
rm -rf "$i" rm -rf "$i"
done done
ls -R . echo "Repackaged artifacts:"
cd ../ ls -R
popd
sleep 20s sleep 20s
- name: Upload new release gh release create "$RELEASE_TAG" artifacts/* \
uses: FWGS/action-gh-release@v0.1.15 --title "Xash3D FWGS Continuous ${{ github.ref_name }} Build" \
with: --target $GITHUB_SHA \
name: Xash3D FWGS Continuous ${{ github.ref_name }} Build --repo "$GITHUB_REPOSITORY" \
tag_name: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }} --prerelease
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/*
draft: false

5
.gitignore vendored
View File

@@ -54,6 +54,11 @@ CMakeFiles
Makefile Makefile
cmake_install.cmake cmake_install.cmake
install_manifest.txt install_manifest.txt
CMakeLists.txt*
CMakeScripts
Testing
compile_commands.json
_deps
# makedepend # makedepend
Makefile.dep Makefile.dep
*.bak *.bak

3
.gitmodules vendored
View File

@@ -19,3 +19,6 @@
[submodule "3rdparty/xash-extras"] [submodule "3rdparty/xash-extras"]
path = 3rdparty/extras/xash-extras path = 3rdparty/extras/xash-extras
url = https://github.com/FWGS/xash-extras url = https://github.com/FWGS/xash-extras
[submodule "3rdparty/bzip2/bzip2"]
path = 3rdparty/bzip2/bzip2
url = https://gitlab.com/bzip2/bzip2

21
3rdparty/MultiEmulator/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017-2018 Alexander Belkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

25
3rdparty/MultiEmulator/README.md vendored Normal file
View File

@@ -0,0 +1,25 @@
# MultiEmulator
**MultiEmulator** - project for GoldSource Engine, which provides ability to generate tickets with a specific SteamID key, using all available emulators for this engine.
Ticket is processed by the game server of Half-Life 1 and modifications using **DProto** or **ReUnion** modules. If the server does not have these modules, then MultiEmulator won't work.
# Ticket generators
Currently available ticket generators:
* OldRevEmu
* AVSMP
* Setti
* SteamEmu
* RevEmu
* SC2009
* RevEmu2013
Currently under development generators:
* SmartSteamEmu (SSE3)
# How to use?
Each file in the **MultiEmulator\Source\Emulators** folder contains a **Generate** function that writes a ticket to the **pDest** argument for the emulator of the same name as a header file. As a result of the function, the size of the written ticket is returned. If the generator can set an arbitrary SteamID, the function will have the **nSteamID** argument, in which the required SteamID is specified.
# Examples
As an example, the DLL was developed that searches InitiateGameConnection method in ISteamUser interface, which generates Steam ticket, and inserts in its place own generator, which creates RevEmu2013 ticket with SteamID equal to 3333333. You can find this project in **Example** folder, you just need to compile it and perform DLL injection in hl.exe process with any known injection method.

View File

@@ -0,0 +1,37 @@
#ifndef MULTI_EMULATOR_H
#define MULTI_EMULATOR_H
#if defined( __GNUC__ )
#if defined( __i386__ )
#define ME_EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer ))
#else
#define ME_EXPORT __attribute__(( visibility ( "default" )))
#endif
#else
#if defined( _MSC_VER )
#define ME_EXPORT __declspec( dllexport )
#else
#define ME_EXPORT
#endif
#endif
#include <string.h>
#if __cplusplus
extern "C"
{
#endif
int ME_EXPORT GenerateRevEmu2013( void *pDest, int nSteamID );
int ME_EXPORT GenerateSC2009( void *pDest, int nSteamID );
int ME_EXPORT GenerateOldRevEmu( void *pDest, int nSteamID );
int ME_EXPORT GenerateSteamEmu( void *pDest, int nSteamID );
int ME_EXPORT GenerateRevEmu( void *pDest, int nSteamID );
int ME_EXPORT GenerateSetti( void *pDest );
int ME_EXPORT GenerateAVSMP( void *pDest, int nSteamID, int bUniverse );
#if __cplusplus
}
#endif
#endif // MULTI_EMULATOR_H

13
3rdparty/MultiEmulator/src/AVSMP.cpp vendored Normal file
View File

@@ -0,0 +1,13 @@
#include "multi_emulator.h"
/* bUniverse param is "y" value in "STEAM_x:y:z" */
int GenerateAVSMP(void *pDest, int nSteamID, int bUniverse)
{
auto pTicket = (int *)pDest;
pTicket[0] = 0x14; // +0, header
pTicket[3] = (nSteamID << 1) | (bUniverse ? 1 : 0); // +12, SteamId, Low part
pTicket[4] = 0x01100001; // +16, SteamId, High part
return 28;
}

1376
3rdparty/MultiEmulator/src/CRijndael.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

187
3rdparty/MultiEmulator/src/CRijndael.h vendored Normal file
View File

@@ -0,0 +1,187 @@
#ifndef __RIJNDAEL_H__
#define __RIJNDAEL_H__
#include <exception>
#include <stdexcept>
#include <cstring>
#include <string>
using namespace std;
//Rijndael (pronounced Reindaal) is a block cipher, designed by Joan Daemen and Vincent Rijmen as a candidate algorithm for the AES.
//The cipher has a variable block length and key length. The authors currently specify how to use keys with a length
//of 128, 192, or 256 bits to encrypt blocks with al length of 128, 192 or 256 bits (all nine combinations of
//key length and block length are possible). Both block length and key length can be extended very easily to
// multiples of 32 bits.
//Rijndael can be implemented very efficiently on a wide range of processors and in hardware.
//This implementation is based on the Java Implementation used with the Cryptix toolkit found at:
//http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael.zip
//Java code authors: Raif S. Naffah, Paulo S. L. M. Barreto
//This Implementation was tested against KAT test published by the authors of the method and the
//results were identical.
class CRijndael
{
public:
//Operation Modes
//The Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB) modes
//are implemented.
//In ECB mode if the same block is encrypted twice with the same key, the resulting
//ciphertext blocks are the same.
//In CBC Mode a ciphertext block is obtained by first xoring the
//plaintext block with the previous ciphertext block, and encrypting the resulting value.
//In CFB mode a ciphertext block is obtained by encrypting the previous ciphertext block
//and xoring the resulting value with the plaintext.
enum { ECB = 0, CBC = 1, CFB = 2 };
private:
enum { DEFAULT_BLOCK_SIZE = 16 };
enum { MAX_BLOCK_SIZE = 32, MAX_ROUNDS = 14, MAX_KC = 8, MAX_BC = 8 };
//Auxiliary Functions
//Multiply two elements of GF(2^m)
static int Mul(int a, int b)
{
return (a != 0 && b != 0) ? sm_alog[(sm_log[a & 0xFF] + sm_log[b & 0xFF]) % 255] : 0;
}
//Convenience method used in generating Transposition Boxes
static int Mul4(int a, char b[])
{
if (a == 0)
return 0;
a = sm_log[a & 0xFF];
int a0 = (b[0] != 0) ? sm_alog[(a + sm_log[b[0] & 0xFF]) % 255] & 0xFF : 0;
int a1 = (b[1] != 0) ? sm_alog[(a + sm_log[b[1] & 0xFF]) % 255] & 0xFF : 0;
int a2 = (b[2] != 0) ? sm_alog[(a + sm_log[b[2] & 0xFF]) % 255] & 0xFF : 0;
int a3 = (b[3] != 0) ? sm_alog[(a + sm_log[b[3] & 0xFF]) % 255] & 0xFF : 0;
return a0 << 24 | a1 << 16 | a2 << 8 | a3;
}
public:
//CONSTRUCTOR
CRijndael();
//DESTRUCTOR
virtual ~CRijndael();
//Expand a user-supplied key material into a session key.
// key - The 128/192/256-bit user-key to use.
// chain - initial chain block for CBC and CFB modes.
// keylength - 16, 24 or 32 bytes
// blockSize - The block size in bytes of this Rijndael (16, 24 or 32 bytes).
void MakeKey(char const* key, char const* chain, int keylength = DEFAULT_BLOCK_SIZE, int blockSize = DEFAULT_BLOCK_SIZE);
private:
//Auxiliary Function
void Xor(char* buff, char const* chain)
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
for (int i = 0; i<m_blockSize; i++)
*(buff++) ^= *(chain++);
}
//Convenience method to encrypt exactly one block of plaintext, assuming
//Rijndael's default block size (128-bit).
// in - The plaintext
// result - The ciphertext generated from a plaintext using the key
void DefEncryptBlock(char const* in, char* result);
//Convenience method to decrypt exactly one block of plaintext, assuming
//Rijndael's default block size (128-bit).
// in - The ciphertext.
// result - The plaintext generated from a ciphertext using the session key.
void DefDecryptBlock(char const* in, char* result);
public:
//Encrypt exactly one block of plaintext.
// in - The plaintext.
// result - The ciphertext generated from a plaintext using the key.
void EncryptBlock(char const* in, char* result);
//Decrypt exactly one block of ciphertext.
// in - The ciphertext.
// result - The plaintext generated from a ciphertext using the session key.
void DecryptBlock(char const* in, char* result);
void Encrypt(char const* in, char* result, size_t n, int iMode = ECB);
void Decrypt(char const* in, char* result, size_t n, int iMode = ECB);
//Get Key Length
int GetKeyLength()
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
return m_keylength;
}
//Block Size
int GetBlockSize()
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
return m_blockSize;
}
//Number of Rounds
int GetRounds()
{
if (false == m_bKeyInit)
throw runtime_error(sm_szErrorMsg1);
return m_iROUNDS;
}
void ResetChain()
{
memcpy(m_chain, m_chain0, m_blockSize);
}
public:
//Null chain
static char const* sm_chain0;
private:
static const int sm_alog[256];
static const int sm_log[256];
static const char sm_S[256];
static const char sm_Si[256];
static const int sm_T1[256];
static const int sm_T2[256];
static const int sm_T3[256];
static const int sm_T4[256];
static const int sm_T5[256];
static const int sm_T6[256];
static const int sm_T7[256];
static const int sm_T8[256];
static const int sm_U1[256];
static const int sm_U2[256];
static const int sm_U3[256];
static const int sm_U4[256];
static const char sm_rcon[30];
static const int sm_shifts[3][4][2];
//Error Messages
static char const* sm_szErrorMsg1;
static char const* sm_szErrorMsg2;
//Key Initialization Flag
bool m_bKeyInit;
//Encryption (m_Ke) round key
int m_Ke[MAX_ROUNDS + 1][MAX_BC];
//Decryption (m_Kd) round key
int m_Kd[MAX_ROUNDS + 1][MAX_BC];
//Key Length
int m_keylength;
//Block Size
int m_blockSize;
//Number of Rounds
int m_iROUNDS;
//Chain Block
char m_chain0[MAX_BLOCK_SIZE];
char m_chain[MAX_BLOCK_SIZE];
//Auxiliary private use buffers
int tk[MAX_KC];
int a[MAX_BC];
int t[MAX_BC];
};
#endif // __RIJNDAEL_H__

View File

@@ -0,0 +1,128 @@
//DoubleBuffering.cpp Source File
#include "DoubleBuffering.h"
#include <cassert>
#include <exception>
#include <string.h>
using namespace std;
CDoubleBuffering::CDoubleBuffering(ifstream& in, char* pcBuff, int iSize, int iDataLen) : m_rin(in),
m_iDataLen(iDataLen), m_bEOF(false), m_iSize(iSize), m_iSize2(iSize >> 1), m_pcBuff(pcBuff)
{
//m_iSize should be even
if(m_iSize%2 != 0)
throw runtime_error("CDoubleBuffering: m_iSize should be Even Number!");
//Check file
if(!in.is_open() || in.bad())
throw runtime_error("CDoubleBuffering: Referenced File not Opened or in Bad State!");
//Check construction data
if(m_iDataLen<1 || m_iSize2<m_iDataLen)
throw runtime_error("CDoubleBuffering: Illegal Construction Data!");
in.read(m_pcBuff, m_iSize2);
m_iEnd = m_rin.gcount();
m_iCurPos = 0;
m_iBuf = 0;
}
int CDoubleBuffering::GetData(char* pszDataBuf, int iDataLen)
{
if(-1 == iDataLen)
iDataLen = m_iDataLen;
if(iDataLen<1 || m_iSize2<iDataLen)
throw runtime_error("CDoubleBuffering::GetData(): Illegal iDataLen!");
if(true == m_bEOF)
return 0;
//Estimate the next position
int iCurPos = m_iCurPos + iDataLen;
if(0 == m_iBuf) //First Buffer
{
if(iCurPos >= m_iEnd)
{
//Read the next buffer
if(m_rin.eof())
{
m_bEOF = true;
//Take everything remained
int iRead = m_iEnd-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
return iRead;
}
else
{
m_rin.read(m_pcBuff+m_iEnd, m_iSize2);
m_iEnd += m_rin.gcount();
if(iCurPos > m_iEnd) //Still greater, then EOF attained
{
assert(m_rin.eof());
m_bEOF = true;
//Take everything remained
int iRead = m_iEnd-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
return iRead;
}
else
{
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iDataLen);
m_iCurPos = iCurPos;
assert(m_iCurPos >= m_iSize2);
m_iBuf = 1;
return iDataLen;
}
}
}
else
{
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iDataLen);
m_iCurPos = iCurPos;
return iDataLen;
}
}
else //1 == m_iBuf, Second Buffer
{
if(iCurPos >= m_iEnd)
{
//Read the next buffer
if(m_rin.eof())
{
m_bEOF = true;
//Take everything remained
int iRead = m_iEnd-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
return iRead;
}
else
{
m_rin.read(m_pcBuff, m_iSize2);
m_iEnd = m_rin.gcount();
iCurPos %= m_iSize;
if(iCurPos > m_iEnd) //Still greater, then EOF attained
{
assert(m_rin.eof());
m_bEOF = true;
//Take everything remained
int iRead = m_iSize-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
memcpy(pszDataBuf+iRead, m_pcBuff, m_iEnd);
return iRead + m_iEnd;
}
else
{
int iRead = m_iSize-m_iCurPos;
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iRead);
memcpy(pszDataBuf+iRead, m_pcBuff, iDataLen-iRead);
m_iCurPos = iCurPos;
assert(m_iCurPos < m_iSize2);
m_iBuf = 0;
return iDataLen;
}
}
}
else
{
memcpy(pszDataBuf, m_pcBuff+m_iCurPos, iDataLen);
m_iCurPos = iCurPos;
return iDataLen;
}
}
}

View File

@@ -0,0 +1,40 @@
//DoubleBuffering.h Header File
#ifndef __DOUBLEBUFFERING_H__
#define __DOUBLEBUFFERING_H__
//Typical DISCLAIMER:
//The code in this project is Copyright (C) 2003 by George Anescu. You have the right to
//use and distribute the code in any way you see fit as long as this paragraph is included
//with the distribution. No warranties or claims are made as to the validity of the
//information and code contained herein, so use it at your own risk.
#include <fstream>
using namespace std;
class CDoubleBuffering
{
public:
//Constructor
CDoubleBuffering(ifstream& in, char* pcBuff, int iSize, int iDataLen);
//Get Next Data Buffer
int GetData(char* pszDataBuf, int iDataLen=-1);
private:
ifstream& m_rin;
int m_iSize;
int m_iSize2; //m_iSize/2
int m_iDataLen;
//Current Position
int m_iCurPos;
//End Position
int m_iEnd;
//Which Buffer
int m_iBuf;
char* m_pcBuff;
//EOF attained
bool m_bEOF;
};
#endif //__DOUBLEBUFFERING_H__

View File

@@ -0,0 +1,38 @@
//MessageDigest.cpp
#include "MessageDigest.h"
#include "DoubleBuffering.h"
#include <exception>
#include <fstream>
#include <strstream>
using namespace std;
//Digesting a Full File
void IMessageDigest::DigestFile(string const& rostrFileIn, char* pcDigest)
{
//Is the User's responsability to ensure that pcDigest is appropriately allocated
//Open Input File
ifstream in(rostrFileIn.c_str(), ios::binary);
if(!in)
{
ostrstream ostr;
ostr << "FileDigest ERROR: in IMessageDigest::DigestFile(): Cannot open File " << rostrFileIn << "!" << ends;
string ostrMsg = ostr.str();
ostr.freeze(false);
throw runtime_error(ostrMsg);
}
//Resetting first
Reset();
//Reading from file
char szLargeBuff[BUFF_LEN+1] = {0};
char szBuff[DATA_LEN+1] = {0};
CDoubleBuffering oDoubleBuffering(in, szLargeBuff, BUFF_LEN, DATA_LEN);
int iRead;
while((iRead=oDoubleBuffering.GetData(szBuff)) > 0)
AddData(szBuff, iRead);
in.close();
//Final Step
FinalDigest(pcDigest);
}

View File

@@ -0,0 +1,47 @@
//MessageDigest.h
#ifndef __MESSAGEDIGEST_H__
#define __MESSAGEDIGEST_H__
#include <string>
using namespace std;
//Typical DISCLAIMER:
//The code in this project is Copyright (C) 2003 by George Anescu. You have the right to
//use and distribute the code in any way you see fit as long as this paragraph is included
//with the distribution. No warranties or claims are made as to the validity of the
//information and code contained herein, so use it at your own risk.
//General Message Digest Interface
class IMessageDigest
{
public:
//CONSTRUCTOR
IMessageDigest() : m_bAddData(false) {}
//DESTRUCTOR
virtual ~IMessageDigest() {}
//Update context to reflect the concatenation of another buffer of bytes
virtual void AddData(char const* pcData, int iDataLength) = 0;
//Final wrapup - pad to BLOCKSIZE-byte boundary with the bit pattern
//10000...(64-bit count of bits processed, MSB-first)
virtual void FinalDigest(char* pcDigest) = 0;
//Reset current operation in order to prepare for a new one
virtual void Reset() = 0;
//Digesting a Full File
void DigestFile(string const& rostrFileIn, char* pcDigest);
protected:
enum { BLOCKSIZE=64 };
//Control Flag
bool m_bAddData;
//The core of the MessageDigest algorithm, this alters an existing MessageDigest hash to
//reflect the addition of 64 bytes of new data
virtual void Transform() = 0;
private:
enum { DATA_LEN=384, BUFF_LEN=1024 };
};
#endif // __MESSAGEDIGEST_H__

View File

@@ -0,0 +1,13 @@
#include "multi_emulator.h"
int GenerateOldRevEmu(void* pDest, int nSteamID)
{
auto pTicket = (int*)pDest;
auto pbTicket = (unsigned char*)pDest;
pTicket[0] = 0xFFFF; // +0, header
pTicket[1] = (nSteamID ^ 0xC9710266) << 1; // +4, SteamId
*(short *)&pbTicket[8] = 0; // +8, unknown, in original emulator must be 0
return 10;
}

27
3rdparty/MultiEmulator/src/RevEmu.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
#include "multi_emulator.h"
#include "StrUtils.h"
#include "RevSpoofer.h"
int GenerateRevEmu(void *pDest, int nSteamID)
{
char szhwid[64];
CreateRandomString(szhwid, 16);
if (!RevSpoofer::Spoof(szhwid, nSteamID))
return 0;
auto pTicket = (int *)pDest;
auto revHash = RevSpoofer::Hash(szhwid);
pTicket[0] = 'J'; // +0, header
pTicket[1] = revHash; // +4, hash of string at +24 offset
pTicket[2] = 'r' << 16 | 'e' << 8 | 'v';// +8, magic number
pTicket[3] = 0; // +12, unknown number, must always be 0
pTicket[4] = revHash << 1; // +16, SteamId, Low part
pTicket[5] = 0x01100001; // +20, SteamId, High part
strcpy((char *)&pTicket[6], szhwid); // +24, string for hash
return 152;
}

View File

@@ -0,0 +1,55 @@
#include "multi_emulator.h"
#include "StrUtils.h"
#include "RevSpoofer.h"
#include "CRijndael.h"
#include "SHA.h"
#include <time.h>
int GenerateRevEmu2013(void *pDest, int nSteamID)
{
char szhwid[64];
CreateRandomString(szhwid, 32);
if (!RevSpoofer::Spoof(szhwid, nSteamID))
return 0;
auto pTicket = (int *)pDest;
auto pbTicket = (unsigned char *)pDest;
auto revHash = RevSpoofer::Hash(szhwid);
pTicket[0] = 'S'; // +0
pTicket[1] = revHash; // +4
pTicket[2] = 'r' << 16 | 'e' << 8 | 'v';;// +8
pTicket[3] = 0; // +12
pTicket[4] = revHash << 1; // +16
pTicket[5] = 0x01100001; // +20
pTicket[6] = (int)time(0) + 90123; // +24
pbTicket[27] = ~(pbTicket[27] + pbTicket[24]);
pTicket[7] = ~(int)time(0); // +28
pTicket[8] = revHash * 2 >> 3; // +32
pTicket[9] = 0; // +36
static const char c_szAESKeyRand[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
char szAESHashRand[32];
auto AESRand = CRijndael();
AESRand.MakeKey(c_szAESKeyRand, CRijndael::sm_chain0, 32, 32);
AESRand.EncryptBlock(szhwid, szAESHashRand);
memcpy(&pbTicket[40], szAESHashRand, 32);
static const char c_szAESKeyRev[] = "_YOU_SERIOUSLY_NEED_TO_GET_LAID_";
char AESHashRev[32];
auto AESRev = CRijndael();
AESRev.MakeKey(c_szAESKeyRev, CRijndael::sm_chain0, 32, 32);
AESRev.EncryptBlock(c_szAESKeyRand, AESHashRev);
memcpy(&pbTicket[72], AESHashRev, 32);
char szSHAHash[32];
auto sha = CSHA(CSHA::SHA256);
sha.AddData(szhwid, 32);
sha.FinalDigest(szSHAHash);
memcpy(&pbTicket[104], szSHAHash, 32);
return 194;
}

View File

@@ -0,0 +1,96 @@
#include "RevSpoofer.h"
#include <string.h>
#define astrlen(x) sizeof(x) - 1
static char s_szDictionary[] = { "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
static int iInputLen;
static unsigned int uTreasure;
bool ScanLast3(char *pszInput, unsigned int uPrevHash)
{
unsigned int h1, h2, h3, hh;
for (int i1 = 0; i1 < astrlen(s_szDictionary); i1++)
{
h1 = uPrevHash ^ ((uPrevHash >> 2) + (uPrevHash << 5) + s_szDictionary[i1]);
hh = h1 ^ ((h1 >> 2) + (h1 << 5));
hh = hh ^ ((hh >> 2) + (hh << 5));
if ((hh ^ uTreasure) >> (8 + 5 + 3))
continue;
for (int i2 = 0; i2 < astrlen(s_szDictionary); i2++)
{
h2 = h1 ^ ((h1 >> 2) + (h1 << 5) + s_szDictionary[i2]);
hh = h2 ^ ((h2 >> 2) + (h2 << 5));
if ((hh ^ uTreasure) >> (8 + 3))
continue;
for (int i3 = 0; i3 < astrlen(s_szDictionary); i3++)
{
h3 = h2 ^ ((h2 >> 2) + (h2 << 5) + s_szDictionary[i3]);
if (h3 == uTreasure)
{
pszInput[iInputLen - 3] = s_szDictionary[i1];
pszInput[iInputLen - 2] = s_szDictionary[i2];
pszInput[iInputLen - 1] = s_szDictionary[i3];
return true;
}
}
}
}
return false;
}
bool ScanNext(char* pszInput, int uIndex, unsigned int uPrevHash)
{
bool res;
for (int i = 0; i < astrlen(s_szDictionary); i++)
{
auto h = uPrevHash ^ ((uPrevHash >> 2) + (uPrevHash << 5) + s_szDictionary[i]);
if (uIndex + 1 < iInputLen - 3)
res = ScanNext(pszInput, uIndex + 1, h);
else
res = ScanLast3(pszInput, h);
if (res)
{
pszInput[uIndex] = s_szDictionary[i];
return true;
}
}
return false;
}
namespace RevSpoofer
{
bool Spoof(char *pszDest, int uSID)
{
uTreasure = uSID;
iInputLen = strlen(pszDest);
auto i = iInputLen - 7;
i = (i < 0) ? 0 : i;
pszDest[i] = '\0';
auto h = Hash(pszDest);
return ScanNext(pszDest, i, h);
}
unsigned int Hash(char *pszString)
{
int i = 0;
unsigned int nHash = 0x4E67C6A7;
int c = pszString[i++];
while (c)
{
nHash = nHash ^ ((nHash >> 2) + (nHash << 5) + c);
c = pszString[i++];
}
return nHash;
}
}

View File

@@ -0,0 +1,7 @@
#pragma once
namespace RevSpoofer
{
bool Spoof(char *pszDest, int uSID);
unsigned int Hash(char *pszString);
}

52
3rdparty/MultiEmulator/src/SC2009.cpp vendored Normal file
View File

@@ -0,0 +1,52 @@
#include "multi_emulator.h"
#include "StrUtils.h"
#include "RevSpoofer.h"
#include "CRijndael.h"
#include "SHA.h"
int GenerateSC2009(void* pDest, int nSteamID)
{
char hwid[64];
CreateRandomString(hwid, 32);
if (!RevSpoofer::Spoof(hwid, nSteamID))
return 0;
auto pTicket = (int*)pDest;
auto pbTicket = (unsigned char*)pDest;
auto revHash = RevSpoofer::Hash(hwid);
pTicket[0] = 'S'; // +0
pTicket[1] = revHash; // +4
pTicket[2] = 'r' << 16 | 'e' << 8 | 'v';;// +8
pTicket[3] = 0; // +12
pTicket[4] = revHash << 1; // +16
pTicket[5] = 0x01100001; // +20
/* Encrypt HWID with AESKeyRand key and save it in the ticket. */
static const char AESKeyRand[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
char AESHashRand[32];
auto AESRand = CRijndael();
AESRand.MakeKey(AESKeyRand, CRijndael::sm_chain0, 32, 32);
AESRand.EncryptBlock(hwid, AESHashRand);
memcpy(&pbTicket[24], AESHashRand, 32);
/* Encrypt AESKeyRand with AESKeyRev key and save it in the ticket.
* AESKeyRev key is identical to the key in dproto/reunion. */
static const char AESKeyRev[] = "_YOU_SERIOUSLY_NEED_TO_GET_LAID_";
char AESHashRev[32];
auto AESRev = CRijndael();
AESRev.MakeKey(AESKeyRev, CRijndael::sm_chain0, 32, 32);
AESRev.EncryptBlock(AESKeyRand, AESHashRev);
memcpy(&pbTicket[56], AESHashRev, 32);
/* Perform HWID hashing and save hash to the ticket. */
char SHAHash[32];
auto sha = CSHA(CSHA::SHA256);
sha.AddData(hwid, 32);
sha.FinalDigest(SHAHash);
memcpy(&pbTicket[88], SHAHash, 32);
return 178;
}

734
3rdparty/MultiEmulator/src/SHA.cpp vendored Normal file
View File

@@ -0,0 +1,734 @@
//SHA.cpp
#include "SHA.h"
#include <exception>
#include <strstream>
#include <string.h>
using namespace std;
const unsigned int CSHA::sm_K160[4] =
{
0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
};
const unsigned int CSHA::sm_H160[SHA160LENGTH] =
{
0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0
};
const unsigned int CSHA::sm_K256[64] =
{
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
const unsigned int CSHA::sm_H256[SHA256LENGTH] =
{
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
const SUI64 CSHA::sm_H384[SHA512LENGTH] =
{
{0xcbbb9d5d, 0xc1059ed8},
{0x629a292a, 0x367cd507},
{0x9159015a, 0x3070dd17},
{0x152fecd8, 0xf70e5939},
{0x67332667, 0xffc00b31},
{0x8eb44a87, 0x68581511},
{0xdb0c2e0d, 0x64f98fa7},
{0x47b5481d, 0xbefa4fa4}
};
const SUI64 CSHA::sm_K512[80] =
{
{0x428a2f98, 0xd728ae22}, {0x71374491, 0x23ef65cd},
{0xb5c0fbcf, 0xec4d3b2f}, {0xe9b5dba5, 0x8189dbbc},
{0x3956c25b, 0xf348b538}, {0x59f111f1, 0xb605d019},
{0x923f82a4, 0xaf194f9b}, {0xab1c5ed5, 0xda6d8118},
{0xd807aa98, 0xa3030242}, {0x12835b01, 0x45706fbe},
{0x243185be, 0x4ee4b28c}, {0x550c7dc3, 0xd5ffb4e2},
{0x72be5d74, 0xf27b896f}, {0x80deb1fe, 0x3b1696b1},
{0x9bdc06a7, 0x25c71235}, {0xc19bf174, 0xcf692694},
{0xe49b69c1, 0x9ef14ad2}, {0xefbe4786, 0x384f25e3},
{0x0fc19dc6, 0x8b8cd5b5}, {0x240ca1cc, 0x77ac9c65},
{0x2de92c6f, 0x592b0275}, {0x4a7484aa, 0x6ea6e483},
{0x5cb0a9dc, 0xbd41fbd4}, {0x76f988da, 0x831153b5},
{0x983e5152, 0xee66dfab}, {0xa831c66d, 0x2db43210},
{0xb00327c8, 0x98fb213f}, {0xbf597fc7, 0xbeef0ee4},
{0xc6e00bf3, 0x3da88fc2}, {0xd5a79147, 0x930aa725},
{0x06ca6351, 0xe003826f}, {0x14292967, 0x0a0e6e70},
{0x27b70a85, 0x46d22ffc}, {0x2e1b2138, 0x5c26c926},
{0x4d2c6dfc, 0x5ac42aed}, {0x53380d13, 0x9d95b3df},
{0x650a7354, 0x8baf63de}, {0x766a0abb, 0x3c77b2a8},
{0x81c2c92e, 0x47edaee6}, {0x92722c85, 0x1482353b},
{0xa2bfe8a1, 0x4cf10364}, {0xa81a664b, 0xbc423001},
{0xc24b8b70, 0xd0f89791}, {0xc76c51a3, 0x0654be30},
{0xd192e819, 0xd6ef5218}, {0xd6990624, 0x5565a910},
{0xf40e3585, 0x5771202a}, {0x106aa070, 0x32bbd1b8},
{0x19a4c116, 0xb8d2d0c8}, {0x1e376c08, 0x5141ab53},
{0x2748774c, 0xdf8eeb99}, {0x34b0bcb5, 0xe19b48a8},
{0x391c0cb3, 0xc5c95a63}, {0x4ed8aa4a, 0xe3418acb},
{0x5b9cca4f, 0x7763e373}, {0x682e6ff3, 0xd6b2b8a3},
{0x748f82ee, 0x5defb2fc}, {0x78a5636f, 0x43172f60},
{0x84c87814, 0xa1f0ab72}, {0x8cc70208, 0x1a6439ec},
{0x90befffa, 0x23631e28}, {0xa4506ceb, 0xde82bde9},
{0xbef9a3f7, 0xb2c67915}, {0xc67178f2, 0xe372532b},
{0xca273ece, 0xea26619c}, {0xd186b8c7, 0x21c0c207},
{0xeada7dd6, 0xcde0eb1e}, {0xf57d4f7f, 0xee6ed178},
{0x06f067aa, 0x72176fba}, {0x0a637dc5, 0xa2c898a6},
{0x113f9804, 0xbef90dae}, {0x1b710b35, 0x131c471b},
{0x28db77f5, 0x23047d84}, {0x32caab7b, 0x40c72493},
{0x3c9ebe0a, 0x15c9bebc}, {0x431d67c4, 0x9c100d4c},
{0x4cc5d4be, 0xcb3e42b6}, {0x597f299c, 0xfc657e2a},
{0x5fcb6fab, 0x3ad6faec}, {0x6c44198c, 0x4a475817}
};
const SUI64 CSHA::sm_H512[SHA512LENGTH] =
{
{0x6a09e667, 0xf3bcc908},
{0xbb67ae85, 0x84caa73b},
{0x3c6ef372, 0xfe94f82b},
{0xa54ff53a, 0x5f1d36f1},
{0x510e527f, 0xade682d1},
{0x9b05688c, 0x2b3e6c1f},
{0x1f83d9ab, 0xfb41bd6b},
{0x5be0cd19, 0x137e2179}
};
//CONSTRUCTOR
CSHA::CSHA(int iMethod)
{
//Check the method
switch(iMethod)
{
case SHA160:
{
for(int i=0; i<SHA160LENGTH; i++)
m_auiBuf[i] = sm_H160[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA256:
{
for(int i=0; i<SHA256LENGTH; i++)
m_auiBuf[i] = sm_H256[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA384:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H384[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
break;
case SHA512:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H512[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
break;
default:
{
ostrstream ostr;
ostr << "FileDigest ERROR: in CSHA() Constructor, Illegal Method " << iMethod << "!" << ends;
string ostrMsg = ostr.str();
ostr.freeze(false);
throw runtime_error(ostrMsg);
}
}
m_iMethod = iMethod;
}
//Update context to reflect the concatenation of another buffer of bytes.
void CSHA::AddData(char const* pcData, int iDataLength)
{
if(iDataLength < 0)
throw runtime_error(string("FileDigest ERROR: in CSHA::AddData(), Data Length should be >= 0!"));
unsigned int uiT;
switch(m_iMethod)
{
case SHA160:
case SHA256:
{
//Update bitcount
uiT = m_auiBits[0];
if((m_auiBits[0] = uiT + ((unsigned int)iDataLength << 3)) < uiT)
m_auiBits[1]++; //Carry from low to high
m_auiBits[1] += iDataLength >> 29;
uiT = (uiT >> 3) & (BLOCKSIZE-1); //Bytes already
//Handle any leading odd-sized chunks
if(uiT != 0)
{
unsigned char* puc = (unsigned char*)m_aucIn + uiT;
uiT = BLOCKSIZE - uiT;
if(iDataLength < uiT)
{
memcpy(puc, pcData, iDataLength);
return;
}
memcpy(puc, pcData, uiT);
Transform();
pcData += uiT;
iDataLength -= uiT;
}
//Process data in 64-byte chunks
while(iDataLength >= BLOCKSIZE)
{
memcpy(m_aucIn, pcData, BLOCKSIZE);
Transform();
pcData += BLOCKSIZE;
iDataLength -= BLOCKSIZE;
}
//Handle any remaining bytes of data
memcpy(m_aucIn, pcData, iDataLength);
}
break;
case SHA384:
case SHA512:
{
uiT = m_aoui64Bits[0].m_uiRight;
unsigned int uiU = m_aoui64Bits[0].m_uiLeft;
if((m_aoui64Bits[0].m_uiRight = uiT + ((unsigned int)iDataLength << 3)) < uiT)
m_aoui64Bits[0].m_uiLeft++; //Carry from low to high
unsigned int uiV = m_aoui64Bits[1].m_uiRight;
if((m_aoui64Bits[0].m_uiLeft += iDataLength >> 29) < uiU)
m_aoui64Bits[1].m_uiRight++;
if(m_aoui64Bits[1].m_uiRight < uiV)
m_aoui64Bits[1].m_uiLeft++;
uiT = (uiT >> 3) & (BLOCKSIZE2-1); //Bytes already
//Handle any leading odd-sized chunks
if(uiT != 0)
{
unsigned char* puc = (unsigned char*)m_aucIn + uiT;
uiT = BLOCKSIZE2 - uiT;
if(iDataLength < uiT)
{
memcpy(puc, pcData, iDataLength);
return;
}
memcpy(puc, pcData, uiT);
Transform();
pcData += uiT;
iDataLength -= uiT;
}
//Process data in 64-byte chunks
while(iDataLength >= BLOCKSIZE2)
{
memcpy(m_aucIn, pcData, BLOCKSIZE2);
Transform();
pcData += BLOCKSIZE2;
iDataLength -= BLOCKSIZE2;
}
//Handle any remaining bytes of data
memcpy(m_aucIn, pcData, iDataLength);
}
break;
}
//Set the flag
m_bAddData = true;
}
//Final wrapup - pad to 64-byte boundary with the bit pattern
//1 0*(64-bit count of bits processed, MSB-first)
void CSHA::FinalDigest(char* pcDigest)
{
//Is the User's responsability to ensure that pcDigest is properly allocated 20, 32,
//48 or 64 bytes, depending on the method
if(false == m_bAddData)
throw runtime_error(string("FileDigest ERROR: in CSHA::FinalDigest(), No data Added before call!"));
switch(m_iMethod)
{
case SHA160:
case SHA256:
{
unsigned int uiCount;
unsigned char *puc;
//Compute number of bytes mod 64
uiCount = (m_auiBits[0] >> 3) & (BLOCKSIZE-1);
//Set the first char of padding to 0x80. This is safe since there is
//always at least one byte free
puc = m_aucIn + uiCount;
*puc++ = 0x80;
//Bytes of padding needed to make 64 bytes
uiCount = BLOCKSIZE - uiCount - 1;
//Pad out to 56 mod 64
if(uiCount < 8)
{
//Two lots of padding: Pad the first block to 64 bytes
memset(puc, 0, uiCount);
Transform();
//Now fill the next block with 56 bytes
memset(m_aucIn, 0, BLOCKSIZE-8);
}
else
{
//Pad block to 56 bytes
memset(puc, 0, uiCount - 8);
}
//Append length in bits and transform
Word2Bytes(m_auiBits[1], &m_aucIn[BLOCKSIZE-8]);
Word2Bytes(m_auiBits[0], &m_aucIn[BLOCKSIZE-4]);
Transform();
switch(m_iMethod)
{
case SHA160:
{
for(int i=0; i<SHA160LENGTH; i++,pcDigest+=4)
Word2Bytes(m_auiBuf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
case SHA256:
{
for(int i=0; i<SHA256LENGTH; i++,pcDigest+=4)
Word2Bytes(m_auiBuf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
}
}
break;
case SHA384:
case SHA512:
{
unsigned char *puc;
//Compute number of bytes mod 128
unsigned int uiCount = (m_aoui64Bits[0].m_uiRight >> 3) & (BLOCKSIZE2-1);
//Set the first char of padding to 0x80. This is safe since there is
//always at least one byte free
puc = m_aucIn + uiCount;
*puc++ = 0x80;
//Bytes of padding needed to make 128 bytes
uiCount = BLOCKSIZE2 - uiCount - 1;
//Pad out to 112 mod 128
if(uiCount < 16)
{
//Two lots of padding: Pad the first block to 128 bytes
memset(puc, 0, uiCount);
Transform();
//Now fill the next block with 112 bytes
memset(m_aucIn, 0, BLOCKSIZE2-16);
}
else
{
//Pad block to 112 bytes
memset(puc, 0, uiCount - 16);
}
//Append length in bits and transform
Word2Bytes(m_aoui64Bits[1], &m_aucIn[BLOCKSIZE2-16]);
Word2Bytes(m_aoui64Bits[0], &m_aucIn[BLOCKSIZE2-8]);
Transform();
switch(m_iMethod)
{
case SHA384:
{
for(int i=0; i<SHA384LENGTH; i++,pcDigest+=8)
Word2Bytes(m_aoui64Buf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
case SHA512:
{
for(int i=0; i<SHA512LENGTH; i++,pcDigest+=8)
Word2Bytes(m_aoui64Buf[i], reinterpret_cast<unsigned char*>(pcDigest));
}
break;
}
}
break;
}
//Reinitialize
Reset();
}
//Reset current operation in order to prepare a new one
void CSHA::Reset()
{
//Reinitialize
switch(m_iMethod)
{
case SHA160:
{
for(int i=0; i<SHA160LENGTH; i++)
m_auiBuf[i] = sm_H160[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA256:
{
for(int i=0; i<SHA256LENGTH; i++)
m_auiBuf[i] = sm_H256[i];
m_auiBits[0] = 0;
m_auiBits[1] = 0;
}
break;
case SHA384:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H384[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
break;
case SHA512:
{
for(int i=0; i<SHA512LENGTH; i++)
m_aoui64Buf[i] = sm_H512[i];
m_aoui64Bits[0].m_uiLeft = 0;
m_aoui64Bits[0].m_uiRight = 0;
m_aoui64Bits[1].m_uiLeft = 0;
m_aoui64Bits[1].m_uiRight = 0;
}
}
//Reset the flag
m_bAddData = false;
}
//The core of the SHA algorithm, this alters an existing SHA hash to
//reflect the addition of 16 longwords of new data.
void CSHA::Transform()
{
switch(m_iMethod)
{
case SHA160:
{
//Expansion of m_aucIn
unsigned char* pucIn = m_aucIn;
unsigned int auiW[80];
int i;
for(i=0; i<16; i++,pucIn+=4)
Bytes2Word(pucIn, auiW[i]);
for(i=16; i<80; i++)
auiW[i] = CircularShift(1, auiW[i-3]^auiW[i-8]^auiW[i-14]^auiW[i-16]);
unsigned int temp;
unsigned int A, B, C, D, E;
A = m_auiBuf[0];
B = m_auiBuf[1];
C = m_auiBuf[2];
D = m_auiBuf[3];
E = m_auiBuf[4];
for(i=0; i<20; i++)
{
temp = CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + auiW[i] + sm_K160[0];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for(i=20; i<40; i++)
{
temp = CircularShift(5, A) + (B ^ C ^ D) + E + auiW[i] + sm_K160[1];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for(i=40; i<60; i++)
{
temp = CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + auiW[i] + sm_K160[2];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for(i=60; i<80; i++)
{
temp = CircularShift(5, A) + (B ^ C ^ D) + E + auiW[i] + sm_K160[3];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
m_auiBuf[0] += A;
m_auiBuf[1] += B;
m_auiBuf[2] += C;
m_auiBuf[3] += D;
m_auiBuf[4] += E;
}
break;
case SHA256:
{
//Expansion of m_aucIn
unsigned char* pucIn = m_aucIn;
unsigned int auiW[64];
int i;
for(i=0; i<16; i++,pucIn+=4)
Bytes2Word(pucIn, auiW[i]);
for(i=16; i<64; i++)
auiW[i] = sig1(auiW[i-2]) + auiW[i-7] + sig0(auiW[i-15]) + auiW[i-16];
//OR
//for(i=0; i<48; i++)
// auiW[i+16] = sig1(auiW[i+14]) + auiW[i+9] + sig0(auiW[i+1]) + auiW[i];
unsigned int a, b, c, d, e, f, g, h, t;
a = m_auiBuf[0];
b = m_auiBuf[1];
c = m_auiBuf[2];
d = m_auiBuf[3];
e = m_auiBuf[4];
f = m_auiBuf[5];
g = m_auiBuf[6];
h = m_auiBuf[7];
t = h + SIG1(e) + CH(e, f, g) + sm_K256[0] + auiW[0]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[1] + auiW[1]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[2] + auiW[2]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[3] + auiW[3]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[4] + auiW[4]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[5] + auiW[5]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[6] + auiW[6]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[7] + auiW[7]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[8] + auiW[8]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[9] + auiW[9]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[10] + auiW[10]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[11] + auiW[11]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[12] + auiW[12]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[13] + auiW[13]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[14] + auiW[14]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[15] + auiW[15]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[16] + auiW[16]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[17] + auiW[17]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[18] + auiW[18]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[19] + auiW[19]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[20] + auiW[20]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[21] + auiW[21]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[22] + auiW[22]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[23] + auiW[23]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[24] + auiW[24]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[25] + auiW[25]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[26] + auiW[26]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[27] + auiW[27]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[28] + auiW[28]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[29] + auiW[29]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[30] + auiW[30]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[31] + auiW[31]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[32] + auiW[32]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[33] + auiW[33]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[34] + auiW[34]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[35] + auiW[35]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[36] + auiW[36]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[37] + auiW[37]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[38] + auiW[38]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[39] + auiW[39]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[40] + auiW[40]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[41] + auiW[41]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[42] + auiW[42]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[43] + auiW[43]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[44] + auiW[44]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[45] + auiW[45]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[46] + auiW[46]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[47] + auiW[47]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[48] + auiW[48]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[49] + auiW[49]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[50] + auiW[50]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[51] + auiW[51]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[52] + auiW[52]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[53] + auiW[53]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[54] + auiW[54]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[55] + auiW[55]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K256[56] + auiW[56]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K256[57] + auiW[57]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K256[58] + auiW[58]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K256[59] + auiW[59]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K256[60] + auiW[60]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K256[61] + auiW[61]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K256[62] + auiW[62]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K256[63] + auiW[63]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
//OR
/*
unsigned int a, b, c, d, e, f, g, h, t1, t2;
a = m_auiBuf[0];
b = m_auiBuf[1];
c = m_auiBuf[2];
d = m_auiBuf[3];
e = m_auiBuf[4];
f = m_auiBuf[5];
g = m_auiBuf[6];
h = m_auiBuf[7];
//
for(i=0; i<64; i++)
{
t1 = h + SIG1(e) + CH(e, f, g) + sm_K256[i] + auiW[i];
t2 = SIG0(a) + MAJ(a, b, c);
h = g;
g = f;
f = e;
e = d+t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
*/
m_auiBuf[0] += a;
m_auiBuf[1] += b;
m_auiBuf[2] += c;
m_auiBuf[3] += d;
m_auiBuf[4] += e;
m_auiBuf[5] += f;
m_auiBuf[6] += g;
m_auiBuf[7] += h;
}
break;
case SHA384:
case SHA512:
{
//Expansion of m_aucIn
unsigned char* pucIn = m_aucIn;
SUI64 aoui64W[80];
int i;
for(i=0; i<16; i++,pucIn+=8)
Bytes2Word(pucIn, aoui64W[i]);
for(i=16; i<80; i++)
aoui64W[i] = sig1(aoui64W[i-2]) + aoui64W[i-7] + sig0(aoui64W[i-15]) + aoui64W[i-16];
SUI64 a, b, c, d, e, f, g, h, t;
a = m_aoui64Buf[0];
b = m_aoui64Buf[1];
c = m_aoui64Buf[2];
d = m_aoui64Buf[3];
e = m_aoui64Buf[4];
f = m_aoui64Buf[5];
g = m_aoui64Buf[6];
h = m_aoui64Buf[7];
t = h + SIG1(e) + CH(e, f, g) + sm_K512[0] + aoui64W[0]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[1] + aoui64W[1]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[2] + aoui64W[2]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[3] + aoui64W[3]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[4] + aoui64W[4]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[5] + aoui64W[5]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[6] + aoui64W[6]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[7] + aoui64W[7]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[8] + aoui64W[8]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[9] + aoui64W[9]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[10] + aoui64W[10]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[11] + aoui64W[11]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[12] + aoui64W[12]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[13] + aoui64W[13]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[14] + aoui64W[14]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[15] + aoui64W[15]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[16] + aoui64W[16]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[17] + aoui64W[17]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[18] + aoui64W[18]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[19] + aoui64W[19]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[20] + aoui64W[20]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[21] + aoui64W[21]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[22] + aoui64W[22]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[23] + aoui64W[23]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[24] + aoui64W[24]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[25] + aoui64W[25]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[26] + aoui64W[26]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[27] + aoui64W[27]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[28] + aoui64W[28]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[29] + aoui64W[29]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[30] + aoui64W[30]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[31] + aoui64W[31]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[32] + aoui64W[32]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[33] + aoui64W[33]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[34] + aoui64W[34]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[35] + aoui64W[35]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[36] + aoui64W[36]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[37] + aoui64W[37]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[38] + aoui64W[38]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[39] + aoui64W[39]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[40] + aoui64W[40]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[41] + aoui64W[41]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[42] + aoui64W[42]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[43] + aoui64W[43]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[44] + aoui64W[44]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[45] + aoui64W[45]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[46] + aoui64W[46]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[47] + aoui64W[47]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[48] + aoui64W[48]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[49] + aoui64W[49]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[50] + aoui64W[50]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[51] + aoui64W[51]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[52] + aoui64W[52]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[53] + aoui64W[53]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[54] + aoui64W[54]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[55] + aoui64W[55]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[56] + aoui64W[56]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[57] + aoui64W[57]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[58] + aoui64W[58]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[59] + aoui64W[59]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[60] + aoui64W[60]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[61] + aoui64W[61]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[62] + aoui64W[62]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[63] + aoui64W[63]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[64] + aoui64W[64]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[65] + aoui64W[65]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[66] + aoui64W[66]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[67] + aoui64W[67]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[68] + aoui64W[68]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[69] + aoui64W[69]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[70] + aoui64W[70]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[71] + aoui64W[71]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
t = h + SIG1(e) + CH(e, f, g) + sm_K512[72] + aoui64W[72]; h = t + SIG0(a) + MAJ(a, b, c); d += t;
t = g + SIG1(d) + CH(d, e, f) + sm_K512[73] + aoui64W[73]; g = t + SIG0(h) + MAJ(h, a, b); c += t;
t = f + SIG1(c) + CH(c, d, e) + sm_K512[74] + aoui64W[74]; f = t + SIG0(g) + MAJ(g, h, a); b += t;
t = e + SIG1(b) + CH(b, c, d) + sm_K512[75] + aoui64W[75]; e = t + SIG0(f) + MAJ(f, g, h); a += t;
t = d + SIG1(a) + CH(a, b, c) + sm_K512[76] + aoui64W[76]; d = t + SIG0(e) + MAJ(e, f, g); h += t;
t = c + SIG1(h) + CH(h, a, b) + sm_K512[77] + aoui64W[77]; c = t + SIG0(d) + MAJ(d, e, f); g += t;
t = b + SIG1(g) + CH(g, h, a) + sm_K512[78] + aoui64W[78]; b = t + SIG0(c) + MAJ(c, d, e); f += t;
t = a + SIG1(f) + CH(f, g, h) + sm_K512[79] + aoui64W[79]; a = t + SIG0(b) + MAJ(b, c, d); e += t;
//
m_aoui64Buf[0] += a;
m_aoui64Buf[1] += b;
m_aoui64Buf[2] += c;
m_aoui64Buf[3] += d;
m_aoui64Buf[4] += e;
m_aoui64Buf[5] += f;
m_aoui64Buf[6] += g;
m_aoui64Buf[7] += h;
}
break;
}
}

379
3rdparty/MultiEmulator/src/SHA.h vendored Normal file
View File

@@ -0,0 +1,379 @@
//SHA.h
#ifndef __SHA_H__
#define __SHA_H__
#include "MessageDigest.h"
//Typical DISCLAIMER:
//The code in this project is Copyright (C) 2003 by George Anescu. You have the right to
//use and distribute the code in any way you see fit as long as this paragraph is included
//with the distribution. No warranties or claims are made as to the validity of the
//information and code contained herein, so use it at your own risk.
//Structure for representing an Unsigned Integer on 64 bits
struct SUI64
{
//Data
unsigned int m_uiLeft;
unsigned int m_uiRight;
//Operators
SUI64& operator++()
{
unsigned int uiTemp = m_uiRight;
m_uiRight++;
if(m_uiRight < uiTemp)
m_uiLeft++;
return *this;
}
SUI64& operator--()
{
unsigned int uiTemp = m_uiRight;
m_uiRight--;
if(m_uiRight > uiTemp)
m_uiLeft--;
return *this;
}
SUI64& operator+=(SUI64 const& roUI64)
{
m_uiRight += roUI64.m_uiRight;
if(m_uiRight < roUI64.m_uiRight)
m_uiLeft++;
m_uiLeft += roUI64.m_uiLeft;
return *this;
}
SUI64& operator|=(SUI64 const& roUI64)
{
m_uiRight |= roUI64.m_uiRight;
m_uiLeft |= roUI64.m_uiLeft;
return *this;
}
SUI64& operator&=(SUI64 const& roUI64)
{
m_uiRight &= roUI64.m_uiRight;
m_uiLeft &= roUI64.m_uiLeft;
return *this;
}
SUI64& operator^=(SUI64 const& roUI64)
{
m_uiRight ^= roUI64.m_uiRight;
m_uiLeft ^= roUI64.m_uiLeft;
return *this;
}
SUI64& operator<<=(unsigned int uiBits)
{
if(uiBits < 32)
{
(m_uiLeft <<= uiBits) |= (m_uiRight >> (32-uiBits));
m_uiRight <<= uiBits;
}
else
{
m_uiLeft = m_uiRight << (uiBits-32);
m_uiRight = 0;
}
return *this;
}
SUI64& operator>>=(unsigned int uiBits)
{
if(uiBits < 32)
{
(m_uiRight >>= uiBits) |= (m_uiLeft << (32-uiBits));
m_uiLeft >>= uiBits;
}
else
{
m_uiRight = m_uiLeft >> (uiBits-32);
m_uiLeft = 0;
}
return *this;
}
bool operator>(SUI64 const& roUI64) const
{
if(m_uiLeft == roUI64.m_uiLeft)
return m_uiRight > roUI64.m_uiRight;
else
return m_uiLeft > roUI64.m_uiLeft;
}
bool operator<(SUI64 const& roUI64) const
{
if(m_uiLeft == roUI64.m_uiLeft)
return m_uiRight < roUI64.m_uiRight;
else
return m_uiLeft < roUI64.m_uiLeft;
}
};
inline SUI64 operator+(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp += roUI64_2;
return temp;
}
inline SUI64 operator|(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp |= roUI64_2;
return temp;
}
inline SUI64 operator&(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp &= roUI64_2;
return temp;
}
inline SUI64 operator^(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
SUI64 temp = roUI64_1;
temp ^= roUI64_2;
return temp;
}
inline SUI64 operator<<(SUI64 const& roUI64, unsigned int uiBits)
{
SUI64 temp = roUI64;
temp <<= uiBits;
return temp;
}
inline SUI64 operator>>(SUI64 const& roUI64, unsigned int uiBits)
{
SUI64 temp = roUI64;
temp >>= uiBits;
return temp;
}
inline bool operator>(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
return roUI64_1.operator>(roUI64_2);
}
inline bool operator<(SUI64 const& roUI64_1, SUI64 const& roUI64_2)
{
return roUI64_1.operator<(roUI64_2);
}
//SHA Message Digest algorithm
//SHA160 TEST VALUES:
//1)"abc"
//"A9993E364706816ABA3E25717850C26C9CD0D89D"
//
//2)"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
//"84983E441C3BD26EBAAE4AA1F95129E5E54670F1"
//
//3)1,000,000 repetitions of "a".
//"34AA973CD4C4DAA4F61EEB2BDBAD27316534016F"
//
//SHA256 TEST VALUES:
//1)One-Block Message "abc"
//"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
//
//2)"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
//"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
//
//3)Multi-Block Message "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
//"CF5B16A778AF8380036CE59E7B0492370B249B11E8F07A51AFAC45037AFEE9D1"
//
//4)Long Message "a" 1,000,000 times
//"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"
//
//SHA384 TEST VALUES:
//1)One-Block Message "abc"
//"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"
//
//2)Multi-Block Message "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
//"09330C33F71147E83D192FC782CD1B4753111B173B3B05D22FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039"
//
//3)Long Message "a" 1,000,000 times
//"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"
//
//SHA512 TEST VALUES:
//1)One-Block Message "abc"
//"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a8
//36ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"
//
//2)"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
//"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4
//331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"
//
//3)""
//"CF83E1357EEFB8BDF1542850D66D8007D620E4050B5715DC83F4A921D36CE9CE47D0D13C5D85F2B0
//FF8318D2877EEC2F63B931BD47417A81A538327AF927DA3E"
//
//4)Long Message "a" 1,000,000 times
//"E718483D0CE769644E2E42C7BC15B4638E1F98B13B2044285632A803AFA973EBDE0FF244877EA60A
//4CB0432CE577C31BEB009C5C2C49AA2E4EADB217AD8CC09B"
class CSHA : public IMessageDigest
{
public:
enum { SHA160=0, SHA256=1, SHA384=2, SHA512=3 };
//CONSTRUCTOR
CSHA(int iMethod=SHA160);
//Update context to reflect the concatenation of another buffer of bytes.
void AddData(char const* pcData, int iDataLength);
//Final wrapup - pad to 64-byte boundary with the bit pattern
//1 0*(64-bit count of bits processed, MSB-first)
void FinalDigest(char* pcDigest);
//Reset current operation in order to prepare a new one
void Reset();
private:
//Transformation Function
void Transform();
//The Method
int m_iMethod;
enum { BLOCKSIZE2 = BLOCKSIZE<<1 };
//For 32 bits Integers
enum { SHA160LENGTH=5, SHA256LENGTH=8 };
//Context Variables
unsigned int m_auiBuf[SHA256LENGTH]; //Maximum for SHA256
unsigned int m_auiBits[2];
unsigned char m_aucIn[BLOCKSIZE2]; //128 bytes for SHA384, SHA512
//Internal auxiliary static functions
static unsigned int CircularShift(unsigned int uiBits, unsigned int uiWord);
static unsigned int CH(unsigned int x, unsigned int y, unsigned int z);
static unsigned int MAJ(unsigned int x, unsigned int y, unsigned int z);
static unsigned int SIG0(unsigned int x);
static unsigned int SIG1(unsigned int x);
static unsigned int sig0(unsigned int x);
static unsigned int sig1(unsigned int x);
static void Bytes2Word(unsigned char const* pcBytes, unsigned int& ruiWord);
static void Word2Bytes(unsigned int const& ruiWord, unsigned char* pcBytes);
static const unsigned int sm_K160[4];
static const unsigned int sm_H160[SHA160LENGTH];
static const unsigned int sm_K256[64];
static const unsigned int sm_H256[SHA256LENGTH];
//For 64 bits Integers
enum { SHA384LENGTH=6, SHA512LENGTH=8 };
//Context Variables
SUI64 m_aoui64Buf[SHA512LENGTH]; //Maximum for SHA512
SUI64 m_aoui64Bits[2];
//Internal auxiliary static functions
static SUI64 CircularShift(unsigned int uiBits, SUI64 const& roui64Word);
static SUI64 CH(SUI64 const& x, SUI64 const& y, SUI64 const& z);
static SUI64 MAJ(SUI64 const& x, SUI64 const& y, SUI64 const& z);
static SUI64 SIG0(SUI64 const& x);
static SUI64 SIG1(SUI64 const& x);
static SUI64 sig0(SUI64 const& x);
static SUI64 sig1(SUI64 const& x);
static void Bytes2Word(unsigned char const* pcBytes, SUI64& ruiWord);
static void Word2Bytes(SUI64 const& ruiWord, unsigned char* pcBytes);
static const SUI64 sm_H384[SHA512LENGTH]; //Dim is as 512
static const SUI64 sm_K512[80];
static const SUI64 sm_H512[SHA512LENGTH];
};
inline unsigned int CSHA::CircularShift(unsigned int uiBits, unsigned int uiWord)
{
return (uiWord << uiBits) | (uiWord >> (32-uiBits));
}
inline unsigned int CSHA::CH(unsigned int x, unsigned int y, unsigned int z)
{
return ((x&(y^z))^z);
}
inline unsigned int CSHA::MAJ(unsigned int x, unsigned int y, unsigned int z)
{
return (((x|y)&z)|(x&y));
}
inline unsigned int CSHA::SIG0(unsigned int x)
{
return ((x >> 2)|(x << 30)) ^ ((x >> 13)|(x << 19)) ^ ((x >> 22)|(x << 10));
}
inline unsigned int CSHA::SIG1(unsigned int x)
{
return ((x >> 6)|(x << 26)) ^ ((x >> 11)|(x << 21)) ^ ((x >> 25)|(x << 7));
}
inline unsigned int CSHA::sig0(unsigned int x)
{
return ((x >> 7)|(x << 25)) ^ ((x >> 18)|(x << 14)) ^ (x >> 3);
}
inline unsigned int CSHA::sig1(unsigned int x)
{
return ((x >> 17)|(x << 15)) ^ ((x >> 19)|(x << 13)) ^ (x >> 10);
}
inline void CSHA::Bytes2Word(unsigned char const* pcBytes, unsigned int& ruiWord)
{
ruiWord = (unsigned int)*(pcBytes+3) | (unsigned int)(*(pcBytes+2)<<8) |
(unsigned int)(*(pcBytes+1)<<16) | (unsigned int)(*pcBytes<<24);
}
inline void CSHA::Word2Bytes(unsigned int const& ruiWord, unsigned char* pcBytes)
{
pcBytes += 3;
*pcBytes = ruiWord & 0xff;
*--pcBytes = (ruiWord>>8) & 0xff;
*--pcBytes = (ruiWord>>16) & 0xff;
*--pcBytes = (ruiWord>>24) & 0xff;
}
inline SUI64 CSHA::CircularShift(unsigned int uiBits, SUI64 const& roui64Word)
{
return (roui64Word << uiBits) | (roui64Word >> (64-uiBits));
}
inline SUI64 CSHA::CH(SUI64 const& x, SUI64 const& y, SUI64 const& z)
{
return ((x&(y^z))^z);
}
inline SUI64 CSHA::MAJ(SUI64 const& x, SUI64 const& y, SUI64 const& z)
{
return (((x|y)&z)|(x&y));
}
inline SUI64 CSHA::SIG0(SUI64 const& x)
{
return ((x >> 28)|(x << 36)) ^ ((x >> 34)|(x << 30)) ^ ((x >> 39)|(x << 25));
}
inline SUI64 CSHA::SIG1(SUI64 const& x)
{
return ((x >> 14)|(x << 50)) ^ ((x >> 18)|(x << 46)) ^ ((x >> 41)|(x << 23));
}
inline SUI64 CSHA::sig0(SUI64 const& x)
{
return ((x >> 1)|(x << 63)) ^ ((x >> 8)|(x << 56)) ^ (x >> 7);
}
inline SUI64 CSHA::sig1(SUI64 const& x)
{
return ((x >> 19)|(x << 45)) ^ ((x >> 61)|(x << 3)) ^ (x >> 6);
}
inline void CSHA::Bytes2Word(unsigned char const* pcBytes, SUI64& ruiWord)
{
Bytes2Word(pcBytes+4, ruiWord.m_uiRight);
Bytes2Word(pcBytes, ruiWord.m_uiLeft);
}
inline void CSHA::Word2Bytes(SUI64 const& ruiWord, unsigned char* pcBytes)
{
Word2Bytes(ruiWord.m_uiRight, pcBytes+4);
Word2Bytes(ruiWord.m_uiLeft, pcBytes);
}
#endif // __SHA_H__

13
3rdparty/MultiEmulator/src/Setti.cpp vendored Normal file
View File

@@ -0,0 +1,13 @@
#include "multi_emulator.h"
int GenerateSetti(void *pDest)
{
auto pTicket = (int *)pDest;
pTicket[0] = 0xD4CA7F7B;
pTicket[1] = 0xC7DB6023;
pTicket[2] = 0x6D6A2E1F;
pTicket[5] = 0xB4C43105;
return 768;
}

18
3rdparty/MultiEmulator/src/SteamEmu.cpp vendored Normal file
View File

@@ -0,0 +1,18 @@
#include "multi_emulator.h"
int GenerateSteamEmu(void *pDest, int nSteamID)
{
auto pTicket = (int *)pDest;
pTicket[20] = -1; // +80, dproto/reunion wants this value to be -1, but if this value
// does not match -1, then instead of SteamID in [21] cell
// client IP address that xored with 0x25730981 number should
// be used. But dproto/reunion will just skip ticket validation
// in that case.
pTicket[21] = nSteamID; // +84, SteamId, low part. Actually, this is just system volume serial
// number, which comes from GetVolumeInformationA() function. If
// function failed (returned 0), then instead of volume serial number
// 777 number will be written to the ticket.
return 768;
}

12
3rdparty/MultiEmulator/src/StrUtils.cpp vendored Normal file
View File

@@ -0,0 +1,12 @@
#include "StrUtils.h"
#include <stdlib.h>
void CreateRandomString(char *pszDest, int nLength)
{
static const char c_szAlphaNum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int i = 0; i < nLength; ++i)
pszDest[i] = c_szAlphaNum[rand() % (sizeof(c_szAlphaNum) - 1)];
pszDest[nLength] = '\0';
}

3
3rdparty/MultiEmulator/src/StrUtils.h vendored Normal file
View File

@@ -0,0 +1,3 @@
#pragma once
void CreateRandomString(char *pszDest, int nLength);

24
3rdparty/MultiEmulator/wscript vendored Normal file
View File

@@ -0,0 +1,24 @@
#! /usr/bin/env python
# encoding: utf-8
# mittorn, 2018
from waflib import Logs
import os
top = '.'
def options(opt):
return
def configure(conf):
return
def build(bld):
bld.stlib(
source = bld.path.ant_glob(['src/*.cpp']),
target = 'MultiEmulator',
features = 'cxx',
includes = ['include/', 'src/'],
export_includes = ['include/'],
subsystem = bld.env.MSVC_SUBSYSTEM
)

1
3rdparty/bzip2/bz_version.h vendored Normal file
View File

@@ -0,0 +1 @@
#define BZ_VERSION "1.1.0-fwgs"

1
3rdparty/bzip2/bzip2 vendored Submodule

Submodule 3rdparty/bzip2/bzip2 added at 66c46b8c94

34
3rdparty/bzip2/wscript vendored Normal file
View 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):
# 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',
features = 'c',
includes = ['.', 'bzip2/'],
subsystem = bld.env.MSVC_SUBSYSTEM,
export_includes = ['bzip2/']
)

View File

@@ -18,7 +18,7 @@ def build(bld):
target = 'gl4es', target = 'gl4es',
features = 'c', features = 'c',
includes = ['gl4es/src', 'gl4es/src/gl', 'gl4es/src/glx', 'gl4es/include'], includes = ['gl4es/src', 'gl4es/src/gl', 'gl4es/src/glx', 'gl4es/include'],
defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'EXTERNAL_GETPROCADDRESS=GL4ES_GetProcAddress', 'NO_LOADER', 'STATICLIB'], defines = ['NOX11', 'NO_GBM', 'NO_INIT_CONSTRUCTOR', 'DEFAULT_ES=2', 'NOEGL', 'NO_LOADER', 'STATICLIB'],
cflags = ['-w', '-fvisibility=hidden', '-std=gnu99'], cflags = ['-w', '-fvisibility=hidden', '-std=gnu99'],
subsystem = bld.env.MSVC_SUBSYSTEM, subsystem = bld.env.MSVC_SUBSYSTEM,
export_includes = '.') export_includes = '.')

View File

@@ -1,17 +1,17 @@
# Bug-compatibility in Xash3D FWGS # Bug-compatibility in Xash3D FWGS
Xash3D FWGS has special mode for games that rely on original engine bugs. Xash3D FWGS has special mode for games that rely on original engine bugs. In this mode, we emulate the behaviour of selected functions that may help running mods relying on engine bugs, but enabling them by default may break majority of other games.
In this mode, we emulate the behaviour of selected functions that may help running mods relying on engine bugs, but enabling them by default may break majority of other games.
At this time, we only have implemented GoldSrc bug-compatibility. It can be enabled with `-bugcomp` command line switch. At this time, we only have implemented GoldSrc bug-compatibility. It can be enabled with `-bugcomp` command line switch.
When `-bugcomp` is specified without argument, it enables everything. This behavior might be changed or removed in future versions.
When `-bugcomp` is specified with argument, it interpreted as flags separated with `+`. This way it's possible to combine multiple levels of bug-compatibility.
## GoldSrc bug-compatibility ## GoldSrc bug-compatibility
### Emulated bugs | Flag | Description | Games that require this flag |
| ------- | ----------- | ---------------------------- |
* `pfnPEntityOfEntIndex` in GoldSrc returns NULL for last player due to incorrect player index comparison | `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 |
### Games and mods that require this | `sp_attn_none` | Makes sounds with attenuation zero spatialized, i.e. have a stereo effect. | Possibly, every game that was made for GoldSrc. |
* Counter-Strike: Condition Zero - Deleted Scenes

View File

@@ -0,0 +1,21 @@
## Environment variables
#### Xash3D FWGS
The engine respects these environment variables:
| Variable | Type | Description |
| --------------------- | ---------- | ----------- |
| `XASH3D_GAME` | _string_ | Overrides default game directory. Ignored if `-game` command line argument is set |
| `XASH3D_BASEDIR` | _string_ | Sets path to base (root) directory, instead of current working directory |
| `XASH3D_RODIR` | _string_ | Sets path to read-only base (root) directory. Ignored if `-rodir` command line argument is set |
| `XASH3D_EXTRAS_PAK1` | _string_ | Archive file from specified path will be added to virtual filesystem search path in the lowest possible priority |
| `XASH3D_EXTRAS_PAK2` | _string_ | Similar to `XASH3D_EXTRAS_PAK1` but next to it in priority list |
Environment variables NOT listed in the table above are used internally, and aren't considered as stable interface.
#### mdldec
| Variable | Type | Description |
| --------------------- | ---------- | ----------- |
| `MDLDEC_ACT_PATH` | _string_ | If set, will read activities list from this path |

View File

@@ -0,0 +1,25 @@
# GetNativeObject API
To be able to use platform-specific features or get optional engine interfaces, we've added a simple call to MobilityAPI on client DLL and PhysicsAPI for server DLL and extended MenuAPI for menu DLL.
It's defined like this:
```
void *pfnGetNativeObject( const char *name );
```
#### Cross-platform objects
Only these objects are guaranteed to be available on all targets.
| Object name | Interface |
|-------------|-----------|
| `VFileSystem009` | Provides C++ interface to filesystem, binary-compatible with Valve's VFileSystem009. |
| `XashFileSystemXXX` | Provides C interface to filesystem. This interface is unstable and not recommended for generic use, outside of engine internals. For more info about current version look into `filesystem.h`. |
#### Android-specific objects
| Object name | Interface |
|-------------|-----------|
| `JNIEnv` | Allows interfacing with Java Native Interface. |
| `ActivityClass` | Returns JNI object for engine Android activity class. |

View File

@@ -0,0 +1,65 @@
# sounds.lst.md
Using sounds.lst located in scripts folder, modder can override some of the hardcoded sounds in temp entities and server physics.
File format:
```
<group name>
{
<path1>
<path2>
<path3>
}
<group2 name> <path with %d> <min number> <max number>
```
* Sounds can use any supported sound format (WAV or MP3).
* The path must be relative to the sounds/ folder in the game or base directory root, addon folder, or archive root.
* Groups can be empty or omitted from the file to load no sound.
* Groups can either list a set of files or specify a format string and a range.
* Anything after // will be considered a comment and ignored.
* Behavior is undefined if the group was listed multiple times.
Currently supported groups are:
|Group name|Usage|
|----------|-----|
|`BouncePlayerShell`|Used for BOUNCE_SHELL tempentity hitsound|
|`BounceWeaponShell`|Used for BOUCNE_SHOTSHELL tempentity hitsound|
|`BounceConcrete`|Used for BOUNCE_CONCRETE tempentity hitsound|
|`BounceGlass`|Used for BOUCNE_GLASS|
|`BounceMetal`|Used for BOUNCE_METAL|
|`BounceFlesh`|Used for BOUNCE_FLESH|
|`BounceWood`|Used for BOUNCE_WOOD|
|`Ricochet`|Used for BOUNCE_SHRAP and ricochet tempentities|
|`Explode`|Used for tempentity explosions|
|`EntityWaterEnter`|Used for entity entering water|
|`EntityWaterExit`|Used for entity exiting water|
|`PlayerWaterEnter`|Used for player entering water|
|`PlayerWaterExit`|Used for player exiting water|
## Example
This example is based on defaults sounds used in Half-Life:
```
BouncePlayerShell "player/pl_shell%d.wav" 1 3
BounceWeaponShell "weapons/sshell%d.wav" 1 3
BounceConcrete "debris/concrete%d.wav" 1 3
BounceGlass "debris/glass%d.wav" 1 4
BounceMetal "debris/metal%d.wav" 1 6
BounceFlesh "debris/flesh%d.wav" 1 7
BounceWood "debris/wood%d.wav" 1 4
Ricochet "weapons/ric%d.wav" 1 5
Explode "weapons/explode%d.wav" 3 5
EntityWaterEnter "player/pl_wade%d.wav" 1 4
EntityWaterExit "player/pl_wade%d.wav" 1 4
PlayerWaterEnter
{
"player/pl_wade1.wav"
}
PlayerWaterExit
{
"player/pl_wade2.wav"
}
```

View File

@@ -70,12 +70,15 @@ These strings are specific to Xash3D FWGS.
| Key | Type | Default value | Description | | Key | Type | Default value | Description |
| ----------------------- | ---------- | ------------------------ | ----------- | | ----------------------- | ---------- | ------------------------ | ----------- |
| `animated_title` | boolean | 0 | Use animated title in main menu (WON Half-Life logo.avi imitation from Half-Life 25-th anniversary update)
| `autosave_aged_count` | integer | 2 | Auto saves limit used in saves rotation | | `autosave_aged_count` | integer | 2 | Auto saves limit used in saves rotation |
| `gamedll_linux` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 Linux (see LibraryNaming.md for details) | | `gamedll_linux` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 Linux (see LibraryNaming.md for details) |
| `gamedll_osx` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 macOS (see LibraryNaming.md for details) | | `gamedll_osx` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 macOS (see LibraryNaming.md for details) |
| `hd_background` | boolean | 0 | Use HD background for main menu (Half-Life 25-th anniversary update) |
| `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!<br>When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. | | `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!<br>When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. |
| `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead | | `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead |
| `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation | | `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation |
| `demomap` | string | Empty string | The name of the demo chapter map (Half-Life Uplink) |
## Note on GoldSrc liblist.gam support ## Note on GoldSrc liblist.gam support
@@ -88,6 +91,7 @@ The table below defines conversion rules from liblist.gam to gameinfo.txt. Some
| `liblist.gam` key | `gameinfo.txt` key | Note | | `liblist.gam` key | `gameinfo.txt` key | Note |
| ----------------- | ------------------ | ---- | | ----------------- | ------------------ | ---- |
| `animated_title` | `animated_title` | |
| `edicts` | `max_edicts` | | | `edicts` | `max_edicts` | |
| `fallback_dir` | `fallback_dir` | | | `fallback_dir` | `fallback_dir` | |
| `game` | `title` | | | `game` | `title` | |
@@ -95,6 +99,7 @@ The table below defines conversion rules from liblist.gam to gameinfo.txt. Some
| `gamedll` | `gamedll` | | | `gamedll` | `gamedll` | |
| `gamedll_linux` | `gamedll_linux` | | | `gamedll_linux` | `gamedll_linux` | |
| `gamedll_osx` | `gamedll_osx` | | | `gamedll_osx` | `gamedll_osx` | |
| `hd_background` | `hd_background` | |
| `icon` | `icon` | | | `icon` | `icon` | |
| `mpentity` | `mp_entity` | | | `mpentity` | `mp_entity` | |
| `mpfilter` | `mp_filter` | | | `mpfilter` | `mp_filter` | |

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

View File

@@ -0,0 +1,40 @@
### HD (external) textures support
Xash3D supports loading texture replacements in TGA format for almost all types of models in the game, except alias models at this time.
Textures are expected to be located at:
* `modfolder/materials/<mapname>` - for a specific map
* `modfolder/materials/common` - common for all maps
* `modfolder/materials/decals` - for decals
* `modfolder/materials/models/<model>` - for models (texture name must match the internal texture name in the model)
Support for high-resolution textures is enabled setting `host_allow_materials` cvar to `1` or in the menu, in "Video options" section.
#### Xash3D FWGS additions
In addition to paths above, Xash3D FWGS checks following paths:
* `modfolder/materials/sprites/<sprite>` - for sprites, except HUD sprites
Also, to check which texture replacements are loaded successfully, failed or weren't found, a mod developer can set `host_allow_materials` cvar value to `2`. The engine will spew log at any developer level in the following format:
```
Looking for <replacement> replacement... <status code> (<path relative to mod directory>)
```
Status codes:
* `OK` - texture replacement file was found and loaded into GPU memory successfully
* `FAIL` - texture file was found but hasn't been parsed or loaded successfully. Refer to engine log for more details.
* `MISS` - texture file wasn't found
Example:
```
Looking for maps/bounce.bsp:!waterblue tex replacement...OK (materials/common/!waterblue.tga)
Looking for maps/bounce.bsp:!waterblue_luma tex replacement...MISS (not found)
Looking for {shot2 decal replacement...MISS (materials/decals/{shot2.tga)
Looking for {shot4 decal replacement...MISS (materials/decals/{shot4.tga)
Looking for {shot3 decal replacement...MISS (materials/decals/{shot3.tga)
Looking for models/gman tex replacement...FAIL (materials/models/gman/GMan_Case1.tga)
Looking for models/gman tex replacement...FAIL (materials/models/gman/inside_1.tga)
```

15
Documentation/musl.md Normal file
View File

@@ -0,0 +1,15 @@
# Xash3D FWGS on `musl`
Xash3D FWGS works on `musl` out of the box. However, the engine doesn't try to differentiate glibc and musl anymore. If you see error similar to:
```
Host_InitError: can't initialize cl_dlls/client.so: Error relocating valve/cl_dlls/client.so: __sprintf_chk: symbol not found
```
... or you know that the game you're running is linked against glibc, you can try using `libgcompat`, like this:
```
$ LD_PRELOAD=/lib/libgcompat.so.0 ./xash3d ...
```
It will automatically add the missing symbols that glibc binaries usually need. In the future we might automatically link engine against `libgcompat` for better compatibility with prebuilt or closed-source games, if there will be any use for this.

View File

@@ -228,7 +228,7 @@ Branch **caseclosed** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable
Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd Branch **CAd** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/CAd
## Counter Strike ## Counter Strike
Reverse-engineered code of client part by a1batross - https://github.com/FWGS/cs16-client/tree/v1.32 Reverse-engineered code of client part by a1batross - https://github.com/Velaron/cs16-client
Reverse-engineered code of server part by nagist - https://github.com/nagist/cs16nd Reverse-engineered code of server part by nagist - https://github.com/nagist/cs16nd
@@ -240,6 +240,8 @@ CSO-like Xash3D-based mod, CSMoE - https://github.com/MoeMod/CSMoE
## Crack-Life: Campaign Mode ## Crack-Life: Campaign Mode
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_life Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_life
Reverse-engineered code: branch **clcampaign** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/clcampaign
## Escape from the Darkness ## Escape from the Darkness
malortie's recreation - https://github.com/malortie/hl-eftd malortie's recreation - https://github.com/malortie/hl-eftd

View File

@@ -19,7 +19,22 @@
- [List of XashXT-based mods](#list-of-xashxt-based-mods) - [List of XashXT-based mods](#list-of-xashxt-based-mods)
- [List of maps for They Hunger](#list-of-maps-for-they-hunger) - [List of maps for They Hunger](#list-of-maps-for-they-hunger)
- [List of games and mods with custom gamedll](#list-of-games-and-mods-with-custom-gamedll) - [List of games and mods with custom gamedll](#list-of-games-and-mods-with-custom-gamedll)
- [List of mods for Counter Strike(Android only)](#list-of-mods-for-counter-strike) - [List of mods for Counter Strike](#list-of-mods-for-counter-strike)
- [List of supported mods from mobile_hacks branch of HLSDK Portable by FWGS](#list-of-supported-mods-from-mobile_hacks-branch-of-hlsdk-portable-by-fwgs)
# List of supported mods from mobile_hacks branch of HLSDK Portable by FWGS
1. [Afraid of Monsters](https://www.moddb.com/mods/afraid-of-monsters/downloads/afraid-of-monsters-v1)
2. [Big Lolly](https://www.moddb.com/mods/big-lolly)
3. [Half-Life: Blue Shift](https://store.steampowered.com/app/130/HalfLife_Blue_Shift/)
4. [Half-Secret](https://www.moddb.com/mods/half-secret)
5. [Case Closed](https://www.moddb.com/mods/caseclosed)
6. [Bloody Pizza - Vendetta](https://www.moddb.com/games/half-life/addons/bloody-pizza-vendetta)
7. [Borderlands](https://www.moddb.com/games/half-life/addons/borderlands-v04)
8. [Half-Life: Induction](https://www.moddb.com/mods/half-life-induction/downloads/half-life-induction-12)
9. [Redemption/Absolute Redemption](https://www.moddb.com/mods/absolute-redemption)
10. [Sewer beta](https://www.moddb.com/games/half-life/addons/sewer-beta)
11. [Times of Troubles](https://www.moddb.com/mods/times-of-troubles)
12. [Half-Life: Urbicide](https://www.moddb.com/mods/half-life-urbicide)
# List of Half-Life-based mods # List of Half-Life-based mods
Originally this list was written by *Qwertyus*(*Qortez*) Originally this list was written by *Qwertyus*(*Qortez*)
@@ -176,7 +191,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
143. [Operation: Nova](http://www.moddb.com/mods/half-life-operation-nova) (there is an inner bug with an M60 machinegun on a map with Osprey: it can be activated and used if you are staying in front of it, not behind it) 143. [Operation: Nova](http://www.moddb.com/mods/half-life-operation-nova) (there is an inner bug with an M60 machinegun on a map with Osprey: it can be activated and used if you are staying in front of it, not behind it)
144. [Optimum Fear](https://www.fileplanet.com/7472/0/fileinfo/Optimum-Fear) 144. [Optimum Fear](https://www.fileplanet.com/7472/0/fileinfo/Optimum-Fear)
145. [Outrun](http://www.moddb.com/mods/outrun) 145. [Outrun](http://www.moddb.com/mods/outrun)
146. [Outwards (Day One)](https://drive.google.com/file/d/1mjQ8wUazYbwTq9Ocg0Vs0raq4avbTRne/view?usp=sharing) 146. [Outwards (Day One)](https://web.archive.org/web/20161026104825/http://visgi.info/maps/)
147. [Overhaul Pack](http://www.moddb.com/mods/half-life-overhaul-pack) (Just HD pack for Half-Life) 147. [Overhaul Pack](http://www.moddb.com/mods/half-life-overhaul-pack) (Just HD pack for Half-Life)
148. [P.I.Z.D.E.C.](https://www.runthinkshootlive.com/posts/pizdec/) 148. [P.I.Z.D.E.C.](https://www.runthinkshootlive.com/posts/pizdec/)
149. [pagoda](http://www.moddb.com/mods/pagoda1) 149. [pagoda](http://www.moddb.com/mods/pagoda1)
@@ -282,7 +297,7 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
6. [Catacombs: Part 1](https://www.runthinkshootlive.com/posts/catacombs/) 6. [Catacombs: Part 1](https://www.runthinkshootlive.com/posts/catacombs/)
7. [Cro-man's Office Mappack](http://twhl.info/vault.php?map=5547) 7. [Cro-man's Office Mappack](http://twhl.info/vault.php?map=5547)
8. [Half-Life Episode Two Demo Alpha v1.0](http://hl.loess.ru/?mod=451) 8. [Half-Life Episode Two Demo Alpha v1.0](http://hl.loess.ru/?mod=451)
9. [Hazardous-Course (first version of Hazardous-Course 2)](https://drive.google.com/file/d/16djJZSpNWKyScSxSyMqX-u_S-2i400rl/view?usp=sharing) 9. [Hazardous-Course (first version of Hazardous-Course 2)](https://web.archive.org/web/20110512012317/http://www.richmans-maps.ch.vu/)
10. [High Tech v0.2](http://hl.loess.ru/?mod=499) 10. [High Tech v0.2](http://hl.loess.ru/?mod=499)
11. [HL Shadows, Part 1](https://www.fileplanet.com/7466/0/fileinfo/'HL-Shadows',-Part-1) 11. [HL Shadows, Part 1](https://www.fileplanet.com/7466/0/fileinfo/'HL-Shadows',-Part-1)
12. [HLNewEnd](http://twhl.info/vault.php?map=2275) 12. [HLNewEnd](http://twhl.info/vault.php?map=2275)
@@ -305,11 +320,11 @@ For mappacks - place *.bsp files to **valve/maps** folder, *.wad files to **valv
29. [Shortcut v1.0 Beta](https://www.runthinkshootlive.com/posts/shortcut/) 29. [Shortcut v1.0 Beta](https://www.runthinkshootlive.com/posts/shortcut/)
30. [Stoka](https://www.ceskemody.cz/mapy.php?lng=1&clanek=222&razeni_hra=1&pn=stoka) 30. [Stoka](https://www.ceskemody.cz/mapy.php?lng=1&clanek=222&razeni_hra=1&pn=stoka)
31. [Striker's Compo 26](http://twhl.info/vault.php?map=5190) (buggy) 31. [Striker's Compo 26](http://twhl.info/vault.php?map=5190) (buggy)
32. [Technology Test 2](https://drive.google.com/file/d/1LfldzsMIN5j07bgtNkfY5v0Xl0S9de_G/view?usp=sharing) 32. [Technology Test 2](https://web.archive.org/web/20110512012317/http://www.richmans-maps.ch.vu/)
33. [The Gate Playable Demo](https://www.fileplanet.com/116347/110000/fileinfo/The-Gate-Playable-Demo) 33. [The Gate Playable Demo](https://www.fileplanet.com/116347/110000/fileinfo/The-Gate-Playable-Demo)
34. [They are Back](https://www.runthinkshootlive.com/posts/they-are-back/) 34. [They are Back](https://www.runthinkshootlive.com/posts/they-are-back/)
35. [Tiefseelabor( Deep Sea Laboratory )](https://www.runthinkshootlive.com/posts/deep-sea-laboratory/) 35. [Tiefseelabor( Deep Sea Laboratory )](https://www.runthinkshootlive.com/posts/deep-sea-laboratory/)
36. [Time-Shift](https://drive.google.com/file/d/1pK1s-2SIlSMQHVRPMLdC_94wTa__8_DX/view?usp=sharing) 36. [Time-Shift](https://web.archive.org/web/20110512012317/http://www.richmans-maps.ch.vu/)
37. [Train Single Beta](https://cs-mapping.com.ua/forum/showthread.php?t=36394) (Remove **gfx.wad** from **TrainSingle** folder) 37. [Train Single Beta](https://cs-mapping.com.ua/forum/showthread.php?t=36394) (Remove **gfx.wad** from **TrainSingle** folder)
38. [WAR: The Killer Beta 0.1](http://www.moddb.com/mods/war) 38. [WAR: The Killer Beta 0.1](http://www.moddb.com/mods/war)
39. [White Force Beta( Residual Point prototype )](http://www.moddb.com/mods/hl-residual-point/downloads/white-force-beta-2002) 39. [White Force Beta( Residual Point prototype )](http://www.moddb.com/mods/hl-residual-point/downloads/white-force-beta-2002)
@@ -379,7 +394,7 @@ Mods:
5. [Half-Life Baby v1.4](http://www.moddb.com/games/half-life/addons/half-life-baby) (it's an unfinished but playable mod; after installing of the mod open **liblist.gam** or **gameinfo.txt** file in the mod's folder and correct the line **gamedll "..\hlbaby\dlls\hl.dll"** for **gamedll "dlls\hl.dll"**, otherwise you'll not be able to start a game) 5. [Half-Life Baby v1.4](http://www.moddb.com/games/half-life/addons/half-life-baby) (it's an unfinished but playable mod; after installing of the mod open **liblist.gam** or **gameinfo.txt** file in the mod's folder and correct the line **gamedll "..\hlbaby\dlls\hl.dll"** for **gamedll "dlls\hl.dll"**, otherwise you'll not be able to start a game)
6. [Half-Secret](http://www.moddb.com/mods/half-secret) (this mod has custom **weapon_snark** code) 6. [Half-Secret](http://www.moddb.com/mods/half-secret) (this mod has custom **weapon_snark** code)
7. [Induction](http://www.moddb.com/mods/half-life-induction) (this mod has new item - **item_flashlight**) 7. [Induction](http://www.moddb.com/mods/half-life-induction) (this mod has new item - **item_flashlight**)
8. [Lost in Black Mesa(first version without HLFX)](https://drive.google.com/file/d/1bEnm_AxJs-ly8hTEZIQBw_v2BsXdSiGa/view?usp=sharing) 8. [Lost in Black Mesa(first version without HLFX)](https://web.archive.org/web/20160407041812/http://half-life.ru/forum/showthread.php?threadid=13959) (download links dead!)
9. [Soldier](http://www.moddb.com/mods/half-life-soldier) 9. [Soldier](http://www.moddb.com/mods/half-life-soldier)
10. [Solo Operations](http://www.moddb.com/mods/solo-operations) 10. [Solo Operations](http://www.moddb.com/mods/solo-operations)
11. [The Blood v1.1](http://hl.loess.ru/?mods=&search=The+Blood) (there are some inner bugs in the mod, but they don't interfere with a game progress) 11. [The Blood v1.1](http://hl.loess.ru/?mods=&search=The+Blood) (there are some inner bugs in the mod, but they don't interfere with a game progress)
@@ -440,7 +455,7 @@ Mods:
51. [Data-base](https://www.runthinkshootlive.com/posts/database/) 51. [Data-base](https://www.runthinkshootlive.com/posts/database/)
52. [de_dust2_azabetfeN](https://cs-mapping.com.ua/forum/showthread.php?t=36394) (remove **cl_dlls** & **dlls** folders from inside of mod's directory before you start the game) 52. [de_dust2_azabetfeN](https://cs-mapping.com.ua/forum/showthread.php?t=36394) (remove **cl_dlls** & **dlls** folders from inside of mod's directory before you start the game)
53. [De-railed](http://twhl.info/competitions.php?results=7) 53. [De-railed](http://twhl.info/competitions.php?results=7)
54. [Dead Shift Beta](http://www.moddb.com/mods/dead-shift) - [Demo 1](https://www.gamewatcher.com/mods/half-life-mod/dead-shift-1-0-beta) & [Demo 2](https://drive.google.com/file/d/1uHvr8xONogTTNOy-8X6G4ehFV6Eawvbq/view?usp=sharing) 54. [Dead Shift Beta](http://www.moddb.com/mods/dead-shift) - [Demo 1](https://www.gamewatcher.com/mods/half-life-mod/dead-shift-1-0-beta) & [Demo 2](https://web.archive.org/web/20151030005310/http://www.gamefront.com/files/13532512)
55. [Deep](http://twhl.info/vault.php?map=1669) 55. [Deep](http://twhl.info/vault.php?map=1669)
56. [Desert Attack](http://fyzzer.narod.ru/index.html) 56. [Desert Attack](http://fyzzer.narod.ru/index.html)
57. [Desert Combat Demo](https://www.fileplanet.com/190487/190000/fileinfo/Half-Life---Desert-Combat-Mod) (despite a big file size there's only one small unfinished map) 57. [Desert Combat Demo](https://www.fileplanet.com/190487/190000/fileinfo/Half-Life---Desert-Combat-Mod) (despite a big file size there's only one small unfinished map)
@@ -498,8 +513,8 @@ Mods:
109. [Hospital](https://gamebanana.com/maps/167446) (you need to edit **liblist.gam** file in the mod's folder - delete *gamedll & type* strings from it before you start to play) 109. [Hospital](https://gamebanana.com/maps/167446) (you need to edit **liblist.gam** file in the mod's folder - delete *gamedll & type* strings from it before you start to play)
110. [Hostage](https://www.runthinkshootlive.com/posts/hostage-2/) 110. [Hostage](https://www.runthinkshootlive.com/posts/hostage-2/)
111. [House](http://www.artpeter.net/Data/HalfLife/Hl.php) 111. [House](http://www.artpeter.net/Data/HalfLife/Hl.php)
112. [Impulse 101 Fun - The Train](https://drive.google.com/file/d/1jAuMCCmREH0mfAEAscqaG8FQGa2uNknb/view?usp=sharing) (map from *TWHL* by *Archie* aka *The Hunter*) 112. [Impulse 101 Fun - The Train](http://web.archive.org/web/20070305075816/http://www.twhl.co.za/mapvault/2817.zip) (map from *TWHL* by *Archie* aka *The Hunter*)
113. [In America](https://drive.google.com/file/d/1gOC8zfnUvBxRy8Rr8juNiUNbLYjoZpnn/view?usp=sharing) 113. [In America](https://web.archive.org/web/20170221213409/http://www.lambda-force.org/load/half_life/karty/half_life_in_america/18-1-0-476)
114. [In the Kitchen](http://twhl.info/vault.php?map=4314) 114. [In the Kitchen](http://twhl.info/vault.php?map=4314)
115. [Infiltration](https://www.fileplanet.com/7467/0/fileinfo/Infiltration) 115. [Infiltration](https://www.fileplanet.com/7467/0/fileinfo/Infiltration)
116. [Interactivity & Lots of Entities](http://twhl.info/vault.php?map=5744) (link dead!) 116. [Interactivity & Lots of Entities](http://twhl.info/vault.php?map=5744) (link dead!)

View File

@@ -1,8 +1,8 @@
# Xash3D FWGS Engine <img align="right" width="128" height="128" src="https://github.com/FWGS/xash3d-fwgs/raw/master/game_launch/icon-xash-material.png" alt="Xash3D FWGS icon" /> # Xash3D FWGS Engine <img align="right" width="128" height="128" src="https://github.com/FWGS/xash3d-fwgs/raw/master/game_launch/icon-xash-material.png" alt="Xash3D FWGS icon" />
[![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \ [![builds.sr.ht status](https://builds.sr.ht/~a1batross/xash3d-fwgs.svg)](https://builds.sr.ht/~a1batross/xash3d-fwgs?) [![GitHub Actions Status](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/FWGS/xash3d-fwgs/actions/workflows/c-cpp.yml) [![FreeBSD Build Status](https://img.shields.io/cirrus/github/FWGS/xash3d-fwgs?label=freebsd%20build)](https://cirrus-ci.com/github/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](http://fwgsdiscord.mentality.rip/) \
[![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous) [![Download Stable](https://img.shields.io/badge/download-stable-yellow)](https://github.com/FWGS/xash3d-fwgs/releases/latest) [![Download Testing](https://img.shields.io/badge/downloads-testing-orange)](https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous)
Xash3D FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow. Xash3D (pronounced `[ksɑʂ]`) FWGS is a game engine, aimed to provide compatibility with Half-Life Engine and extend it, as well as to give game developers well known workflow.
Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike. Xash3D FWGS is a heavily modified fork of an original [Xash3D Engine](https://www.moddb.com/engines/xash3d-engine) by Unkle Mike.
@@ -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). If you like Xash3D FWGS, consider supporting individual engine maintainers. By supporting us, you help to continue developing this game engine further. The sponsorship links are available in [documentation](Documentation/donate.md).
## Fork features ## Fork features
* Steam Half-Life (HLSDK 2.4) support. * 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). * 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. * 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. * 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. * Different input methods: touch and gamepad in addition to mouse & keyboard.
* TrueType font rendering, as a part of mainui_cpp. * TrueType font rendering, as a part of mainui_cpp.
* External VGUI support module. * External VGUI support module.
@@ -28,29 +28,28 @@ If you like Xash3D FWGS, consider supporting individual engine maintainers. By s
1) Copy engine binaries to some directory. 1) Copy engine binaries to some directory.
2) Copy `valve` directory from [Half-Life](https://store.steampowered.com/app/70/HalfLife/) to directory with engine binaries. 2) Copy `valve` directory from [Half-Life](https://store.steampowered.com/app/70/HalfLife/) to directory with engine binaries.
If your CPU is NOT x86 compatible or you're running 64-bit version of the engine, you may want to compile [Half-Life SDK](https://github.com/FWGS/hlsdk-portable). If your CPU is NOT x86 compatible or you're running 64-bit version of the engine, you may want to compile [Half-Life SDK](https://github.com/FWGS/hlsdk-portable).
This repository contains our fork of HLSDK and restored source code for some of the mods. Not all of them, of course. This repository contains our fork of HLSDK and restored source code for Half-Life expansions and some mods.
You still needed to copy `valve` directory as all game resources located there. You still needed to copy `valve` directory as all game resources located there.
3) Run the main executable (`xash3d.exe` or AppImage). 3) Run the main executable (`xash3d.exe` or AppImage).
For additional info, run Xash3D with `-help` command line key. For additional info, run Xash3D with `-help` command line key.
## Contributing ## 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 * 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 * Issues are accepted in both English and Russian.
* Before sending a PR, check if you followed our contribution guide in CONTRIBUTING.md file. * Before sending a PR, check if you followed our contribution guide in CONTRIBUTING.md file.
## Build instructions ## 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! NOTE: NEVER USE GitHub's ZIP ARCHIVES. GitHub doesn't include external dependencies we're using!
### Prerequisites ### 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.
If your CPU is x86 compatible, 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! Even if Xash3D FWGS does support targetting 64-bit, you can't load games without recompiling them from source code!
If your CPU is NOT x86 compatible or you decided build 64-bit version of engine, you may want to compile [Half-Life SDK](https://github.com/FWGS/hlsdk-portable). If your CPU is NOT x86 compatible or you decided build 64-bit version of engine, you may want to compile [Half-Life SDK](https://github.com/FWGS/hlsdk-portable).
This repository contains our fork of HLSDK and restored source code for some of the mods. Not all of them, of course. This repository contains our fork of HLSDK and restored source code for Half-Life expansions and some mods.
#### Windows (Visual Studio) #### Windows (Visual Studio)
* Install Visual Studio. * Install Visual Studio.
@@ -62,31 +61,39 @@ This repository contains our fork of HLSDK and restored source code for some of
#### GNU/Linux #### GNU/Linux
##### Debian/Ubuntu ##### Debian/Ubuntu
* Enable i386 on your system, if you're compiling 32-bit engine on amd64. If not, skip this * For 32-bit engine on 64-bit x86 operating system:
* Enable i386 on your system: `$ sudo dpkg --add-architecture i386`.
* Install development tools: `$ sudo apt install build-essential gcc-multilib g++-multilib python libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-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` * For non-x86 systems:
* Install development tools * Install development tools: `$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev libopus-dev libbz2-dev`.
* 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` * Clone this repostory: `$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`.
* For everything else: \
`$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev` ##### RedHat/Fedora
* Clone this repostory: * For 32-bit engine on 64-bit x86 operating system:
`$ git clone --recursive https://github.com/FWGS/xash3d-fwgs` * Install development tools: `$ sudo dnf install 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 non-x86 systems:
* Install development tools: `$ sudo dnf install 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 ### Building
#### Windows (Visual Studio) #### Windows (Visual Studio)
0) Open command line 0) Open command line.
1) Navigate to `xash3d-fwgs` directory. 1) Navigate to `xash3d-fwgs` directory.
2) Carefully examine which build options are available: `waf --help` 2) (optional) Examine which build options are available: `waf --help`.
3) Configure build: `waf configure -T release --sdl2=c:/path/to/SDL2` 3) Configure build: `waf configure --sdl2=c:/path/to/SDL2`.
4) Compile: `waf build` 4) Compile: `waf build`.
5) Install: `waf install --destdir=c:/path/to/any/output/directory` 5) Install: `waf install --destdir=c:/path/to/any/output/directory`.
#### Linux #### 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` 0) (optional) Examine which build options are available: `./waf --help`.
1) Configure build: `./waf configure -T release` 1) Configure build: `./waf configure` (you need to pass `-8` to compile 64-bit engine on 64-bit x86 processor).
(You need to pass `-8` to compile 64-bit engine on 64-bit x86 processor) 2) Compile: `./waf build`.
2) Compile: `./waf build` 3) Install: `./waf install --destdir=/path/to/any/output/directory`.
3) Install(optional): `./waf install --destdir=/path/to/any/output/directory`

View File

@@ -1,25 +0,0 @@
/*
boneinfo.h - structure that send delta-compressed bones across network
Copyright (C) 2018 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef BONEINFO_H
#define BONEINFO_H
typedef struct
{
vec3_t angles;
vec3_t origin;
} boneinfo_t;
#endif//BONEINFO_H

View File

@@ -127,14 +127,23 @@ typedef struct
int flags; // sky or slime, no lightmap or 256 subdivision int flags; // sky or slime, no lightmap or 256 subdivision
} mtexinfo_t; } mtexinfo_t;
typedef struct glpoly_s // a1ba: changed size to avoid undefined behavior. Check your allocations if you take this header!
// For example:
// before: malloc( sizeof( glpoly_t ) + ( numverts - 4 ) * VERTEXSIZE * sizeof( float ))
// after (C): malloc( sizeof( glpoly_t ) + numverts * VERTEXSIZE * sizeof( float ))
// after (C++): malloc( sizeof( glpoly_t ) + ( numverts - 1 ) * VERTEXSIZE * sizeof( float ))
typedef struct glpoly2_s
{ {
struct glpoly_s *next; struct glpoly2_s *next;
struct glpoly_s *chain; struct glpoly2_s *chain;
int numverts; int numverts;
int flags; // for SURF_UNDERWATER int flags; // for SURF_UNDERWATER
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2) #ifdef __cplusplus
} glpoly_t; float verts[1][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
#else
float verts[][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
#endif
} glpoly2_t;
typedef struct mnode_s typedef struct mnode_s
{ {
@@ -173,7 +182,7 @@ struct decal_s
short entityIndex; // Entity this is attached to short entityIndex; // Entity this is attached to
// Xash3D specific // Xash3D specific
vec3_t position; // location of the decal center in world space. vec3_t position; // location of the decal center in world space.
glpoly_t *polys; // precomputed decal vertices glpoly2_t *polys; // precomputed decal vertices
intptr_t reserved[4]; // just for future expansions or mod-makers intptr_t reserved[4]; // just for future expansions or mod-makers
}; };
@@ -246,7 +255,7 @@ struct msurface_s
int light_s, light_t; // gl lightmap coordinates int light_s, light_t; // gl lightmap coordinates
glpoly_t *polys; // multiple if warped glpoly2_t *polys; // multiple if warped
struct msurface_s *texturechain; struct msurface_s *texturechain;
mtexinfo_t *texinfo; mtexinfo_t *texinfo;
@@ -488,7 +497,8 @@ typedef struct
int flags; int flags;
float size; float size;
int reserved[8]; // VBO offsets const trivertex_t **pposeverts; // only valid during loading, used to build GL mesh
intptr_t reserved[7]; // VBO offsets
int numposes; int numposes;
int poseverts; int poseverts;
@@ -531,8 +541,10 @@ typedef struct
#define MAX_MOVIES 8 #define MAX_MOVIES 8
#define MAX_CDTRACKS 32 #define MAX_CDTRACKS 32
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client) #define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
#define MAX_EFRAGS 8192 // Arcane Dimensions required
#define MAX_REQUESTS 64 #define MAX_REQUESTS 64
STATIC_CHECK_SIZEOF( mextrasurf_t, 324, 496 );
STATIC_CHECK_SIZEOF( decal_t, 60, 88 );
STATIC_CHECK_SIZEOF( mfaceinfo_t, 176, 304 );
#endif//COM_MODEL_H #endif//COM_MODEL_H

View File

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

View File

@@ -1,49 +1,122 @@
/*** /*
* cvardef.h - quake cvar definition
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (C) 2024 Alibek Omarov
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef CVARDEF_H
#define CVARDEF_H
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc This program is free software; you can redistribute it and/or
#define FCVAR_USERINFO (1<<1) // changes the client's info string modify it under the terms of the GNU General Public License
#define FCVAR_SERVER (1<<2) // notifies players when changed as published by the Free Software Foundation; either version 2
#define FCVAR_EXTDLL (1<<3) // defined by external DLL of the License, or (at your option) any later version.
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar
#define FCVAR_PRIVILEGED (1<<10) // only available in privileged mode
#define FCVAR_FILTERABLE (1<<11) // filtered in unprivileged mode if cl_filterstuffcmd is 1
// Xash3D extensions This program is distributed in the hope that it will be useful,
#define FCVAR_GLCONFIG (1<<12) // write it into <renderer>.cfg(see RefAPI) but WITHOUT ANY WARRANTY; without even the implied warranty of
#define FCVAR_CHANGED (1<<13) // set each time the cvar is changed MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#define FCVAR_GAMEUIDLL (1<<14) // defined by the menu DLL
#define FCVAR_CHEAT (1<<15) // can not be changed if cheats are disabled
// a1ba: let's reuse higher bits for flags extensions from now on See the GNU General Public License for more details.
#define FCVAR_LATCH (1<<30) // notify client what this cvar will be applied only after server restart (but don't does more nothing)
typedef struct cvar_s You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef CVAR
#define CVAR
#include STDINT_H
#include "xash3d_types.h"
/*
cvar_t variables are used to hold scalar or string variables that can be changed
or displayed at the console or prog code as well as accessed directly
in C code.
The user can access cvars from the console in three ways:
r_draworder prints the current value
r_draworder 0 sets the current value to 0
set r_draworder 0 as above, but creates the cvar if not present
Cvars are restricted from having the same names as commands to keep this
interface from being ambiguous.
The are also occasionally used to communicated information between different
modules of the program.
*/
enum
{ {
// GoldSrc compatibility flags
FCVAR_ARCHIVE = 1 << 0, // set to cause it to be saved to vars.rc
FCVAR_USERINFO = 1 << 1, // added to userinfo when changed
FCVAR_SERVER = 1 << 2, // added to serverinfo when changed, will notify clients by default
FCVAR_EXTDLL = 1 << 3, // defined by server.dll
FCVAR_CLIENTDLL = 1 << 4, // defined by client.dll
FCVAR_PROTECTED = 1 << 5, // private server cvar
FCVAR_SPONLY = 1 << 6, // can be set only in singleplayer
FCVAR_PRINTABLEONLY = 1 << 7, // only allows printable characters
FCVAR_UNLOGGED = 1 << 8, // disables notifying client about server cvar change
FCVAR_NOEXTRAWHITESPACE = 1 << 9, // removes space characters from the beginning and the end of the string
FCVAR_PRIVILEGED = 1 << 10, // only available in privileged mode
FCVAR_FILTERABLE = 1 << 11, // treated as privileged if cl_filterstuffcmd is 1, otherwise ignored
// Xash3D public flags
// FCVAR_LATCH = 1 << 11, // deprecated Xash3D flag, conflicts with FCVAR_FILTERABLE. Use another FCVAR_LATCH!
FCVAR_GLCONFIG = 1 << 12, // set to cause it to be saved to <renderer>.cfg (see RefAPI)
FCVAR_CHANGED = 1 << 13, // set each time the cvar changed
FCVAR_GAMEUIDLL = 1 << 14, // defined by menu.dll
FCVAR_CHEAT = 1 << 15, // cannot be changed if sv_cheats is 0
#if REF_DLL || ENGINE_DLL // Xash3D internal flags, MUST NOT be used outside of engine
FCVAR_RENDERINFO = 1 << 16, // set to cause it to be saved to video.cfg
FCVAR_READ_ONLY = 1 << 17, // display only, cannot be set by user at all
FCVAR_EXTENDED = 1 << 18, // extended cvar structure
FCVAR_ALLOCATED = 1 << 19, // allocated by the engine, must be freed with Mem_Free
FCVAR_VIDRESTART = 1 << 20, // triggers video subsystem to recreate/modify window parameters
FCVAR_TEMPORARY = 1 << 21, // only used to temporarly hold some value, can be unlinked
FCVAR_MOVEVARS = 1 << 22, // access to movevars_t structure, synchornized between client and server
FCVAR_USER_CREATED = 1 << 23, // created by a set command
FCVAR_REFDLL = 1 << 29, // (Xash3D FWGS internal flag) defined by the renderer DLL
#endif // REF_DLL || ENGINE_DLL
FCVAR_LATCH = 1 << 30, // (Xash3D FWGS public flag, was FCVAR_FILTERABLE in Xash3D) save changes until server restart
};
struct cvar_s {
char *name; char *name;
char *string; char *string;
int flags; uint32_t flags;
float value; float value;
struct cvar_s *next; struct cvar_s *next;
} cvar_t; };
typedef struct cvar_s cvar_t;
#endif//CVARDEF_H STATIC_CHECK_SIZEOF( struct cvar_s, 20, 32 );
#if REF_DLL || ENGINE_DLL // Xash3D internal cvar format, MUST NOT be used outside of engine
struct convar_s {
char *name;
char *string;
uint32_t flags;
float value;
struct convar_s *next;
char *desc;
char *def_string;
};
typedef struct convar_s convar_t;
#if XASH_64BIT
#define CVAR_SENTINEL (uintptr_t)0xDEADBEEFDEADBEEF
#else
#define CVAR_SENTINEL (uintptr_t)0xDEADBEEF
#endif
#define CVAR_CHECK_SENTINEL( cv ) ((uintptr_t)(cv)->next == CVAR_SENTINEL)
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) \
convar_t cv = { (char*)cvname, (char*)cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, (char*)cvdesc, NULL }
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )
#endif // REF_DLL || ENGINE_DLL
#endif // CVAR

View File

@@ -189,4 +189,8 @@ Default build-depended cvar and constant values
#define DEFAULT_FULLSCREEN "1" // must be a string #define DEFAULT_FULLSCREEN "1" // must be a string
#endif // DEFAULT_FULLSCREEN #endif // DEFAULT_FULLSCREEN
#ifndef DEFAULT_MAX_EDICTS
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
#endif // DEFAULT_MAX_EDICTS
#endif // DEFAULTS_H #endif // DEFAULTS_H

View File

@@ -1,5 +1,5 @@
/* /*
features.h - engine features that can be enabled by mod-maker request enginefeatures.h - engine features that can be enabled by mod-maker request
Copyright (C) 2012 Uncle Mike Copyright (C) 2012 Uncle Mike
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@@ -27,4 +27,20 @@ GNU General Public License for more details.
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer #define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
#define ENGINE_DISABLE_HDTEXTURES (1U<<30) // disable support of HD-textures in case custom renderer have separate way to load them
#define ENGINE_STEP_POSHISTORY_LERP (1U<<31) // enable MOVETYPE_STEP interpolation based on position history. Incompatible with ENGINE_COMPUTE_STUDIO_LERP!
// adjust the mask when features will be added or removed
#define ENGINE_FEATURES_MASK \
( ENGINE_WRITE_LARGE_COORD \
| ENGINE_QUAKE_COMPATIBLE \
| ENGINE_LOAD_DELUXEDATA \
| ENGINE_PHYSICS_PUSHER_EXT \
| ENGINE_LARGE_LIGHTMAPS \
| ENGINE_COMPENSATE_QUAKE_BUG \
| ENGINE_IMPROVED_LINETRACE \
| ENGINE_COMPUTE_STUDIO_LERP \
| ENGINE_LINEAR_GAMMA_SPACE \
| ENGINE_STEP_POSHISTORY_LERP )
#endif//FEATURES_H #endif//FEATURES_H

View File

@@ -19,6 +19,8 @@ GNU General Public License for more details.
#define GFL_NOMODELS (1<<0) #define GFL_NOMODELS (1<<0)
#define GFL_NOSKILLS (1<<1) #define GFL_NOSKILLS (1<<1)
#define GFL_RENDER_PICBUTTON_TEXT (1<<2) #define GFL_RENDER_PICBUTTON_TEXT (1<<2)
#define GFL_HD_BACKGROUND (1<<3)
#define GFL_ANIMATED_TITLE (1<<4)
/* /*
======================================================================== ========================================================================
@@ -28,7 +30,7 @@ GAMEINFO stuff
internal shared gameinfo structure (readonly for engine parts) internal shared gameinfo structure (readonly for engine parts)
======================================================================== ========================================================================
*/ */
typedef struct typedef struct GAMEINFO_s
{ {
// filesystem info // filesystem info
char gamefolder[64]; // used for change game '-game x' char gamefolder[64]; // used for change game '-game x'
@@ -48,4 +50,48 @@ typedef struct
int gamemode; int gamemode;
} GAMEINFO; } GAMEINFO;
/*
========================================================================
Extended GameInfo struct introduced in Xash3D FWGS
GAMEINFO can't be reliably extended, as nor engine, nor menu can't be
sure about struct size. By adding struct versioning, we can check the
presense for extra fields.
========================================================================
*/
#define GAMEINFO_VERSION 2
typedef enum gametype_e
{
GAME_NORMAL,
GAME_SINGLEPLAYER_ONLY,
GAME_MULTIPLAYER_ONLY,
} gametype_t;
typedef struct gameinfo2_s
{
int gi_version; // should be set to desired struct version, e.g. GAMEINFO_VERSION
// filesystem info
char gamefolder[64]; // used for change game
char startmap[64]; // map to start singleplayer game from
char trainmap[64]; // map to start hazardous course from (if specified)
char demomap[64]; // map to start demo chapter from (if specified)
char title[64]; // game title
char iconpath[64]; // path to game icon
char version[16]; // game version (optional)
uint32_t flags; // gameinfo flags, extended to fit more flags
// mod info
char game_url[256]; // link to a developer's site
char update_url[256]; // link to updates page
char type[64]; // single, toolkit, multiplayer, etc
char date[64]; // release date
uint64_t size; // size in bytes
gametype_t gamemode;
} gameinfo2_t;
#endif//GAMEINFO_H #endif//GAMEINFO_H

View File

@@ -1,18 +1,35 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ /*
// Copyright (C) 1996-1997 Id Software, Inc.
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( KBUTTONH ) This program is free software; you can redistribute it and/or
#define KBUTTONH modify it under the terms of the GNU General Public License
#pragma once as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
typedef struct kbutton_s This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef KBUTTON_H
#define KBUTTON_H
// a1ba: copied from WinQuake/client.h
//
// cl_input
//
typedef struct
{ {
int down[2]; // key nums holding it down int down[2]; // key nums holding it down
int state; // low bit is down state int state; // low bit is down state
} kbutton_t; } kbutton_t;
#endif // !KBUTTONH STATIC_CHECK_SIZEOF( kbutton_t, 12, 12 );
#endif // KBUTTON_H

View File

@@ -27,6 +27,7 @@
// Set this flag for things like broadcast requests, etc. where the engine should not // Set this flag for things like broadcast requests, etc. where the engine should not
// kill the request hook after receiving the first response // kill the request hook after receiving the first response
#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 ) #define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 )
#define FNETAPI_LEGACY_PROTOCOL ( 1<<1 ) // xash3d-fwgs extension
struct net_response_s; struct net_response_s;
typedef void (*net_api_response_func_t) ( struct net_response_s *response ); typedef void (*net_api_response_func_t) ( struct net_response_s *response );
@@ -35,6 +36,7 @@ typedef void (*net_api_response_func_t) ( struct net_response_s *response );
#define NET_ERROR_TIMEOUT ( 1<<0 ) #define NET_ERROR_TIMEOUT ( 1<<0 )
#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 ) #define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 )
#define NET_ERROR_UNDEFINED ( 1<<2 ) #define NET_ERROR_UNDEFINED ( 1<<2 )
#define NET_ERROR_FORBIDDEN ( 1<<3 ) // xash3d-fwgs extension
typedef struct net_adrlist_s typedef struct net_adrlist_s
{ {

View File

@@ -1,76 +1,74 @@
/*** /*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#ifndef NETADR_H This program is free software; you can redistribute it and/or
#define NETADR_H modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef NET_ADR_H
#define NET_ADR_H
#include "build.h"
#include STDINT_H #include STDINT_H
typedef enum // net.h -- quake's interface to the networking layer
{ // a1ba: copied from Quake-2/qcommon/qcommon.h and modified to support IPv6
NA_UNUSED = 0,
NA_LOOPBACK,
NA_BROADCAST,
NA_IP,
NA_IPX,
NA_BROADCAST_IPX,
NA_IP6,
NA_MULTICAST_IP6, // all nodes multicast
} netadrtype_t;
// Original structure: #define PORT_ANY -1
// typedef struct netadr_s
// { typedef enum {NA_LOOPBACK = 1, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX, NA_IP6, NA_MULTICAST_IP6} netadrtype_t;
// netadrtype_t type;
// unsigned char ip[4]; /*
// unsigned char ipx[10]; Original Quake-2 structure:
// unsigned short port; typedef struct
// } netadr_t; {
netadrtype_t type;
byte ip[4];
byte ipx[10];
unsigned short port;
} netadr_t;
*/
#pragma pack( push, 1 ) #pragma pack( push, 1 )
typedef struct netadr_s typedef struct netadr_s
{ {
union union
{ {
// IPv6 struct
struct struct
{ {
uint32_t type; uint16_t type6;
uint8_t ip6[16];
};
struct
{
uint32_t type; // must be netadrtype_t but will break with short enums
union union
{ {
uint8_t ip[4]; uint8_t ip[4];
uint32_t ip4; uint32_t ip4; // for easier conversions
}; };
uint8_t ipx[10]; uint8_t ipx[10];
}; };
struct
{
#if XASH_LITTLE_ENDIAN
uint16_t type6;
uint8_t ip6[16];
#elif XASH_BIG_ENDIAN
uint8_t ip6_0[2];
uint16_t type6;
uint8_t ip6_2[14];
#endif
};
}; };
uint16_t port; uint16_t port;
} netadr_t; } netadr_t;
#pragma pack( pop ) #pragma pack( pop )
STATIC_ASSERT( sizeof( netadr_t ) == 20, "invalid netadr_t size" ); STATIC_CHECK_SIZEOF( netadr_t, 20, 20 );
#endif//NETADR_H #endif // NET_ADR_H

View File

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

View File

@@ -56,6 +56,8 @@ color24 gTracerColors[] =
}; };
*/ */
#define TRACER_COLORINDEX_DEFAULT 4
// Temporary entity array // Temporary entity array
#define TENTPRIORITY_LOW 0 #define TENTPRIORITY_LOW 0
#define TENTPRIORITY_HIGH 1 #define TENTPRIORITY_HIGH 1

View File

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

View File

@@ -28,11 +28,7 @@ typedef byte rgb_t[3]; // unsigned byte colorpack
typedef vec_t matrix3x4[3][4]; typedef vec_t matrix3x4[3][4];
typedef vec_t matrix4x4[4][4]; typedef vec_t matrix4x4[4][4];
#if XASH_64BIT
typedef uint32_t poolhandle_t; typedef uint32_t poolhandle_t;
#else
typedef void* poolhandle_t;
#endif
#undef true #undef true
#undef false #undef false
@@ -58,9 +54,6 @@ typedef uint64_t longtime_t;
#define BIT( n ) ( 1U << ( n )) #define BIT( n ) ( 1U << ( n ))
#define BIT64( n ) ( 1ULL << ( n )) #define BIT64( n ) ( 1ULL << ( n ))
#define GAMMA ( 2.2f ) // Valve Software gamma
#define INVGAMMA ( 1.0f / 2.2f ) // back to 1.0
#define TEXGAMMA ( 0.9f ) // compensate dim textures
#define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits)) #define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits)) #define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit)) #define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))
@@ -78,50 +71,94 @@ typedef uint64_t longtime_t;
#define ColorIndex( c ) ((( c ) - '0' ) & 7 ) #define ColorIndex( c ) ((( c ) - '0' ) & 7 )
#if defined( __GNUC__ ) #if defined( __GNUC__ )
#ifdef __i386__ #if defined( __i386__ )
#define EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer )) #define EXPORT __attribute__(( visibility( "default" ), force_align_arg_pointer ))
#define GAME_EXPORT __attribute(( force_align_arg_pointer )) #define GAME_EXPORT __attribute(( force_align_arg_pointer ))
#else #else
#define EXPORT __attribute__(( visibility ( "default" ))) #define EXPORT __attribute__(( visibility ( "default" )))
#define GAME_EXPORT #define GAME_EXPORT
#endif #endif
#define _format(x) __attribute__((format(printf, x, x+1)))
#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 NORETURN __attribute__(( noreturn ))
#define NONNULL __attribute__(( nonnull )) #define NONNULL __attribute__(( nonnull ))
#elif defined(_MSC_VER) #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 )
#define EXPORT __declspec( dllexport ) #define EXPORT __declspec( dllexport )
#define GAME_EXPORT #define NO_ASAN __declspec( no_sanitize_address )
#define _format(x)
#define NORETURN
#define NONNULL
#else #else
#define EXPORT #define EXPORT
#define NO_ASAN
#endif
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x)
#define NORETURN #define NORETURN
#define NONNULL #define NONNULL
#define _format( x )
#define ALLOC_CHECK( x )
#define RENAME_SYMBOL( x )
#define MALLOC
#define MALLOC_LIKE( x, y )
#define WARN_UNUSED_RESULT
#endif #endif
#if ( __GNUC__ >= 3 ) #if __GNUC__ >= 3
#define unlikely( x ) __builtin_expect( x, 0 ) #define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 ) #define likely( x ) __builtin_expect( x, 1 )
#elif defined( __has_builtin ) #elif defined( __has_builtin )
#if __has_builtin( __builtin_expect ) #if __has_builtin( __builtin_expect ) // this must be after defined() check
#define unlikely( x ) __builtin_expect( x, 0 ) #define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 ) #define likely( x ) __builtin_expect( x, 1 )
#else
#define unlikely(x) (x)
#define likely(x) (x)
#endif #endif
#else #endif
#if !defined( unlikely ) || !defined( likely )
#define unlikely( x ) ( x ) #define unlikely( x ) ( x )
#define likely( x ) ( x ) #define likely( x ) ( x )
#endif #endif
#if defined( static_assert ) // C11 static_assert #if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
#define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y )
#define STATIC_ASSERT static_assert #define STATIC_ASSERT static_assert
#elif __STDC_VERSION__ >= 201112L // in C11 it's _Static_assert
#define STATIC_ASSERT_( ignore, x, y ) _Static_assert( x, y )
#define STATIC_ASSERT _Static_assert
#else #else
#define STATIC_ASSERT( x, y ) extern int _static_assert_##__LINE__[( x ) ? 1 : -1] #define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1]
// need these to correctly expand the line macro
#define STATIC_ASSERT_3( line, x, y ) STATIC_ASSERT_( static_assert_ ## line, x, y )
#define STATIC_ASSERT_2( line, x, y ) STATIC_ASSERT_3( line, x, y )
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
#endif
// at least, statically check size of some public structures
#if XASH_64BIT
#define STATIC_CHECK_SIZEOF( type, size32, size64 ) \
STATIC_ASSERT( sizeof( type ) == size64, #type " unexpected size" )
#else
#define STATIC_CHECK_SIZEOF( type, size32, size64 ) \
STATIC_ASSERT( sizeof( type ) == size32, #type " unexpected size" )
#endif
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
#define XASH_RESTRICT restrict
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
#define XASH_RESTRICT __restrict
#else
#define XASH_RESTRICT // nothing
#endif #endif
#ifdef XASH_BIG_ENDIAN #ifdef XASH_BIG_ENDIAN
@@ -156,6 +193,7 @@ _inline float LittleFloat( float f )
typedef unsigned int dword; typedef unsigned int dword;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned long ulong;
typedef char string[MAX_STRING]; typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file typedef struct file_s file_t; // normal file
typedef struct stream_s stream_t; // sound stream for background music playing typedef struct stream_s stream_t; // sound stream for background music playing

View File

@@ -74,7 +74,7 @@ typedef struct
float size; float size;
} daliashdr_t; } daliashdr_t;
STATIC_ASSERT( sizeof( daliashdr_t ) == 84, "invalid daliashdr_t size" ); STATIC_CHECK_SIZEOF( daliashdr_t, 84, 84 );
typedef struct typedef struct
{ {
@@ -83,7 +83,7 @@ typedef struct
int32_t t; int32_t t;
} stvert_t; } stvert_t;
STATIC_ASSERT( sizeof( stvert_t ) == 12, "invalid stvert_t size" ); STATIC_CHECK_SIZEOF( stvert_t, 12, 12 );
typedef struct dtriangle_s typedef struct dtriangle_s
{ {
@@ -91,7 +91,7 @@ typedef struct dtriangle_s
int32_t vertindex[3]; int32_t vertindex[3];
} dtriangle_t; } dtriangle_t;
STATIC_ASSERT( sizeof( dtriangle_t ) == 16, "invalid dtriangle_t size" ); STATIC_CHECK_SIZEOF( dtriangle_t, 16, 16 );
#define DT_FACES_FRONT 0x0010 #define DT_FACES_FRONT 0x0010
#define ALIAS_ONSEAM 0x0020 #define ALIAS_ONSEAM 0x0020
@@ -103,7 +103,7 @@ typedef struct
char name[16]; // frame name from grabbing char name[16]; // frame name from grabbing
} daliasframe_t; } daliasframe_t;
STATIC_ASSERT( sizeof( daliasframe_t ) == 24, "invalid daliasframe_t size" ); STATIC_CHECK_SIZEOF( daliasframe_t, 24, 24 );
typedef struct typedef struct
{ {
@@ -112,41 +112,41 @@ typedef struct
trivertex_t bboxmax; // lightnormal isn't used trivertex_t bboxmax; // lightnormal isn't used
} daliasgroup_t; } daliasgroup_t;
STATIC_ASSERT( sizeof( daliasgroup_t ) == 12, "invalid daliasgrou_t size" ); STATIC_CHECK_SIZEOF( daliasgroup_t, 12, 12 );
typedef struct typedef struct
{ {
int32_t numskins; int32_t numskins;
} daliasskingroup_t; } daliasskingroup_t;
STATIC_ASSERT( sizeof( daliasskingroup_t ) == 4, "invalid daliasskingroup_t size" ); STATIC_CHECK_SIZEOF( daliasskingroup_t, 4, 4 );
typedef struct typedef struct
{ {
float interval; float interval;
} daliasinterval_t; } daliasinterval_t;
STATIC_ASSERT( sizeof( daliasinterval_t ) == 4, "invalid daliasinterval_t size" ); STATIC_CHECK_SIZEOF( daliasinterval_t, 4, 4 );
typedef struct typedef struct
{ {
float interval; float interval;
} daliasskininterval_t; } daliasskininterval_t;
STATIC_ASSERT( sizeof( daliasskininterval_t ) == 4, "invalid daliasskininterval_t size" ); STATIC_CHECK_SIZEOF( daliasskininterval_t, 4, 4 );
typedef struct typedef struct
{ {
uint32_t type; // was aliasframetype_t uint32_t type; // was aliasframetype_t
} daliasframetype_t; } daliasframetype_t;
STATIC_ASSERT( sizeof( daliasframetype_t ) == 4, "invalid daliasframetype_t size" ); STATIC_CHECK_SIZEOF( daliasframetype_t, 4, 4 );
typedef struct typedef struct
{ {
uint32_t type; // was aliasskintype_t uint32_t type; // was aliasskintype_t
} daliasskintype_t; } daliasskintype_t;
STATIC_ASSERT( sizeof( daliasskintype_t ) == 4, "invalid daliasskintype_t size" ); STATIC_CHECK_SIZEOF( daliasskintype_t, 4, 4 );
#endif//ALIAS_H #endif//ALIAS_H

View File

@@ -1,18 +1,22 @@
/*** /*
* Copyright (C) 1996-1997 Id Software, Inc.
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
{-0.525731, 0.000000, 0.850651}, {-0.525731, 0.000000, 0.850651},
{-0.442863, 0.238856, 0.864188}, {-0.442863, 0.238856, 0.864188},
{-0.295242, 0.000000, 0.955423}, {-0.295242, 0.000000, 0.955423},

View File

@@ -85,6 +85,12 @@ void CL_PlayCDTrack_f( void )
paused = false; paused = false;
looped = false; looped = false;
} }
else if( !Q_stricmp( command, "playfile" ))
{
S_StartBackgroundTrack( pszTrack, NULL, 0, true );
paused = false;
looped = false;
}
else if( !Q_stricmp( command, "loop" )) else if( !Q_stricmp( command, "loop" ))
{ {
if( Q_isdigit( pszTrack )) if( Q_isdigit( pszTrack ))
@@ -96,6 +102,12 @@ void CL_PlayCDTrack_f( void )
paused = false; paused = false;
looped = true; looped = true;
} }
else if( !Q_stricmp( command, "loopfile" ))
{
S_StartBackgroundTrack( pszTrack, pszTrack, 0, true );
paused = false;
looped = true;
}
else if( !Q_stricmp( command, "pause" )) else if( !Q_stricmp( command, "pause" ))
{ {
S_StreamSetPause( true ); S_StreamSetPause( true );
@@ -145,32 +157,12 @@ void CL_PlayCDTrack_f( void )
CL_ScreenshotGetName CL_ScreenshotGetName
================== ==================
*/ */
static qboolean CL_ScreenshotGetName( int lastnum, char *filename, size_t size ) static qboolean CL_ScreenshotGetName( const char *fmt, int lastnum, char *filename, size_t size )
{ {
if( lastnum < 0 || lastnum > 9999 ) if( lastnum < 0 || lastnum > 9999 )
{
Con_Printf( S_ERROR "unable to write screenshot\n" );
return false; return false;
}
return Q_snprintf( filename, size, "scrshots/%s_shot%04d.png", clgame.mapname, lastnum ) > 0; return Q_snprintf( filename, size, fmt, clgame.mapname, lastnum ) > 0;
}
/*
==================
CL_SnapshotGetName
==================
*/
static qboolean CL_SnapshotGetName( int lastnum, char *filename, size_t size )
{
if( lastnum < 0 || lastnum > 9999 )
{
Con_Printf( S_ERROR "unable to write snapshot\n" );
FS_AllowDirectPaths( false );
return false;
}
return Q_snprintf( filename, size, "../%s_%04d.png", clgame.mapname, lastnum ) > 0;
} }
/* /*
@@ -180,127 +172,6 @@ static qboolean CL_SnapshotGetName( int lastnum, char *filename, size_t size )
============================================================================== ==============================================================================
*/ */
/*
==================
CL_ScreenShot_f
normal screenshot
==================
*/
void CL_ScreenShot_f( void )
{
int i;
string checkname;
if( CL_IsDevOverviewMode() == 1 )
{
// special case for write overview image and script file
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
}
else
{
// scan for a free filename
for( i = 0; i < 9999; i++ )
{
if( !CL_ScreenshotGetName( i, checkname, sizeof( checkname )))
return; // no namespace
if( !FS_FileExists( checkname, true ))
break;
}
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
cls.scrshot_action = scrshot_normal; // build new frame for screenshot
}
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_SnapShot_f
save screenshots into root dir
==================
*/
void CL_SnapShot_f( void )
{
int i;
string checkname;
if( CL_IsDevOverviewMode() == 1 )
{
// special case for write overview image and script file
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
cls.scrshot_action = scrshot_mapshot; // build new frame for mapshot
}
else
{
FS_AllowDirectPaths( true );
// scan for a free filename
for( i = 0; i < 9999; i++ )
{
if( !CL_SnapshotGetName( i, checkname, sizeof( checkname )))
return; // no namespace
if( !FS_FileExists( checkname, true ))
break;
}
FS_AllowDirectPaths( false );
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
cls.scrshot_action = scrshot_snapshot; // build new frame for screenshot
}
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_EnvShot_f
cubemap view
==================
*/
void CL_EnvShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "envshot <shotname>\n" );
return;
}
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_envshot; // build new frame for envshot
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/*
==================
CL_SkyShot_f
skybox view
==================
*/
void CL_SkyShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "skyshot <shotname>\n" );
return;
}
Q_snprintf( cls.shotname, sizeof( cls.shotname ),"gfx/env/%s", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_skyshot; // build new frame for skyshot
cls.envshot_vieworg = NULL; // no custom view
cls.envshot_viewsize = 0;
}
/* /*
================== ==================
CL_LevelShot_f CL_LevelShot_f
@@ -343,23 +214,107 @@ void CL_LevelShot_f( void )
else cls.scrshot_action = scrshot_inactive; // disable - not needs else cls.scrshot_action = scrshot_inactive; // disable - not needs
} }
/* static scrshot_t CL_GetScreenshotTypeFromString( const char *string )
================== {
CL_SaveShot_f if( !Q_stricmp( string, "snapshot" ))
return scrshot_snapshot;
mini-pic in loadgame menu if( !Q_stricmp( string, "screenshot" ))
================== return scrshot_normal;
*/
void CL_SaveShot_f( void ) if( !Q_stricmp( string, "saveshot" ))
return scrshot_savegame;
if( !Q_stricmp( string, "envshot" ))
return scrshot_envshot;
if( !Q_stricmp( string, "skyshot" ))
return scrshot_skyshot;
return scrshot_inactive;
}
void CL_GenericShot_f( void )
{
const char *argv0 = Cmd_Argv( 0 );
scrshot_t type;
type = CL_GetScreenshotTypeFromString( argv0 );
if( type == scrshot_normal || type == scrshot_snapshot )
{
if( CL_IsDevOverviewMode() == 1 )
type = scrshot_mapshot;
}
else
{ {
if( Cmd_Argc() < 2 ) if( Cmd_Argc() < 2 )
{ {
Con_Printf( S_USAGE "saveshot <savename>\n" ); Con_Printf( S_USAGE "%s <shotname>\n", argv0 );
return;
}
}
switch( type )
{
case scrshot_envshot:
case scrshot_skyshot:
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "gfx/env/%s", Cmd_Argv( 1 ));
break;
case scrshot_savegame:
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 ));
break;
case scrshot_mapshot:
Q_snprintf( cls.shotname, sizeof( cls.shotname ), "overviews/%s.bmp", clgame.mapname );
break;
case scrshot_normal:
case scrshot_snapshot:
{
const char *fmt;
string checkname;
int i;
// 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";
FS_AllowDirectPaths( true );
}
else fmt = "scrshots/%s_shot%04d.png";
for( i = 0; i < 9999; i++ )
{
if( !CL_ScreenshotGetName( fmt, i, checkname, sizeof( checkname )))
{
Con_Printf( S_ERROR "unable to write %s\n", argv0 );
FS_AllowDirectPaths( false );
return; return;
} }
Q_snprintf( cls.shotname, sizeof( cls.shotname ), DEFAULT_SAVE_DIRECTORY "%s.bmp", Cmd_Argv( 1 )); if( !FS_FileExists( checkname, true ))
cls.scrshot_action = scrshot_savegame; // build new frame for saveshot break;
}
FS_AllowDirectPaths( false );
Q_strncpy( cls.shotname, checkname, sizeof( cls.shotname ));
break;
}
case scrshot_inactive:
case scrshot_plaque:
default:
return; // shouldn't happen
}
cls.scrshot_action = type; // build new frame for saveshot
cls.envshot_vieworg = NULL;
cls.envshot_viewsize = 0;
} }
/* /*
@@ -401,7 +356,7 @@ void CL_SetSky_f( void )
return; return;
} }
ref.dllFuncs.R_SetupSky( Cmd_Argv( 1 )); R_SetupSky( Cmd_Argv( 1 ));
} }
/* /*

View File

@@ -70,16 +70,17 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
return true; return true;
} }
if( cl.downloadUrl[0] ) host.downloadcount++;
if( cl.http_download )
{ {
HTTP_AddDownload( filepath, pResource->nDownloadSize, true ); HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
host.downloadcount++;
return false;
} }
else
{
MSG_BeginClientCmd( msg, clc_stringcmd ); MSG_BeginClientCmd( msg, clc_stringcmd );
MSG_WriteStringf( msg, "dlfile %s", filepath ); MSG_WriteStringf( msg, "dlfile %s", filepath );
host.downloadcount++; }
return false; return false;
} }
@@ -104,7 +105,7 @@ void CL_AddToResourceList( resource_t *pResource, resource_t *pList )
void CL_RemoveFromResourceList( resource_t *pResource ) void CL_RemoveFromResourceList( resource_t *pResource )
{ {
if( pResource->pPrev == NULL || pResource->pNext == NULL ) if( pResource->pPrev == NULL || pResource->pNext == NULL )
Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" ); Host_Error( "mislinked resource in %s\n", __func__ );
if( pResource->pNext == pResource || pResource->pPrev == pResource ) if( pResource->pNext == pResource || pResource->pPrev == pResource )
Host_Error( "attempt to free last entry in list.\n" ); Host_Error( "attempt to free last entry in list.\n" );
@@ -119,7 +120,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
{ {
if( !pResource ) if( !pResource )
{ {
Con_Reportf( "Null resource passed to CL_MoveToOnHandList\n" ); Con_Reportf( "Null resource passed to %s\n", __func__ );
return; return;
} }
@@ -127,7 +128,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
CL_AddToResourceList( pResource, &cl.resourcesonhand ); CL_AddToResourceList( pResource, &cl.resourcesonhand );
} }
void CL_ClearResourceList( resource_t *pList ) static void CL_ClearResourceList( resource_t *pList )
{ {
resource_t *p, *n; resource_t *p, *n;

View File

@@ -50,7 +50,29 @@ const char *CL_MsgInfo( int cmd )
if( cmd >= 0 && cmd <= svc_lastmsg ) if( cmd >= 0 && cmd <= svc_lastmsg )
{ {
// get engine message name // get engine message name
Q_strncpy( sz, svc_strings[cmd], sizeof( sz )); const char *svc_string = NULL;
switch( cls.legacymode )
{
case PROTO_CURRENT:
svc_string = svc_strings[cmd];
break;
case PROTO_LEGACY:
svc_string = svc_legacy_strings[cmd];
break;
case PROTO_QUAKE:
svc_string = svc_quake_strings[cmd];
break;
case PROTO_GOLDSRC:
svc_string = svc_goldsrc_strings[cmd];
break;
}
// fall back to current protocol strings
if( !svc_string )
svc_string = svc_strings[cmd];
Q_strncpy( sz, svc_string, sizeof( sz ));
} }
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES )) else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
{ {

View File

@@ -40,6 +40,8 @@ GNU General Public License for more details.
#define IDEMOHEADER (('M'<<24)+('E'<<16)+('D'<<8)+'I') // little-endian "IDEM" #define IDEMOHEADER (('M'<<24)+('E'<<16)+('D'<<8)+'I') // little-endian "IDEM"
#define DEMO_PROTOCOL 3 #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] = const char *demo_cmd[dem_lastcmd+1] =
{ {
"dem_unknown", "dem_unknown",
@@ -79,7 +81,7 @@ typedef struct
typedef struct typedef struct
{ {
demoentry_t *entries; // track entry info demoentry_t *entries; // track entry info
int numentries; // number of tracks int32_t numentries; // number of tracks
} demodirectory_t; } demodirectory_t;
// add angles // add angles
@@ -107,6 +109,42 @@ struct
int angle_position; int angle_position;
} demo; } demo;
static qboolean CL_NextDemo( void );
static int CL_GetDemoNetProtocol( connprotocol_t proto )
{
switch( proto )
{
case PROTO_CURRENT:
return PROTOCOL_VERSION;
case PROTO_LEGACY:
return PROTOCOL_LEGACY_VERSION;
case PROTO_QUAKE:
return PROTOCOL_VERSION_QUAKE;
case PROTO_GOLDSRC:
return PROTOCOL_GOLDSRC_VERSION_DEMO;
}
return PROTOCOL_VERSION;
}
static connprotocol_t CL_GetProtocolFromDemo( int net_protocol )
{
switch( net_protocol )
{
case PROTOCOL_VERSION:
return PROTO_CURRENT;
case PROTOCOL_LEGACY_VERSION:
return PROTO_LEGACY;
case PROTOCOL_VERSION_QUAKE:
return PROTO_QUAKE;
case PROTOCOL_GOLDSRC_VERSION_DEMO:
return PROTO_GOLDSRC;
}
return PROTO_CURRENT;
}
/* /*
==================== ====================
CL_StartupDemoHeader CL_StartupDemoHeader
@@ -117,12 +155,8 @@ we record a demo on this level
*/ */
void CL_StartupDemoHeader( void ) void CL_StartupDemoHeader( void )
{ {
if( cls.demoheader ) CL_CloseDemoHeader();
{
FS_Close( cls.demoheader );
}
// Note: this is replacing tmpfile()
cls.demoheader = FS_Open( "demoheader.tmp", "w+b", true ); cls.demoheader = FS_Open( "demoheader.tmp", "w+b", true );
if( !cls.demoheader ) if( !cls.demoheader )
@@ -156,7 +190,7 @@ CL_GetDemoRecordClock
write time while demo is recording write time while demo is recording
==================== ====================
*/ */
float CL_GetDemoRecordClock( void ) static float CL_GetDemoRecordClock( void )
{ {
return cl.mtime[0]; return cl.mtime[0];
} }
@@ -168,7 +202,7 @@ CL_GetDemoPlaybackClock
overwrite host.realtime overwrite host.realtime
==================== ====================
*/ */
float CL_GetDemoPlaybackClock( void ) static float CL_GetDemoPlaybackClock( void )
{ {
return host.realtime + host.frametime; return host.realtime + host.frametime;
} }
@@ -194,7 +228,7 @@ CL_WriteDemoCmdHeader
Writes the demo command header and time-delta Writes the demo command header and time-delta
==================== ====================
*/ */
void CL_WriteDemoCmdHeader( byte cmd, file_t *file ) static void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
{ {
float dt; float dt;
@@ -267,7 +301,7 @@ Save state of cls.netchan sequences
so that we can play the demo correctly. so that we can play the demo correctly.
==================== ====================
*/ */
void CL_WriteDemoSequence( file_t *file ) static void CL_WriteDemoSequence( file_t *file )
{ {
Assert( file != NULL ); Assert( file != NULL );
@@ -295,10 +329,6 @@ void CL_WriteDemoMessage( qboolean startup, int start, sizebuf_t *msg )
if( !file ) return; if( !file ) return;
// past the start but not recording a demo.
if( !startup && !cls.demorecording )
return;
swlen = MSG_GetNumBytesWritten( msg ) - start; swlen = MSG_GetNumBytesWritten( msg ) - start;
if( swlen <= 0 ) return; if( swlen <= 0 ) return;
@@ -348,7 +378,7 @@ CL_WriteDemoHeader
Write demo header Write demo header
==================== ====================
*/ */
void CL_WriteDemoHeader( const char *name ) static void CL_WriteDemoHeader( const char *name )
{ {
int copysize; int copysize;
int savepos; int savepos;
@@ -371,8 +401,8 @@ void CL_WriteDemoHeader( const char *name )
demo.header.id = IDEMOHEADER; demo.header.id = IDEMOHEADER;
demo.header.dem_protocol = DEMO_PROTOCOL; demo.header.dem_protocol = DEMO_PROTOCOL;
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION; demo.header.net_protocol = CL_GetDemoNetProtocol( cls.legacymode );
demo.header.host_fps = bound( MIN_FPS, host_maxfps.value, MAX_FPS ); demo.header.host_fps = host_maxfps.value ? bound( MIN_FPS, host_maxfps.value, MAX_FPS ) : MAX_FPS;
Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname )); Q_strncpy( demo.header.mapname, clgame.mapname, sizeof( demo.header.mapname ));
Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment )); Q_strncpy( demo.header.comment, clgame.maptitle, sizeof( demo.header.comment ));
Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir )); Q_strncpy( demo.header.gamedir, FS_Gamedir(), sizeof( demo.header.gamedir ));
@@ -391,6 +421,7 @@ void CL_WriteDemoHeader( const char *name )
// finish off the startup info. // finish off the startup info.
CL_WriteDemoCmdHeader( dem_stop, cls.demoheader ); CL_WriteDemoCmdHeader( dem_stop, cls.demoheader );
FS_Flush( cls.demoheader );
// now copy the stuff we cached from the server. // now copy the stuff we cached from the server.
copysize = savepos = FS_Tell( cls.demoheader ); copysize = savepos = FS_Tell( cls.demoheader );
@@ -436,7 +467,7 @@ CL_StopRecord
finish recording demo finish recording demo
================= =================
*/ */
void CL_StopRecord( void ) static void CL_StopRecord( void )
{ {
int i, curpos; int i, curpos;
float stoptime; float stoptime;
@@ -518,7 +549,7 @@ CL_ReadDemoCmdHeader
read the demo command read the demo command
================= =================
*/ */
qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt ) static qboolean CL_ReadDemoCmdHeader( byte *cmd, float *dt )
{ {
// read the command // read the command
// HACKHACK: skip NOPs // HACKHACK: skip NOPs
@@ -548,7 +579,7 @@ read the demo usercmd for predicting
and smooth movement during playback the demo and smooth movement during playback the demo
================= =================
*/ */
void CL_ReadDemoUserCmd( qboolean discard ) static void CL_ReadDemoUserCmd( qboolean discard )
{ {
byte data[1024]; byte data[1024];
int cmdnumber; int cmdnumber;
@@ -570,6 +601,9 @@ void CL_ReadDemoUserCmd( qboolean discard )
memset( &nullcmd, 0, sizeof( nullcmd )); memset( &nullcmd, 0, sizeof( nullcmd ));
MSG_Init( &buf, "UserCmd", data, sizeof( data )); MSG_Init( &buf, "UserCmd", data, sizeof( data ));
// a1ba: I have no proper explanation why
cmdnumber++;
pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK]; pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK];
pcmd->processedfuncs = false; pcmd->processedfuncs = false;
pcmd->senttime = 0.0f; pcmd->senttime = 0.0f;
@@ -610,7 +644,7 @@ CL_ReadDemoSequence
read netchan sequences read netchan sequences
================= =================
*/ */
void CL_ReadDemoSequence( qboolean discard ) static void CL_ReadDemoSequence( qboolean discard )
{ {
int incoming_sequence; int incoming_sequence;
int incoming_acknowledged; int incoming_acknowledged;
@@ -644,7 +678,7 @@ void CL_ReadDemoSequence( qboolean discard )
CL_DemoStartPlayback CL_DemoStartPlayback
================= =================
*/ */
void CL_DemoStartPlayback( int mode ) static void CL_DemoStartPlayback( int mode )
{ {
if( cls.changedemo ) if( cls.changedemo )
{ {
@@ -674,7 +708,7 @@ void CL_DemoStartPlayback( int mode )
demo.starttime = CL_GetDemoPlaybackClock(); // for determining whether to read another message 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 ); Netchan_Setup( NS_CLIENT, &cls.netchan, net_from, Cvar_VariableInteger( "net_qport" ), NULL, CL_GetFragmentSize, 0 );
memset( demo.cmds, 0, sizeof( demo.cmds )); memset( demo.cmds, 0, sizeof( demo.cmds ));
demo.angle_position = 1; demo.angle_position = 1;
@@ -689,7 +723,7 @@ void CL_DemoStartPlayback( int mode )
CL_DemoAborted CL_DemoAborted
================= =================
*/ */
void CL_DemoAborted( void ) static void CL_DemoAborted( void )
{ {
if( cls.demofile ) if( cls.demofile )
FS_Close( cls.demofile ); FS_Close( cls.demofile );
@@ -729,7 +763,7 @@ returns true on success, false on failure
g-cont. probably captain obvious mode is ON g-cont. probably captain obvious mode is ON
================= =================
*/ */
qboolean CL_DemoMoveToNextSection( void ) static qboolean CL_DemoMoveToNextSection( void )
{ {
if( ++demo.entryIndex >= demo.directory.numentries ) if( ++demo.entryIndex >= demo.directory.numentries )
{ {
@@ -751,7 +785,7 @@ qboolean CL_DemoMoveToNextSection( void )
return true; return true;
} }
qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length ) static qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
{ {
int msglen = 0; int msglen = 0;
@@ -802,7 +836,7 @@ CL_DemoReadMessageQuake
reads demo data and write it to client reads demo data and write it to client
================= =================
*/ */
qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length ) static qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
{ {
vec3_t viewangles; vec3_t viewangles;
int msglen = 0; int msglen = 0;
@@ -1017,7 +1051,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
return CL_ReadRawNetworkData( buffer, length ); return CL_ReadRawNetworkData( buffer, length );
} }
void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next ) static void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next )
{ {
int i, i0, i1, imod; int i, i0, i1, imod;
float at; float at;
@@ -1112,8 +1146,9 @@ CL_FinishTimeDemo
show stats show stats
============== ==============
*/ */
void CL_FinishTimeDemo( void ) static void CL_FinishTimeDemo( void )
{ {
qboolean temp = host.allow_console;
int frames; int frames;
double time; double time;
@@ -1124,7 +1159,9 @@ void CL_FinishTimeDemo( void )
time = host.realtime - cls.td_starttime; time = host.realtime - cls.td_starttime;
if( !time ) time = 1.0; if( !time ) time = 1.0;
host.allow_console = true;
Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time ); Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time );
host.allow_console = temp;
if( Sys_CheckParm( "-timedemo" )) if( Sys_CheckParm( "-timedemo" ))
CL_Quit_f(); CL_Quit_f();
@@ -1261,7 +1298,7 @@ CL_NextDemo
Called when a demo finishes Called when a demo finishes
================== ==================
*/ */
qboolean CL_NextDemo( void ) static qboolean CL_NextDemo( void )
{ {
char str[MAX_QPATH]; char str[MAX_QPATH];
@@ -1413,6 +1450,51 @@ void CL_Record_f( void )
CL_WriteDemoHeader( demopath ); CL_WriteDemoHeader( demopath );
} }
static qboolean CL_ParseDemoHeader( const char *callee, const char *filename, file_t *f, demoheader_t *hdr, int32_t *numentries )
{
if( FS_Read( f, hdr, sizeof( *hdr )) != sizeof( *hdr ) || hdr->id != IDEMOHEADER )
{
Con_Printf( S_ERROR "%s: %s is not in supported format or not a demo file\n", callee, filename );
return false;
}
// force null terminate strings
hdr->mapname[sizeof( hdr->mapname ) - 1] = 0;
hdr->comment[sizeof( hdr->comment ) - 1] = 0;
hdr->gamedir[sizeof( hdr->gamedir ) - 1] = 0;
if( hdr->dem_protocol != DEMO_PROTOCOL )
{
Con_Printf( S_ERROR "%s: demo protocol outdated (%i should be %i)\n",
callee, hdr->net_protocol, DEMO_PROTOCOL );
return false;
}
if( hdr->net_protocol != PROTOCOL_VERSION && hdr->net_protocol != PROTOCOL_LEGACY_VERSION )
{
Con_Printf( S_ERROR "%s: net protocol outdated (%i should be %i or %i)\n",
callee, hdr->net_protocol, PROTOCOL_VERSION, PROTOCOL_LEGACY_VERSION );
return false;
}
if( FS_Seek( f, hdr->directory_offset, SEEK_SET ) < 0
|| FS_Read( f, numentries, sizeof( *numentries )) != sizeof( *numentries ))
{
Con_Printf( S_ERROR "%s: can't find directory offset in %s, demo file corrupted\n",
callee, filename );
return false;
}
if(( *numentries < 1 ) || ( *numentries > 1024 ))
{
Con_Printf( S_ERROR "%s: demo have bogus # of directory entries: %i\n",
callee, *numentries );
return false;
}
return true;
}
/* /*
==================== ====================
CL_PlayDemo_f CL_PlayDemo_f
@@ -1433,9 +1515,7 @@ void CL_PlayDemo_f( void )
} }
if( cls.demoplayback ) if( cls.demoplayback )
{
CL_StopPlayback(); CL_StopPlayback();
}
if( cls.demorecording ) if( cls.demorecording )
{ {
@@ -1485,51 +1565,32 @@ void CL_PlayDemo_f( void )
if( neg ) cls.forcetrack = -cls.forcetrack; if( neg ) cls.forcetrack = -cls.forcetrack;
CL_DemoStartPlayback( DEMO_QUAKE1 ); CL_DemoStartPlayback( DEMO_QUAKE1 );
cls.legacymode = PROTO_QUAKE;
return; // quake demo is started return; // quake demo is started
} }
// read in the demo header // read in the demo header
FS_Read( cls.demofile, &demo.header, sizeof( demoheader_t )); if( !CL_ParseDemoHeader( Cmd_Argv( 0 ), filename, cls.demofile, &demo.header, &demo.directory.numentries ))
if( demo.header.id != IDEMOHEADER )
{ {
Con_Printf( S_ERROR "%s is not a demo file\n", demoname );
CL_DemoAborted();
return;
}
if( demo.header.dem_protocol != DEMO_PROTOCOL )
{
Con_Printf( S_ERROR "playdemo: demo protocol outdated (%i should be %i)\n", demo.header.dem_protocol, DEMO_PROTOCOL );
CL_DemoAborted();
return;
}
if( demo.header.net_protocol != PROTOCOL_VERSION &&
demo.header.net_protocol != PROTOCOL_LEGACY_VERSION )
{
Con_Printf( S_ERROR "playdemo: net protocol outdated (%i should be %i)\n", demo.header.net_protocol, PROTOCOL_VERSION );
CL_DemoAborted();
return;
}
// now read in the directory structure.
FS_Seek( cls.demofile, demo.header.directory_offset, SEEK_SET );
FS_Read( cls.demofile, &demo.directory.numentries, sizeof( int ));
if( demo.directory.numentries < 1 || demo.directory.numentries > 1024 )
{
Con_Printf( S_ERROR "demo had bogus # of directory entries: %i\n", demo.directory.numentries );
CL_DemoAborted(); CL_DemoAborted();
return; return;
} }
// allocate demo entries // allocate demo entries
demo.directory.entries = Mem_Malloc( cls.mempool, sizeof( demoentry_t ) * demo.directory.numentries ); demo.directory.entries = Mem_Malloc( cls.mempool, sizeof( *demo.directory.entries ) * demo.directory.numentries );
for( i = 0; i < demo.directory.numentries; i++ ) for( i = 0; i < demo.directory.numentries; i++ )
{ {
FS_Read( cls.demofile, &demo.directory.entries[i], sizeof( demoentry_t )); demoentry_t *entry = &demo.directory.entries[i];
if( FS_Read( cls.demofile, entry, sizeof( *entry )) != sizeof( *entry ))
{
Con_Printf( S_ERROR "%s: demo entry %i of %s corrupted", Cmd_Argv( 0 ), i, filename );
CL_DemoAborted();
return;
}
entry->description[sizeof( entry->description ) - 1] = 0;
} }
demo.entryIndex = 0; demo.entryIndex = 0;
@@ -1539,9 +1600,11 @@ void CL_PlayDemo_f( void )
CL_DemoStartPlayback( DEMO_XASH3D ); CL_DemoStartPlayback( DEMO_XASH3D );
// must be after DemoStartPlayback, as CL_Disconnect_f resets the protocol
cls.legacymode = CL_GetProtocolFromDemo( demo.header.net_protocol );
// g-cont. is this need? // g-cont. is this need?
Q_strncpy( cls.servername, demoname, sizeof( cls.servername )); Q_strncpy( cls.servername, demoname, sizeof( cls.servername ));
cls.legacymode = demo.header.net_protocol == PROTOCOL_LEGACY_VERSION;
// begin a playback demo // begin a playback demo
} }
@@ -1583,7 +1646,7 @@ void CL_StartDemos_f( void )
c = Cmd_Argc() - 1; c = Cmd_Argc() - 1;
if( c > MAX_DEMOS ) if( c > MAX_DEMOS )
{ {
Con_DPrintf( S_WARN "Host_StartDemos: max %i demos in demoloop\n", MAX_DEMOS ); Con_DPrintf( S_WARN "%s: max %i demos in demoloop\n", __func__, MAX_DEMOS );
c = MAX_DEMOS; c = MAX_DEMOS;
} }
@@ -1641,3 +1704,78 @@ void CL_Stop_f( void )
S_StopBackgroundTrack(); S_StopBackgroundTrack();
} }
} }
void CL_ListDemo_f( void )
{
demoheader_t hdr;
int32_t num_entries;
file_t *f;
char filename[MAX_QPATH];
char demoname[MAX_QPATH];
int i;
if( Cmd_Argc() < 2 )
{
Con_Printf( S_USAGE "%s <demoname>\n", Cmd_Argv( 0 ));
return;
}
Q_strncpy( demoname, Cmd_Argv( 1 ), sizeof( demoname ));
COM_StripExtension( demoname );
Q_snprintf( filename, sizeof( filename ), "%s.dem", demoname );
f = FS_Open( filename, "rb", true );
if( !f )
{
Con_Printf( S_ERROR "couldn't open %s\n", filename );
return;
}
if( !CL_ParseDemoHeader( Cmd_Argv( 0 ), filename, f, &hdr, &num_entries ))
{
FS_Close( f );
return;
}
Con_Printf( "Demo contents for %s:\n"
"\tProtocol: %i net/%i demo\n"
"\tFPS: %g\n"
"\tMap: %s\n"
"\tComment: %s\n"
"\tGame: %s\n",
filename, hdr.net_protocol, hdr.dem_protocol, hdr.host_fps, hdr.mapname,
hdr.comment, hdr.gamedir );
for( i = 0; i < num_entries; i++ )
{
demoentry_t entry;
Con_Printf( "Demo entry #%i:\n", i );
if( FS_Read( f, &entry, sizeof( entry )) != sizeof( entry ))
{
Con_Printf( S_ERROR "can't read demo entry\n" );
FS_Close( f );
return;
}
entry.description[sizeof( entry.description ) - 1] = 0;
if( entry.entrytype == DEMO_STARTUP )
{
// startup entries don't have anything useful
Con_Printf( "\tEntry type: " S_YELLOW "startup" S_DEFAULT "\n" );
}
else
{
Con_Printf( "\tEntry type: " S_GREEN "normal" S_DEFAULT " (%i)\n"
"\tEntry playback time/frames: %.2f seconds/%i frames\n"
"\tEntry flags: 0x%x\n"
"\tEntry description: %s\n",
entry.entrytype, entry.playback_time, entry.playback_frames,
entry.flags, entry.description );
}
}
FS_Close( f );
}

View File

@@ -28,10 +28,51 @@ GNU General Public License for more details.
=============================================================================== ===============================================================================
*/ */
#define NUM_EFRAGS_ALLOC 64 // alloc 64 efrags (1-2kb each alloc)
static efrag_t **lastlink; static efrag_t **lastlink;
static mnode_t *r_pefragtopnode; static mnode_t *r_pefragtopnode;
static vec3_t r_emins, r_emaxs; static vec3_t r_emins, r_emaxs;
static cl_entity_t *r_addent; static cl_entity_t *r_addent;
static int cl_efrags_num;
static efrag_t *cl_efrags;
static efrag_t *CL_AllocEfrags( int num )
{
int i;
efrag_t *efrags;
if( !cl.worldmodel )
{
Host_Error( "%s: called with NULL world\n", __func__ );
return NULL;
}
if( num == 0 )
return NULL;
// set world to be the owner, so it will get automatically cleaned up
efrags = Mem_Calloc( cl.worldmodel->mempool, sizeof( *efrags ) * num );
// initialize linked list
for( i = 0; i < num - 1; i++ )
efrags[i].entnext = &efrags[i + 1];
cl_efrags_num += num;
return efrags;
}
/*
==============
CL_ClearEfrags
==============
*/
void CL_ClearEfrags( void )
{
cl_efrags_num = 0;
cl_efrags = NULL;
}
/* /*
=================== ===================
@@ -56,14 +97,11 @@ static void R_SplitEntityOnNode( mnode_t *node )
leaf = (mleaf_t *)node; leaf = (mleaf_t *)node;
// grab an efrag off the free list // grab an efrag off the free list
ef = clgame.free_efrags; ef = cl_efrags;
if( !ef ) if( !ef )
{ ef = CL_AllocEfrags( NUM_EFRAGS_ALLOC );
Con_Printf( S_ERROR "too many efrags!\n" );
return; // no free fragments...
}
clgame.free_efrags = ef->entnext; cl_efrags = ef->entnext;
ef->entity = r_addent; ef->entity = r_addent;
// add the entity link // add the entity link
@@ -133,21 +171,19 @@ R_StoreEfrags
*/ */
void R_StoreEfrags( efrag_t **ppefrag, int framecount ) void R_StoreEfrags( efrag_t **ppefrag, int framecount )
{ {
efrag_t *pefrag;
cl_entity_t *pent; cl_entity_t *pent;
model_t *clmodel; model_t *clmodel;
efrag_t *pefrag;
while(( pefrag = *ppefrag ) != NULL ) while(( pefrag = *ppefrag ) != NULL )
{ {
pent = pefrag->entity; pent = pefrag->entity;
clmodel = pent->model; clmodel = pent->model;
switch( clmodel->type ) // how this could happen?
{ if( unlikely( clmodel->type < mod_brush || clmodel->type > mod_studio ))
case mod_alias: continue;
case mod_brush:
case mod_studio:
case mod_sprite:
if( pent->visframe != framecount ) if( pent->visframe != framecount )
{ {
if( CL_AddVisibleEntity( pent, ET_FRAGMENTED )) if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))
@@ -159,9 +195,5 @@ void R_StoreEfrags( efrag_t **ppefrag, int framecount )
} }
ppefrag = &pefrag->leafnext; ppefrag = &pefrag->leafnext;
break;
default:
break;
}
} }
} }

View File

@@ -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( tracerlength, "0.8", 0, "tracer length factor" );
static CVAR_DEFINE_AUTO( traceroffset, "30", 0, "tracer starting offset" ); static CVAR_DEFINE_AUTO( traceroffset, "30", 0, "tracer starting offset" );
particle_t *cl_active_particles; static particle_t *cl_active_particles;
particle_t *cl_active_tracers; static particle_t *cl_active_tracers;
particle_t *cl_free_particles; static particle_t *cl_free_particles;
particle_t *cl_particles = NULL; // particle pool static particle_t *cl_particles = NULL; // particle pool
static vec3_t cl_avelocities[NUMVERTEXNORMALS]; static vec3_t cl_avelocities[NUMVERTEXNORMALS];
static float cl_lasttimewarn = 0.0f; static float cl_lasttimewarn = 0.0f;
// expand debugging BBOX particle hulls by this many units.
#define BOX_GAP 0.0f
/* /*
================ ================
R_LookupColor R_LookupColor
@@ -175,7 +178,7 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float )
return NULL; return NULL;
// never alloc particles when we not in game // never alloc particles when we not in game
// if( tr.frametime == 0.0 ) return NULL; if( cl_clientframetime() == 0.0 ) return NULL;
if( !cl_free_particles ) if( !cl_free_particles )
{ {
@@ -218,7 +221,7 @@ R_AllocTracer
can return NULL if particles is out can return NULL if particles is out
================ ================
*/ */
particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life ) static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
{ {
particle_t *p; particle_t *p;
@@ -226,7 +229,7 @@ particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
return NULL; return NULL;
// never alloc particles when we not in game // never alloc particles when we not in game
//if( tr.frametime == 0.0 ) return NULL; if( cl_clientframetime() == 0.0 ) return NULL;
if( !cl_free_particles ) if( !cl_free_particles )
{ {
@@ -250,7 +253,7 @@ particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
VectorCopy( vel, p->vel ); VectorCopy( vel, p->vel );
p->die = cl.time + life; p->die = cl.time + life;
p->ramp = tracerlength.value; p->ramp = tracerlength.value;
p->color = 4; // select custom color p->color = TRACER_COLORINDEX_DEFAULT; // select custom color
p->packedColor = 255; // alpha p->packedColor = 255; // alpha
return p; return p;
@@ -262,9 +265,9 @@ VIEWBEAMS MANAGEMENT
============================================================== ==============================================================
*/ */
BEAM *cl_active_beams; static BEAM *cl_active_beams;
BEAM *cl_free_beams; static BEAM *cl_free_beams;
BEAM *cl_viewbeams = NULL; // beams pool static BEAM *cl_viewbeams = NULL; // beams pool
/* /*
@@ -300,7 +303,7 @@ R_BeamAlloc
============== ==============
*/ */
BEAM *R_BeamAlloc( void ) static BEAM *R_BeamAlloc( void )
{ {
BEAM *pBeam; BEAM *pBeam;
@@ -323,7 +326,7 @@ R_BeamFree
============== ==============
*/ */
void R_BeamFree( BEAM *pBeam ) static void R_BeamFree( BEAM *pBeam )
{ {
// free particles that have died off. // free particles that have died off.
R_FreeDeadParticles( &pBeam->particles ); R_FreeDeadParticles( &pBeam->particles );
@@ -605,7 +608,7 @@ CL_BeamAttemptToDie
Check for expired beams Check for expired beams
============== ==============
*/ */
qboolean CL_BeamAttemptToDie( BEAM *pBeam ) static qboolean CL_BeamAttemptToDie( BEAM *pBeam )
{ {
Assert( pBeam != NULL ); Assert( pBeam != NULL );
@@ -636,12 +639,24 @@ and all particle trails (if this is a beamfollow)
*/ */
void GAME_EXPORT R_BeamKill( int deadEntity ) void GAME_EXPORT R_BeamKill( int deadEntity )
{ {
cl_entity_t *pDeadEntity; BEAM *beam;
pDeadEntity = R_BeamGetEntity( deadEntity ); for( beam = cl_active_beams; beam; beam = beam->next )
if( !pDeadEntity ) return; {
if( FBitSet( beam->flags, FBEAM_STARTENTITY ) && beam->startEntity == deadEntity )
{
if( beam->type != TE_BEAMFOLLOW )
beam->die = cl.time;
CL_KillDeadBeams( pDeadEntity ); ClearBits( beam->flags, FBEAM_STARTENTITY );
}
if( FBitSet( beam->flags, FBEAM_ENDENTITY ) && beam->endEntity == deadEntity )
{
beam->die = cl.time;
ClearBits( beam->flags, FBEAM_ENDENTITY );
}
}
} }
/* /*
@@ -1094,9 +1109,7 @@ void GAME_EXPORT R_ParticleExplosion2( const vec3_t org, int colorStart, int col
int colorMod = 0, packedColor; int colorMod = 0, packedColor;
particle_t *p; particle_t *p;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE )) packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
packedColor = 255; // use old code for blob particles
else packedColor = 0;
for( i = 0; i < 512; i++ ) for( i = 0; i < 512; i++ )
{ {
@@ -1129,9 +1142,7 @@ void GAME_EXPORT R_BlobExplosion( const vec3_t org )
particle_t *p; particle_t *p;
int i, j, packedColor; int i, j, packedColor;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE )) packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
packedColor = 255; // use old code for blob particles
else packedColor = 0;
for( i = 0; i < 1024; i++ ) for( i = 0; i < 1024; i++ )
{ {
@@ -1593,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 R_ParticleLine
@@ -1756,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 CL_Particle
@@ -2040,7 +2099,7 @@ void CL_ReadPointFile_f( void )
else Con_Printf( "map %s has no leaks!\n", clgame.mapname ); else Con_Printf( "map %s has no leaks!\n", clgame.mapname );
} }
void CL_FreeDeadBeams( void ) static void CL_FreeDeadBeams( void )
{ {
BEAM *pBeam, *pNext, *pPrev = NULL; BEAM *pBeam, *pNext, *pPrev = NULL;
// draw temporary entity beams // draw temporary entity beams

View File

@@ -40,7 +40,7 @@ CL_CalcPlayerVelocity
compute velocity for a given client compute velocity for a given client
============= =============
*/ */
void CL_CalcPlayerVelocity( int idx, vec3_t velocity ) static void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
{ {
clientdata_t *pcd; clientdata_t *pcd;
vec3_t delta; vec3_t delta;
@@ -78,7 +78,7 @@ CL_DescribeEvent
============= =============
*/ */
void CL_DescribeEvent( event_info_t *ei, int slot ) static void CL_DescribeEvent( event_info_t *ei, int slot )
{ {
int idx = (slot & 63) * 2; int idx = (slot & 63) * 2;
con_nprint_t info; con_nprint_t info;
@@ -192,7 +192,7 @@ void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func )
ev = clgame.events[lastnum]; ev = clgame.events[lastnum];
// NOTE: ev->index will be set later // NOTE: ev->index will be set later
Q_strncpy( ev->name, szEvName, MAX_QPATH ); Q_strncpy( ev->name, szEvName, sizeof( ev->name ));
ev->func = func; ev->func = func;
} }
@@ -202,7 +202,7 @@ CL_FireEvent
============= =============
*/ */
qboolean CL_FireEvent( event_info_t *ei, int slot ) static qboolean CL_FireEvent( event_info_t *ei, int slot )
{ {
cl_user_event_t *ev; cl_user_event_t *ev;
const char *name; const char *name;
@@ -219,7 +219,7 @@ qboolean CL_FireEvent( event_info_t *ei, int slot )
if( !ev ) if( !ev )
{ {
idx = bound( 1, ei->index, ( MAX_EVENTS - 1 )); idx = bound( 1, ei->index, ( MAX_EVENTS - 1 ));
Con_Reportf( S_ERROR "CL_FireEvent: %s not precached\n", cl.event_precache[idx] ); Con_Reportf( S_ERROR "%s: %s not precached\n", __func__, cl.event_precache[idx] );
break; break;
} }
@@ -244,7 +244,7 @@ qboolean CL_FireEvent( event_info_t *ei, int slot )
return true; return true;
} }
Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name ); Con_Reportf( S_ERROR "%s: %s not hooked\n", __func__, name );
break; break;
} }
} }
@@ -292,7 +292,7 @@ CL_FindEvent
find first empty event find first empty event
============= =============
*/ */
event_info_t *CL_FindEmptyEvent( void ) static event_info_t *CL_FindEmptyEvent( void )
{ {
int i; int i;
event_state_t *es; event_state_t *es;
@@ -320,7 +320,7 @@ CL_FindEvent
replace only unreliable events replace only unreliable events
============= =============
*/ */
event_info_t *CL_FindUnreliableEvent( void ) static event_info_t *CL_FindUnreliableEvent( void )
{ {
event_state_t *es; event_state_t *es;
event_info_t *ei; event_info_t *ei;
@@ -350,7 +350,7 @@ CL_QueueEvent
============= =============
*/ */
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args ) static void CL_QueueEvent( int flags, int index, float delay, event_args_t *args )
{ {
event_info_t *ei; event_info_t *ei;
@@ -380,7 +380,7 @@ CL_ParseReliableEvent
============= =============
*/ */
void CL_ParseReliableEvent( sizebuf_t *msg ) void CL_ParseReliableEvent( sizebuf_t *msg, connprotocol_t proto )
{ {
int event_index; int event_index;
event_args_t nullargs, args; event_args_t nullargs, args;
@@ -390,11 +390,19 @@ void CL_ParseReliableEvent( sizebuf_t *msg )
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS ); event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
// reliable events not use delta-compression just null-compression
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 )) if( MSG_ReadOneBit( msg ))
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f); delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
// reliable events not use delta-compression just null-compression
MSG_ReadDeltaEvent( msg, &nullargs, &args ); MSG_ReadDeltaEvent( msg, &nullargs, &args );
}
if( args.entindex > 0 && args.entindex <= cl.maxclients ) if( args.entindex > 0 && args.entindex <= cl.maxclients )
args.angles[PITCH] *= -3.0f; 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 event_index;
int i, num_events; int i, num_events;
int packet_index; int packet_index;
event_args_t nullargs, args; const event_args_t nullargs = { 0 };
event_args_t args = { 0 };
entity_state_t *state; entity_state_t *state;
float delay; float delay;
int entity_bits;
memset( &nullargs, 0, sizeof( nullargs ));
memset( &args, 0, sizeof( args ));
num_events = MSG_ReadUBitLong( msg, 5 ); 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 // parse events queue
for( i = 0 ; i < num_events; i++ ) for( i = 0 ; i < num_events; i++ )
{ {
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS ); event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))
packet_index = MSG_ReadUBitLong( msg, cls.legacymode ? MAX_LEGACY_ENTITY_BITS : MAX_ENTITY_BITS ); {
else packet_index = -1; packet_index = MSG_ReadUBitLong( msg, entity_bits );
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))
{ {
MSG_ReadDeltaEvent( msg, &nullargs, &args ); 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 )) if( MSG_ReadOneBit( msg ))
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f); delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
@@ -497,14 +514,14 @@ void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word even
// first check event for out of bounds // first check event for out of bounds
if( eventindex < 1 || eventindex >= MAX_EVENTS ) if( eventindex < 1 || eventindex >= MAX_EVENTS )
{ {
Con_DPrintf( S_ERROR "CL_PlaybackEvent: invalid eventindex %i\n", eventindex ); Con_DPrintf( S_ERROR "%s: invalid eventindex %i\n", __func__, eventindex );
return; return;
} }
// check event for precached // check event for precached
if( !CL_EventIndex( cl.event_precache[eventindex] )) if( !CL_EventIndex( cl.event_precache[eventindex] ))
{ {
Con_DPrintf( S_ERROR "CL_PlaybackEvent: event %i was not precached\n", eventindex ); Con_DPrintf( S_ERROR "%s: event %i was not precached\n", __func__, eventindex );
return; return;
} }

View File

@@ -46,10 +46,35 @@ static int CL_LoadFontTexture( const char *fontname, uint texFlags, int *width )
return tex; return tex;
} }
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags ) static int CL_FontRenderMode( convar_t *fontrender )
{
switch((int)fontrender->value )
{
case 0:
return kRenderTransAdd;
case 1:
return kRenderTransAlpha;
case 2:
return kRenderTransTexture;
default:
Cvar_DirectSet( fontrender, fontrender->def_string );
}
return kRenderTransTexture;
}
void CL_SetFontRendermode( cl_font_t *font )
{
ref.dllFuncs.GL_SetRenderMode( CL_FontRenderMode( font->rendermode ));
}
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
{ {
int font_width, i; int font_width, i;
if( !rendermode )
return false;
if( font->valid ) if( font->valid )
return true; // already loaded return true; // already loaded
@@ -60,7 +85,6 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
font->type = FONT_FIXED; font->type = FONT_FIXED;
font->valid = true; font->valid = true;
font->scale = scale; font->scale = scale;
font->nearest = FBitSet( texFlags, TF_NEAREST );
font->rendermode = rendermode; font->rendermode = rendermode;
font->charHeight = Q_rint( font_width / 16 * scale ); font->charHeight = Q_rint( font_width / 16 * scale );
@@ -77,13 +101,16 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
return true; return true;
} }
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags ) qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
{ {
fs_offset_t length; fs_offset_t length;
qfont_t src; qfont_t src;
byte *pfile; byte *pfile;
int font_width, i; int font_width, i;
if( !rendermode )
return false;
if( font->valid ) if( font->valid )
return true; return true;
@@ -106,8 +133,7 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
font->type = FONT_VARIABLE; font->type = FONT_VARIABLE;
font->valid = true; font->valid = true;
font->scale = scale; font->scale = scale ? scale : 1.0f;
font->nearest = FBitSet( texFlags, TF_NEAREST );
font->rendermode = rendermode; font->rendermode = rendermode;
font->charHeight = Q_rint( src.rowheight * scale ); font->charHeight = Q_rint( src.rowheight * scale );
@@ -179,7 +205,8 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
return font->charWidths[number]; return font->charWidths[number];
rc = &font->fontRc[number]; rc = &font->fontRc[number];
if( font->nearest || font->scale <= 1.0f )
if( font->scale <= 1.f || !REF_GET_PARM( PARM_TEX_FILTERING, font->hFontTexture ))
half = 0; half = 0;
s1 = ((float)rc->left + half ) / texw; s1 = ((float)rc->left + half ) / texw;
@@ -193,7 +220,7 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
SPR_AdjustSize( &x, &y, &w, &h ); SPR_AdjustSize( &x, &y, &w, &h );
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE )) if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
ref.dllFuncs.GL_SetRenderMode( font->rendermode ); CL_SetFontRendermode( font );
// don't apply color to fixed fonts it's already colored // don't apply color to fixed fonts it's already colored
if( font->type != FONT_FIXED || REF_GET_PARM( PARM_TEX_GLFORMAT, font->hFontTexture ) == 0x8045 ) // GL_LUMINANCE8_ALPHA8 if( font->type != FONT_FIXED || REF_GET_PARM( PARM_TEX_GLFORMAT, font->hFontTexture ) == 0x8045 ) // GL_LUMINANCE8_ALPHA8
@@ -216,7 +243,7 @@ int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *fon
Con_UtfProcessChar( 0 ); // clear utf state Con_UtfProcessChar( 0 ); // clear utf state
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE )) if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
ref.dllFuncs.GL_SetRenderMode( font->rendermode ); CL_SetFontRendermode( font );
Vector4Copy( color, current_color ); Vector4Copy( color, current_color );

View File

@@ -24,7 +24,7 @@ GNU General Public License for more details.
#include "sound.h" #include "sound.h"
#include "input.h" #include "input.h"
#define STUDIO_INTERPOLATION_FIX // #define STUDIO_INTERPOLATION_FIX
/* /*
================== ==================
@@ -52,19 +52,30 @@ CL_UpdatePositions
Store another position into interpolation circular buffer Store another position into interpolation circular buffer
================== ==================
*/ */
void CL_UpdatePositions( cl_entity_t *ent ) static void CL_UpdatePositions( cl_entity_t *ent )
{ {
position_history_t *ph; position_history_t *ph, *prev;
prev = &ent->ph[ent->current_position];
ent->current_position = (ent->current_position + 1) & HISTORY_MASK; ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
ph = &ent->ph[ent->current_position]; ph = &ent->ph[ent->current_position];
VectorCopy( ent->curstate.origin, ph->origin ); VectorCopy( ent->curstate.origin, ph->origin );
VectorCopy( ent->curstate.angles, ph->angles ); VectorCopy( ent->curstate.angles, ph->angles );
if( ent->model && ent->model->type == mod_brush )
ph->animtime = ent->curstate.animtime; ph->animtime = ent->curstate.animtime;
else
ph->animtime = cl.time; // a1ba: for some reason, this sometimes still may happen
// at this time, I'm not sure whether this bug happens in delta readwrite code
// or server just decides to go backwards and really sends these values
if( ph->animtime < prev->animtime )
{
// try to deduce real animtime by looking up the difference between
// server messages (cl.mtime is never modified ny the interpolation code)
float diff = Q_max( 0, ent->curstate.msg_time - ent->prevstate.msg_time );
ph->animtime = prev->animtime + diff;
}
} }
/* /*
@@ -74,7 +85,7 @@ CL_ResetPositions
Interpolation init or reset after teleporting Interpolation init or reset after teleporting
================== ==================
*/ */
void CL_ResetPositions( cl_entity_t *ent ) static void CL_ResetPositions( cl_entity_t *ent )
{ {
position_history_t store; position_history_t store;
@@ -84,8 +95,7 @@ void CL_ResetPositions( cl_entity_t *ent )
ent->current_position = 1; ent->current_position = 1;
memset( ent->ph, 0, sizeof( position_history_t ) * HISTORY_MAX ); memset( ent->ph, 0, sizeof( position_history_t ) * HISTORY_MAX );
memcpy( &ent->ph[1], &store, sizeof( position_history_t )); ent->ph[1] = ent->ph[0] = store;
memcpy( &ent->ph[0], &store, sizeof( position_history_t ));
} }
/* /*
@@ -96,7 +106,7 @@ check for instant movement in case
we don't want interpolate this we don't want interpolate this
================== ==================
*/ */
qboolean CL_EntityTeleported( cl_entity_t *ent ) static qboolean CL_EntityTeleported( cl_entity_t *ent )
{ {
float len, maxlen; float len, maxlen;
vec3_t delta; vec3_t delta;
@@ -117,7 +127,7 @@ CL_CompareTimestamps
round-off floating errors round-off floating errors
================== ==================
*/ */
qboolean CL_CompareTimestamps( float t1, float t2 ) static qboolean CL_CompareTimestamps( float t1, float t2 )
{ {
int iTime1 = t1 * 1000; int iTime1 = t1 * 1000;
int iTime2 = t2 * 1000; int iTime2 = t2 * 1000;
@@ -132,7 +142,7 @@ CL_EntityIgnoreLerp
some ents will be ignore lerping some ents will be ignore lerping
================== ==================
*/ */
qboolean CL_EntityIgnoreLerp( cl_entity_t *e ) static qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
{ {
if( cl_nointerp.value > 0.f ) if( cl_nointerp.value > 0.f )
return true; return true;
@@ -149,7 +159,7 @@ CL_EntityCustomLerp
================== ==================
*/ */
qboolean CL_EntityCustomLerp( cl_entity_t *e ) static qboolean CL_EntityCustomLerp( cl_entity_t *e )
{ {
switch( e->curstate.movetype ) switch( e->curstate.movetype )
{ {
@@ -159,6 +169,13 @@ qboolean CL_EntityCustomLerp( cl_entity_t *e )
case MOVETYPE_FLY: case MOVETYPE_FLY:
case MOVETYPE_COMPOUND: case MOVETYPE_COMPOUND:
return false; return false;
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
// INTERPOLATION IN GRAVGUNMOD COOP
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
case MOVETYPE_TOSS:
if( cls.legacymode == PROTO_LEGACY && e->model && e->model->type == mod_studio )
return false;
} }
return true; return true;
@@ -171,7 +188,7 @@ CL_ParametricMove
check for parametrical moved entities check for parametrical moved entities
================== ==================
*/ */
qboolean CL_ParametricMove( cl_entity_t *ent ) static qboolean CL_ParametricMove( cl_entity_t *ent )
{ {
float frac, dt, t; float frac, dt, t;
vec3_t delta; vec3_t delta;
@@ -208,7 +225,7 @@ CL_UpdateLatchedVars
==================== ====================
*/ */
void CL_UpdateLatchedVars( cl_entity_t *ent ) static void CL_UpdateLatchedVars( cl_entity_t *ent )
{ {
if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio )) if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio ))
return; // below fields used only for alias and studio interpolation return; // below fields used only for alias and studio interpolation
@@ -303,7 +320,7 @@ CL_ProcessEntityUpdate
apply changes since new frame received apply changes since new frame received
================== ==================
*/ */
void CL_ProcessEntityUpdate( cl_entity_t *ent ) static void CL_ProcessEntityUpdate( cl_entity_t *ent )
{ {
qboolean parametric; qboolean parametric;
@@ -349,11 +366,10 @@ CL_FindInterpolationUpdates
find two timestamps find two timestamps
================== ==================
*/ */
qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, position_history_t **ph0, position_history_t **ph1 ) static qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, double targettime, position_history_t **ph0, position_history_t **ph1 )
{ {
qboolean extrapolate = true; qboolean extrapolate = true;
uint i, i0, i1, imod; uint i, i0, i1, imod;
float at;
imod = ent->current_position; imod = ent->current_position;
i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end) i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end)
@@ -361,8 +377,10 @@ qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, positi
for( i = 1; i < HISTORY_MAX - 1; i++ ) for( i = 1; i < HISTORY_MAX - 1; i++ )
{ {
at = ent->ph[( imod - i ) & HISTORY_MASK].animtime; double at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
if( at == 0.0f ) break;
if( at == 0.0f )
break;
if( targettime > at ) if( targettime > at )
{ {
@@ -387,15 +405,14 @@ CL_PureOrigin
non-local players interpolation non-local players interpolation
================== ==================
*/ */
void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangles ) static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t outangles )
{ {
qboolean extrapolate; double t1, t0, frac;
float t1, t0, frac;
position_history_t *ph0, *ph1; position_history_t *ph0, *ph1;
vec3_t delta; vec3_t delta;
// NOTE: ph0 is next, ph1 is a prev // NOTE: ph0 is next, ph1 is a prev
extrapolate = CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 ); CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
if ( !ph0 || !ph1 ) if ( !ph0 || !ph1 )
return; return;
@@ -403,7 +420,7 @@ void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangle
t0 = ph0->animtime; t0 = ph0->animtime;
t1 = ph1->animtime; t1 = ph1->animtime;
if( t0 != 0.0f ) if( t0 != 0.0 )
{ {
vec4_t q, q1, q2; vec4_t q, q1, q2;
@@ -411,9 +428,9 @@ void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangle
if( !Q_equal( t0, t1 )) if( !Q_equal( t0, t1 ))
frac = ( t - t1 ) / ( t0 - t1 ); frac = ( t - t1 ) / ( t0 - t1 );
else frac = 1.0f; else frac = 1.0;
frac = bound( 0.0f, frac, 1.2f ); frac = bound( 0.0, frac, 1.2 );
VectorMA( ph1->origin, frac, delta, outorigin ); VectorMA( ph1->origin, frac, delta, outorigin );
@@ -437,11 +454,11 @@ CL_InterpolateModel
non-players interpolation non-players interpolation
================== ==================
*/ */
int CL_InterpolateModel( cl_entity_t *e ) static int CL_InterpolateModel( cl_entity_t *e )
{ {
position_history_t *ph0 = NULL, *ph1 = NULL; position_history_t *ph0 = NULL, *ph1 = NULL;
vec3_t origin, angles, delta; vec3_t origin, angles, delta;
float t, t1, t2, frac; double t, t1, t2, frac;
vec4_t q, q1, q2; vec4_t q, q1, q2;
VectorCopy( e->curstate.origin, e->origin ); VectorCopy( e->curstate.origin, e->origin );
@@ -489,9 +506,7 @@ int CL_InterpolateModel( cl_entity_t *e )
return 0; return 0;
} }
// HACKHACK: workaround buggy position history animtime if( Q_equal( t2, t1 ))
// going backward sometimes
if( Q_equal( t2, t1 ) || t2 < t1 )
{ {
VectorCopy( ph0->origin, e->origin ); VectorCopy( ph0->origin, e->origin );
VectorCopy( ph0->angles, e->angles ); VectorCopy( ph0->angles, e->angles );
@@ -529,7 +544,7 @@ interpolate non-local clients
*/ */
void CL_ComputePlayerOrigin( cl_entity_t *ent ) void CL_ComputePlayerOrigin( cl_entity_t *ent )
{ {
float targettime; double targettime;
vec4_t q, q1, q2; vec4_t q, q1, q2;
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
@@ -569,7 +584,7 @@ CL_ProcessPlayerState
process player states after the new packet has received process player states after the new packet has received
================= =================
*/ */
void CL_ProcessPlayerState( int playerindex, entity_state_t *state ) static void CL_ProcessPlayerState( int playerindex, entity_state_t *state )
{ {
entity_state_t *ps; entity_state_t *ps;
@@ -589,7 +604,7 @@ reset latched state if this frame entity was teleported
or just EF_NOINTERP was set or just EF_NOINTERP was set
================= =================
*/ */
void CL_ResetLatchedState( int pnum, frame_t *frame, cl_entity_t *ent ) static void CL_ResetLatchedState( int pnum, frame_t *frame, cl_entity_t *ent )
{ {
if( CHECKVISBIT( frame->flags, pnum )) if( CHECKVISBIT( frame->flags, pnum ))
{ {
@@ -654,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 ); *newnum = MSG_ReadWord( msg );
if( *newnum == 0 ) if( *newnum == 0 )
@@ -679,7 +694,7 @@ CL_FlushEntityPacket
Read and ignore whole entity packet. Read and ignore whole entity packet.
================= =================
*/ */
void CL_FlushEntityPacket( sizebuf_t *msg ) static void CL_FlushEntityPacket( sizebuf_t *msg, connprotocol_t proto )
{ {
int newnum; int newnum;
entity_state_t from, to; entity_state_t from, to;
@@ -692,16 +707,57 @@ void CL_FlushEntityPacket( sizebuf_t *msg )
// read it all, but ignore it // read it all, but ignore it
while( 1 ) while( 1 )
{ {
if( !CL_ParseEntityNumFromPacket( msg, &newnum )) if( !CL_ParseEntityNumFromPacket( msg, &newnum, proto ))
break; // done break; // done
if( MSG_CheckOverflow( msg )) if( MSG_CheckOverflow( msg ))
Host_Error( "CL_FlushEntityPacket: overflow\n" ); Host_Error( "%s: overflow\n", __func__ );
MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ) ? DELTA_PLAYER : DELTA_ENTITY, cl.mtime[0] ); MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ) ? DELTA_PLAYER : DELTA_ENTITY, cl.mtime[0] );
} }
} }
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 CL_DeltaEntity
@@ -709,7 +765,7 @@ CL_DeltaEntity
processing delta update processing delta update
================= =================
*/ */
void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, qboolean has_update ) static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, qboolean has_update )
{ {
cl_entity_t *ent; cl_entity_t *ent;
entity_state_t *state; entity_state_t *state;
@@ -724,7 +780,7 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t
if(( newnum < 0 ) || ( newnum >= clgame.maxEntities )) if(( newnum < 0 ) || ( newnum >= clgame.maxEntities ))
{ {
Con_DPrintf( S_ERROR "CL_DeltaEntity: invalid newnum: %d\n", newnum ); Con_DPrintf( S_ERROR "%s: invalid newnum: %d\n", __func__, newnum );
if( has_update ) if( has_update )
MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] ); MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
return; return;
@@ -736,7 +792,7 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t
if( has_update ) if( has_update )
alive = MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] ); alive = MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
else memcpy( state, old, sizeof( entity_state_t )); else *state = *old;
if( !alive ) if( !alive )
{ {
@@ -772,7 +828,7 @@ An svc_packetentities has just been parsed, deal with the
rest of the data stream. 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; frame_t *newframe, *oldframe;
int oldindex, newnum, oldnum; int oldindex, newnum, oldnum;
@@ -788,7 +844,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
CL_WriteDemoJumpTime(); CL_WriteDemoJumpTime();
// sentinel count. save it for debug checking // sentinel count. save it for debug checking
if( cls.legacymode ) if( proto == PROTO_LEGACY )
count = MSG_ReadWord( msg ); count = MSG_ReadWord( msg );
else count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1; else count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1;
@@ -802,32 +858,12 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
if( delta ) if( delta )
{ {
int subtracted; uint oldpacket = MSG_ReadByte( msg );
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;
}
oldframe = &cl.frames[oldpacket & CL_UPDATE_MASK]; 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, proto );
CL_FlushEntityPacket( msg );
return playerbytes; return playerbytes;
} }
} }
@@ -845,31 +881,15 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
oldent = NULL; oldent = NULL;
oldindex = 0; oldindex = 0;
oldnum = CL_UpdateOldEntNum( oldindex, oldframe, &oldent );
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;
}
}
while( 1 ) while( 1 )
{ {
if( !CL_ParseEntityNumFromPacket( msg, &newnum )) if( !CL_ParseEntityNumFromPacket( msg, &newnum, proto ))
break; // done break; // done
if( MSG_CheckOverflow( msg )) if( MSG_CheckOverflow( msg ))
Host_Error( "CL_ParsePacketEntities: overflow\n" ); Host_Error( "%s: overflow\n", __func__ );
player = CL_IsPlayerIndex( newnum ); player = CL_IsPlayerIndex( newnum );
@@ -877,17 +897,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
{ {
// one or more entities from the old packet are unchanged // one or more entities from the old packet are unchanged
CL_DeltaEntity( msg, newframe, oldnum, oldent, false ); CL_DeltaEntity( msg, newframe, oldnum, oldent, false );
oldindex++; oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
if( oldindex >= oldframe->num_entities )
{
oldnum = MAX_ENTNUMBER;
}
else
{
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
oldnum = oldent->number;
}
} }
if( oldnum == newnum ) if( oldnum == newnum )
@@ -896,17 +906,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
bufStart = MSG_GetNumBytesRead( msg ); bufStart = MSG_GetNumBytesRead( msg );
CL_DeltaEntity( msg, newframe, newnum, oldent, true ); CL_DeltaEntity( msg, newframe, newnum, oldent, true );
if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufStart; if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufStart;
oldindex++; oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
if( oldindex >= oldframe->num_entities )
{
oldnum = MAX_ENTNUMBER;
}
else
{
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
oldnum = oldent->number;
}
continue; continue;
} }
@@ -925,21 +925,11 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
{ {
// one or more entities from the old packet are unchanged // one or more entities from the old packet are unchanged
CL_DeltaEntity( msg, newframe, oldnum, oldent, false ); CL_DeltaEntity( msg, newframe, oldnum, oldent, false );
oldindex++; oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
if( oldindex >= oldframe->num_entities )
{
oldnum = MAX_ENTNUMBER;
}
else
{
oldent = &cls.packet_entities[(oldframe->first_entity+oldindex) % cls.num_client_entities];
oldnum = oldent->number;
}
} }
if( newframe->num_entities != count && newframe->num_entities != 0 ) if( newframe->num_entities != count && newframe->num_entities != 0 )
Con_Reportf( S_WARN "CL_Parse%sPacketEntities: (%i should be %i)\n", delta ? "Delta" : "", newframe->num_entities, count ); Con_Reportf( S_WARN "%s%s: (%i should be %i)\n", __func__, delta ? "Delta" : "", newframe->num_entities, count );
if( !newframe->valid ) if( !newframe->valid )
return playerbytes; // frame is not valid but message was parsed return playerbytes; // frame is not valid but message was parsed
@@ -957,7 +947,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
cls.signon = SIGNONS; cls.signon = SIGNONS;
// Clear loading plaque. // Clear loading plaque.
CL_SignonReply (); CL_SignonReply( proto );
} }
return playerbytes; return playerbytes;
@@ -1041,7 +1031,7 @@ CL_LinkCustomEntity
Add server beam to draw list Add server beam to draw list
============= =============
*/ */
void CL_LinkCustomEntity( cl_entity_t *ent, entity_state_t *state ) static void CL_LinkCustomEntity( cl_entity_t *ent, entity_state_t *state )
{ {
ent->curstate.movetype = state->modelindex; // !!! ent->curstate.movetype = state->modelindex; // !!!
@@ -1064,7 +1054,7 @@ Create visible entities in the correct position
for all current players for all current players
============= =============
*/ */
void CL_LinkPlayers( frame_t *frame ) static void CL_LinkPlayers( frame_t *frame )
{ {
entity_state_t *state; entity_state_t *state;
cl_entity_t *ent; cl_entity_t *ent;
@@ -1147,7 +1137,7 @@ CL_LinkPacketEntities
=============== ===============
*/ */
void CL_LinkPacketEntities( frame_t *frame ) static void CL_LinkPacketEntities( frame_t *frame )
{ {
cl_entity_t *ent; cl_entity_t *ent;
entity_state_t *state; entity_state_t *state;
@@ -1171,7 +1161,7 @@ void CL_LinkPacketEntities( frame_t *frame )
if( !ent ) if( !ent )
{ {
Con_Reportf( S_ERROR "CL_LinkPacketEntity: bad entity %i\n", state->number ); Con_Reportf( S_ERROR "%s: bad entity %i\n", __func__, state->number );
continue; continue;
} }
@@ -1212,18 +1202,34 @@ void CL_LinkPacketEntities( frame_t *frame )
#else #else
if( ent->lastmove >= cl.time ) if( ent->lastmove >= cl.time )
{ {
float at = ent->curstate.animtime;
CL_ResetLatchedVars( ent, true ); CL_ResetLatchedVars( ent, true );
if( cl_fixmodelinterpolationartifacts.value )
ent->latched.prevanimtime = ent->curstate.animtime = at;
VectorCopy( ent->curstate.origin, ent->latched.prevorigin ); VectorCopy( ent->curstate.origin, ent->latched.prevorigin );
VectorCopy( ent->curstate.angles, ent->latched.prevangles ); VectorCopy( ent->curstate.angles, ent->latched.prevangles );
if( !FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
{
// disable step interpolation in client.dll // disable step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_NONE; ent->curstate.movetype = MOVETYPE_NONE;
} }
}
else
{
if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
{
interpolate = true;
}
else else
{ {
// restore step interpolation in client.dll // restore step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_STEP; ent->curstate.movetype = MOVETYPE_STEP;
} }
}
#endif #endif
} }
} }
@@ -1247,11 +1253,24 @@ void CL_LinkPacketEntities( frame_t *frame )
if ( !CL_InterpolateModel( ent )) if ( !CL_InterpolateModel( ent ))
continue; continue;
} }
else if( ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address )) // a1ba: in GoldSrc this is done for cstrike and czero
// but let modders use this as an engine feature
else if( FBitSet( host.features, ENGINE_STEP_POSHISTORY_LERP ) &&
ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address ))
{ {
if( !CL_InterpolateModel( ent )) if( !CL_InterpolateModel( ent ))
continue; continue;
} }
#if 0
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
// INTERPOLATION IN GRAVGUNMOD COOP
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
else if( cls.legacymode == PROTO_LEGACY && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
{
if( !CL_InterpolateModel( ent ))
continue;
}
#endif
else else
{ {
// no interpolation right now // no interpolation right now
@@ -1447,9 +1466,3 @@ qboolean CL_GetMovieSpatialization( rawchan_t *ch )
return true; return true;
} }
void CL_ExtraUpdate( void )
{
clgame.dllFuncs.IN_Accumulate();
S_ExtraUpdate();
}

View File

@@ -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 MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
#define TEXT_MSGNAME "TextMessage%i" #define TEXT_MSGNAME "TextMessage%i"
char cl_textbuffer[MAX_TEXTCHANNELS][2048]; static char cl_textbuffer[MAX_TEXTCHANNELS][2048];
client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS]; static client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS];
static dllfunc_t cdll_exports[] = static const dllfunc_t cdll_exports[] =
{ {
{ "Initialize", (void **)&clgame.dllFuncs.pfnInitialize }, { "Initialize", (void **)&clgame.dllFuncs.pfnInitialize },
{ "HUD_VidInit", (void **)&clgame.dllFuncs.pfnVidInit }, { "HUD_VidInit", (void **)&clgame.dllFuncs.pfnVidInit },
@@ -80,7 +80,7 @@ static dllfunc_t cdll_exports[] =
}; };
// optional 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_GetStudioModelInterface", (void **)&clgame.dllFuncs.pfnGetStudioModelInterface },
{ "HUD_DirectorMessage", (void **)&clgame.dllFuncs.pfnDirectorMessage }, { "HUD_DirectorMessage", (void **)&clgame.dllFuncs.pfnDirectorMessage },
@@ -140,11 +140,7 @@ returns true if thirdperson is enabled
*/ */
qboolean CL_IsThirdPerson( void ) qboolean CL_IsThirdPerson( void )
{ {
cl.local.thirdperson = clgame.dllFuncs.CL_IsThirdPerson(); return clgame.dllFuncs.CL_IsThirdPerson() ? true : false;
if( cl.local.thirdperson )
return true;
return false;
} }
/* /*
@@ -231,7 +227,7 @@ static void CL_InitCDAudio( const char *filename )
if( ++c > MAX_CDTRACKS - 1 ) if( ++c > MAX_CDTRACKS - 1 )
{ {
Con_Reportf( S_WARN "CD_Init: too many tracks %i in %s\n", MAX_CDTRACKS, filename ); Con_Reportf( S_WARN "%s: too many tracks %i in %s\n", __func__, MAX_CDTRACKS, filename );
break; break;
} }
} }
@@ -252,18 +248,18 @@ static int CL_AdjustXPos( float x, int width, int totalWidth )
if( x == -1 ) if( x == -1 )
{ {
xPos = ( refState.width - width ) * 0.5f; xPos = ( clgame.scrInfo.iWidth - width ) * 0.5f;
} }
else else
{ {
if ( x < 0 ) 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 else // align left
xPos = x * refState.width; xPos = x * clgame.scrInfo.iWidth;
} }
if( xPos + width > refState.width ) if( xPos + width > clgame.scrInfo.iWidth )
xPos = refState.width - width; xPos = clgame.scrInfo.iWidth - width;
else if( xPos < 0 ) else if( xPos < 0 )
xPos = 0; xPos = 0;
@@ -283,19 +279,19 @@ static int CL_AdjustYPos( float y, int height )
if( y == -1 ) // centered? if( y == -1 ) // centered?
{ {
yPos = ( refState.height - height ) * 0.5f; yPos = ( clgame.scrInfo.iHeight - height ) * 0.5f;
} }
else else
{ {
// Alight bottom? // Alight bottom?
if( y < 0 ) 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 else // align top
yPos = y * refState.height; yPos = y * clgame.scrInfo.iHeight;
} }
if( yPos + height > refState.height ) if( yPos + height > clgame.scrInfo.iHeight )
yPos = refState.height - height; yPos = clgame.scrInfo.iHeight - height;
else if( yPos < 0 ) else if( yPos < 0 )
yPos = 0; yPos = 0;
@@ -357,7 +353,9 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h )
*h *= yscale; *h *= yscale;
} }
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 ) static void SPR_AdjustTexCoords( int texnum, float width, float height, float *s1, float *t1, float *s2, float *t2 )
{
if( REF_GET_PARM( PARM_TEX_FILTERING, texnum ))
{ {
if( refState.width != clgame.scrInfo.iWidth ) if( refState.width != clgame.scrInfo.iWidth )
{ {
@@ -372,6 +370,7 @@ void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float
*t1 += 0.5f; *t1 += 0.5f;
*t2 -= 0.5f; *t2 -= 0.5f;
} }
}
*s1 /= width; *s1 /= width;
*t1 /= height; *t1 /= height;
@@ -402,6 +401,8 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
height = h; height = h;
} }
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
if( prc ) if( prc )
{ {
wrect_t rc = *prc; wrect_t rc = *prc;
@@ -418,7 +419,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
t2 = rc.bottom; t2 = rc.bottom;
// calc user-defined rectangle // calc user-defined rectangle
SPR_AdjustTexCoords( width, height, &s1, &t1, &s2, &t2 ); SPR_AdjustTexCoords( texnum, width, height, &s1, &t1, &s2, &t2 );
width = rc.right - rc.left; width = rc.right - rc.left;
height = rc.bottom - rc.top; height = rc.bottom - rc.top;
} }
@@ -434,7 +435,6 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
// scale for screen sizes // scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height ); SPR_AdjustSize( &x, &y, &width, &height );
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
ref.dllFuncs.Color4ub( clgame.ds.spriteColor[0], clgame.ds.spriteColor[1], clgame.ds.spriteColor[2], clgame.ds.spriteColor[3] ); ref.dllFuncs.Color4ub( clgame.ds.spriteColor[0], clgame.ds.spriteColor[1], clgame.ds.spriteColor[2], clgame.ds.spriteColor[3] );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum ); ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum );
} }
@@ -470,8 +470,7 @@ void CL_DrawCenterPrint( void )
pText = clgame.centerPrint.message; pText = clgame.centerPrint.message;
CL_DrawCharacterLen( font, 0, NULL, &charHeight ); CL_DrawCharacterLen( font, 0, NULL, &charHeight );
CL_SetFontRendermode( font );
ref.dllFuncs.GL_SetRenderMode( font->rendermode );
for( i = 0; i < clgame.centerPrint.lines; i++ ) for( i = 0; i < clgame.centerPrint.lines; i++ )
{ {
lineLength = 0; lineLength = 0;
@@ -547,7 +546,7 @@ fill screen with specfied color
can be modulated can be modulated
============= =============
*/ */
void CL_DrawScreenFade( void ) static void CL_DrawScreenFade( void )
{ {
screenfade_t *sf = &clgame.fade; screenfade_t *sf = &clgame.fade;
int alpha; int alpha;
@@ -557,7 +556,19 @@ void CL_DrawScreenFade( void )
if( !alpha ) if( !alpha )
return; return;
if( FBitSet( sf->fadeFlags, FFADE_MODULATE )) if( !FBitSet( sf->fadeFlags, FFADE_MODULATE ))
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, alpha );
}
else if( Host_IsQuakeCompatible( ))
{
// Quake Wrapper and Quake Remake use FFADE_MODULATE for item pickups
// so hack the check here
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, alpha );
}
else
{ {
ref.dllFuncs.GL_SetRenderMode( kRenderScreenFadeModulate ); ref.dllFuncs.GL_SetRenderMode( kRenderScreenFadeModulate );
@@ -567,11 +578,6 @@ void CL_DrawScreenFade( void )
(uint16_t)( sf->fadeb * alpha + ( 255 - alpha ) * 255 ) >> 8, (uint16_t)( sf->fadeb * alpha + ( 255 - alpha ) * 255 ) >> 8,
255 ); 255 );
} }
else
{
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, alpha );
}
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1,
R_GetBuiltinTexture( REF_WHITE_TEXTURE )); R_GetBuiltinTexture( REF_WHITE_TEXTURE ));
@@ -763,7 +769,7 @@ CL_SoundFromIndex
return soundname from index return soundname from index
==================== ====================
*/ */
const char *CL_SoundFromIndex( int index ) static const char *CL_SoundFromIndex( int index )
{ {
sfx_t *sfx = NULL; sfx_t *sfx = NULL;
int hSound; int hSound;
@@ -774,14 +780,14 @@ const char *CL_SoundFromIndex( int index )
if( !hSound ) if( !hSound )
{ {
Con_DPrintf( S_ERROR "CL_SoundFromIndex: invalid sound index %i\n", index ); Con_DPrintf( S_ERROR "%s: invalid sound index %i\n", __func__, index );
return NULL; return NULL;
} }
sfx = S_GetSfxByHandle( hSound ); sfx = S_GetSfxByHandle( hSound );
if( !sfx ) if( !sfx )
{ {
Con_DPrintf( S_ERROR "CL_SoundFromIndex: bad sfx for index %i\n", index ); Con_DPrintf( S_ERROR "%s: bad sfx for index %i\n", __func__, index );
return NULL; return NULL;
} }
@@ -909,7 +915,7 @@ CL_DrawCrosshair
Render crosshair Render crosshair
==================== ====================
*/ */
void CL_DrawCrosshair( void ) static void CL_DrawCrosshair( void )
{ {
int x, y, width, height; int x, y, width, height;
float xscale, yscale; float xscale, yscale;
@@ -1009,6 +1015,7 @@ void CL_DrawHUD( int state )
CL_DrawCrosshair (); CL_DrawCrosshair ();
CL_DrawCenterPrint (); CL_DrawCenterPrint ();
clgame.dllFuncs.pfnRedraw( cl.time, cl.intermission ); clgame.dllFuncs.pfnRedraw( cl.time, cl.intermission );
if( showpause.value )
CL_DrawLoadingOrPaused( cls.pauseIcon ); CL_DrawLoadingOrPaused( cls.pauseIcon );
break; break;
case CL_LOADING: case CL_LOADING:
@@ -1038,10 +1045,10 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
int i; int i;
if( !pszName || !*pszName ) if( !pszName || !*pszName )
Host_Error( "CL_LinkUserMessage: bad message name\n" ); Host_Error( "%s: bad message name\n", __func__ );
if( svc_num <= svc_lastmsg ) if( svc_num <= svc_lastmsg )
Host_Error( "CL_LinkUserMessage: tried to hook a system message \"%s\"\n", svc_strings[svc_num] ); Host_Error( "%s: tried to hook a system message \"%s\"\n", __func__, svc_strings[svc_num] );
// see if already hooked // see if already hooked
for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ ) for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
@@ -1058,7 +1065,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
if( i == MAX_USER_MESSAGES ) if( i == MAX_USER_MESSAGES )
{ {
Host_Error( "CL_LinkUserMessage: MAX_USER_MESSAGES hit!\n" ); Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
return; return;
} }
@@ -1109,12 +1116,12 @@ void CL_InitEdicts( int maxclients )
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos ); clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
} }
ref.dllFuncs.R_ProcessEntData( true ); ref.dllFuncs.R_ProcessEntData( true, clgame.entities, clgame.maxEntities );
} }
void CL_FreeEdicts( void ) void CL_FreeEdicts( void )
{ {
ref.dllFuncs.R_ProcessEntData( false ); ref.dllFuncs.R_ProcessEntData( false, NULL, 0 );
if( clgame.entities ) if( clgame.entities )
Mem_Free( clgame.entities ); Mem_Free( clgame.entities );
@@ -1179,7 +1186,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
if( type == SPR_CLIENT || type == SPR_HUDSPRITE ) if( type == SPR_CLIENT || type == SPR_HUDSPRITE )
SetBits( m_pSprite->flags, MODEL_CLIENT ); SetBits( m_pSprite->flags, MODEL_CLIENT );
m_pSprite->numtexinfo = texFlags; // store texFlags into numtexinfo m_pSprite->numtexinfo = texFlags; // store texFlags for renderer into numtexinfo
if( !FS_FileExists( szSpriteName, false ) ) if( !FS_FileExists( szSpriteName, false ) )
{ {
@@ -1206,7 +1213,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
ref.dllFuncs.Mod_LoadMapSprite( m_pSprite, buf, size, &loaded ); ref.dllFuncs.Mod_LoadMapSprite( m_pSprite, buf, size, &loaded );
else else
{ {
Mod_LoadSpriteModel( m_pSprite, buf, &loaded, texFlags ); Mod_LoadSpriteModel( m_pSprite, buf, &loaded );
ref.dllFuncs.Mod_ProcessRenderData( m_pSprite, true, buf ); ref.dllFuncs.Mod_ProcessRenderData( m_pSprite, true, buf );
} }
@@ -1235,22 +1242,18 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
{ {
char name[MAX_QPATH]; char name[MAX_QPATH];
model_t *mod; model_t *mod;
int i; int i, start;
// use high indices for client sprites
// for GoldSrc bug-compatibility
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
if( !COM_CheckString( filename )) if( !COM_CheckString( filename ))
{ {
Con_Reportf( S_ERROR "CL_LoadSpriteModel: bad name!\n" ); Con_Reportf( S_ERROR "%s: bad name!\n", __func__ );
return NULL; return NULL;
} }
Q_strncpy( name, filename, sizeof( name )); Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name ); COM_FixSlashes( name );
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) for( i = 0, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{ {
if( !Q_stricmp( mod->name, name )) if( !Q_stricmp( mod->name, name ))
{ {
@@ -1267,8 +1270,15 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
} }
// find a free model slot spot // find a free model slot spot
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) // use low indices only for HUD sprites
if( !mod->name[0] ) break; // this is a valid spot // for GoldSrc bug compatibility
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
{
if( !mod->name[0] )
break; // this is a valid spot
}
if( i == MAX_CLIENT_SPRITES / 2 ) if( i == MAX_CLIENT_SPRITES / 2 )
{ {
@@ -1320,9 +1330,11 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
========= =========
pfnSPR_Load pfnSPR_Load
function exported for support GoldSrc Monitor utility
========= =========
*/ */
static HSPRITE GAME_EXPORT pfnSPR_Load( const char *szPicName ) HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
{ {
model_t *spr; model_t *spr;
@@ -1368,9 +1380,11 @@ static const model_t *CL_GetSpritePointer( HSPRITE hSprite )
========= =========
pfnSPR_Frames pfnSPR_Frames
function exported for support GoldSrc Monitor utility
========= =========
*/ */
static int GAME_EXPORT pfnSPR_Frames( HSPRITE hPic ) int EXPORT pfnSPR_Frames( HSPRITE hPic );
int EXPORT pfnSPR_Frames( HSPRITE hPic )
{ {
int numFrames = 0; int numFrames = 0;
@@ -1438,7 +1452,7 @@ pfnSPR_Draw
*/ */
static void GAME_EXPORT pfnSPR_Draw( int frame, int x, int y, const wrect_t *prc ) static void GAME_EXPORT pfnSPR_Draw( int frame, int x, int y, const wrect_t *prc )
{ {
ref.dllFuncs.GL_SetRenderMode( kRenderNormal ); ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
SPR_DrawGeneric( frame, x, y, -1, -1, prc ); SPR_DrawGeneric( frame, x, y, -1, -1, prc );
} }
@@ -1493,12 +1507,12 @@ static void GAME_EXPORT pfnSPR_DrawAdditive( int frame, int x, int y, const wrec
/* /*
========= =========
pfnSPR_GetList SPR_GetList
for parsing half-life scripts - hud.txt etc for parsing half-life scripts - hud.txt etc
========= =========
*/ */
static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount ) static client_sprite_t *SPR_GetList( char *psz, int *piCount )
{ {
cached_spritelist_t *pEntry = &clgame.sprlist[0]; cached_spritelist_t *pEntry = &clgame.sprlist[0];
int slot, index, numSprites = 0; int slot, index, numSprites = 0;
@@ -1524,7 +1538,7 @@ static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )
if( slot == MAX_CLIENT_SPRITES ) if( slot == MAX_CLIENT_SPRITES )
{ {
Con_Printf( S_ERROR "SPR_GetList: overflow cache!\n" ); Con_Printf( S_ERROR "%s: overflow cache!\n", __func__ );
return NULL; return NULL;
} }
@@ -1588,7 +1602,7 @@ CL_FillRGBA
============= =============
*/ */
void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a ) static void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
{ {
float _x = x, _y = y, _w = w, _h = h; float _x = x, _y = y, _w = w, _h = h;
@@ -1630,6 +1644,7 @@ get actual screen info
*/ */
int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo ) int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
{ {
qboolean apply_scale_factor = false;
float scale_factor = hud_scale.value; float scale_factor = hud_scale.value;
if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED )) if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED ))
@@ -1645,16 +1660,23 @@ int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH; clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH;
if( scale_factor && scale_factor != 1.0f ) if( scale_factor && scale_factor != 1.0f )
{
float scaled_width = (float)refState.width / scale_factor;
if( scaled_width >= hud_scale_minimal_width.value )
apply_scale_factor = true;
}
if( apply_scale_factor )
{ {
clgame.scrInfo.iWidth = (float)refState.width / scale_factor; clgame.scrInfo.iWidth = (float)refState.width / scale_factor;
clgame.scrInfo.iHeight = (float)refState.height / scale_factor; clgame.scrInfo.iHeight = (float)refState.height / scale_factor;
clgame.scrInfo.iFlags |= SCRINFO_STRETCHED; SetBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
} }
else else
{ {
clgame.scrInfo.iWidth = refState.width; clgame.scrInfo.iWidth = refState.width;
clgame.scrInfo.iHeight = refState.height; clgame.scrInfo.iHeight = refState.height;
clgame.scrInfo.iFlags &= ~SCRINFO_STRETCHED; ClearBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
} }
if( !pscrinfo ) return 0; if( !pscrinfo ) return 0;
@@ -1695,7 +1717,8 @@ pfnCvar_RegisterVariable
static cvar_t *GAME_EXPORT pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags ) static cvar_t *GAME_EXPORT pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
{ {
// a1ba: try to mitigate outdated client.dll vulnerabilities // a1ba: try to mitigate outdated client.dll vulnerabilities
if( !Q_stricmp( szName, "motdfile" )) if( !Q_stricmp( szName, "motdfile" )
|| !Q_stricmp( szName, "sensitivity" ))
flags |= FCVAR_PRIVILEGED; flags |= FCVAR_PRIVILEGED;
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL )); return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
@@ -1724,7 +1747,7 @@ static int GAME_EXPORT pfnHookUserMsg( const char *pszName, pfnUserMsgHook pfn )
if( i == MAX_USER_MESSAGES ) if( i == MAX_USER_MESSAGES )
{ {
Host_Error( "HookUserMsg: MAX_USER_MESSAGES hit!\n" ); Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
return 0; return 0;
} }
@@ -2116,7 +2139,7 @@ pfnGetViewModel
============= =============
*/ */
cl_entity_t* GAME_EXPORT CL_GetViewModel( void ) static cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
{ {
return &clgame.viewent; return &clgame.viewent;
} }
@@ -2274,7 +2297,7 @@ static void GAME_EXPORT pfnHookEvent( const char *filename, pfnEventHook pfn )
if( !Q_stricmp( name, ev->name ) && ev->func != NULL ) if( !Q_stricmp( name, ev->name ) && ev->func != NULL )
{ {
Con_Reportf( S_WARN "CL_HookEvent: %s already hooked!\n", name ); Con_Reportf( S_WARN "%s: %s already hooked!\n", __func__, name );
return; return;
} }
} }
@@ -2357,7 +2380,7 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
if( lasttimewarn < host.realtime ) if( lasttimewarn < host.realtime )
{ {
// tell user about problem (but don't spam console) // tell user about problem (but don't spam console)
Con_Printf( S_ERROR "Could not find index for model %s: not precached\n", filepath ); Con_DPrintf( S_ERROR "Could not find index for model %s: not precached\n", filepath );
lasttimewarn = host.realtime + 1.0f; lasttimewarn = host.realtime + 1.0f;
} }
@@ -2409,8 +2432,8 @@ static void GAME_EXPORT pfnLocalPlayerBounds( int hull, float *mins, float *maxs
{ {
if( hull >= 0 && hull < 4 ) if( hull >= 0 && hull < 4 )
{ {
if( mins ) VectorCopy( clgame.pmove->player_mins[hull], mins ); if( mins ) VectorCopy( host.player_mins[hull], mins );
if( maxs ) VectorCopy( clgame.pmove->player_maxs[hull], maxs ); if( maxs ) VectorCopy( host.player_maxs[hull], maxs );
} }
} }
@@ -2465,6 +2488,51 @@ static physent_t *pfnGetVisent( int idx )
return NULL; return NULL;
} }
static int GAME_EXPORT CL_TestLine( const vec3_t start, const vec3_t end, int flags )
{
return PM_TestLineExt( clgame.pmove, clgame.pmove->physents, clgame.pmove->numphysent, start, end, flags );
}
/*
=============
CL_PushTraceBounds
=============
*/
static void GAME_EXPORT CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs )
{
if( !host.trace_bounds_pushed )
{
memcpy( host.player_mins_backup, host.player_mins, sizeof( host.player_mins_backup ));
memcpy( host.player_maxs_backup, host.player_maxs, sizeof( host.player_maxs_backup ));
host.trace_bounds_pushed = true;
}
hullnum = bound( 0, hullnum, 3 );
VectorCopy( mins, host.player_mins[hullnum] );
VectorCopy( maxs, host.player_maxs[hullnum] );
}
/*
=============
CL_PopTraceBounds
=============
*/
static void GAME_EXPORT CL_PopTraceBounds( void )
{
if( !host.trace_bounds_pushed )
{
Con_Reportf( S_ERROR "%s called without push!\n", __func__ );
return;
}
host.trace_bounds_pushed = false;
memcpy( host.player_mins, host.player_mins_backup, sizeof( host.player_mins ));
memcpy( host.player_maxs, host.player_maxs_backup, sizeof( host.player_maxs ));
}
/* /*
============= =============
pfnSetTraceHull pfnSetTraceHull
@@ -2660,6 +2728,48 @@ static model_t *pfnLoadMapSprite( const char *filename )
return NULL; return NULL;
} }
/*
=============
COM_AddAppDirectoryToSearchPath
=============
*/
static void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
{
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
}
/*
===========
COM_ExpandFilename
Finds the file in the search path, copies over the name with the full path name.
This doesn't search in the pak file.
===========
*/
static int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
{
char result[MAX_SYSPATH];
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
{
// check for enough room
if( Q_strlen( result ) > nameOutBufferSize )
return 0;
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
return 1;
}
return 0;
}
/* /*
============= =============
PlayerInfo_ValueForKey PlayerInfo_ValueForKey
@@ -2697,10 +2807,10 @@ static void GAME_EXPORT PlayerInfo_SetValueForKey( const char *key, const char *
{ {
Cvar_DirectSet( var, value ); Cvar_DirectSet( var, value );
} }
else if( Info_SetValueForStarKey( cls.userinfo, key, value, MAX_INFO_STRING )) else if( Info_SetValueForStarKey( cls.userinfo, key, value, sizeof( cls.userinfo )))
{ {
// time to update server copy of userinfo // time to update server copy of userinfo
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", key, value ); CL_UpdateInfo( key, value );
} }
} }
@@ -3192,7 +3302,7 @@ Heavy legacy of Quake...
*/ */
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode ) void TriColor4fRendermode( float r, float g, float b, float a, int rendermode )
{ {
if( clgame.ds.renderMode == kRenderTransAlpha ) if( rendermode == kRenderTransAlpha )
{ {
clgame.ds.triRGBA[3] = a / 255.0f; clgame.ds.triRGBA[3] = a / 255.0f;
ref.dllFuncs.Color4f( r, g, b, a ); ref.dllFuncs.Color4f( r, g, b, a );
@@ -3324,16 +3434,15 @@ NetAPI_SendRequest
static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, double timeout, netadr_t *remote_address, net_api_response_func_t response ) static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, double timeout, netadr_t *remote_address, net_api_response_func_t response )
{ {
net_request_t *nr = NULL; net_request_t *nr = NULL;
string req;
int i; int i;
if( !response ) if( !response )
{ {
Con_DPrintf( S_ERROR "Net_SendRequest: no callbcak specified for request with context %i!\n", context ); Con_DPrintf( S_ERROR "%s: no callbcak specified for request with context %i!\n", __func__, context );
return; return;
} }
if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX ) if( remote_address->type == NA_IPX || remote_address->type == NA_BROADCAST_IPX )
return; // IPX no longer support return; // IPX no longer support
if( request == NETAPI_REQUEST_SERVERLIST ) if( request == NETAPI_REQUEST_SERVERLIST )
@@ -3376,8 +3485,7 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,
nr->flags = flags; nr->flags = flags;
// local servers request // local servers request
Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, 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, "%s", req );
} }
/* /*
@@ -3681,7 +3789,7 @@ static demo_api_t gDemoApi =
Demo_WriteBuffer, Demo_WriteBuffer,
}; };
static net_api_t gNetApi = net_api_t gNetApi =
{ {
NetAPI_InitNetworking, NetAPI_InitNetworking,
NetAPI_Status, NetAPI_Status,
@@ -3717,7 +3825,7 @@ static cl_enginefunc_t gEngfuncs =
pfnSPR_DrawAdditive, pfnSPR_DrawAdditive,
SPR_EnableScissor, SPR_EnableScissor,
SPR_DisableScissor, SPR_DisableScissor,
pfnSPR_GetList, SPR_GetList,
CL_FillRGBA, CL_FillRGBA,
CL_GetScreenInfo, CL_GetScreenInfo,
pfnSetCrosshair, pfnSetCrosshair,
@@ -3939,14 +4047,14 @@ qboolean CL_LoadProgs( const char *name )
// trying to get single export // trying to get single export
if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL ) if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL )
{ {
Con_Reportf( "CL_LoadProgs: found single callback export\n" ); Con_Reportf( "%s: found single callback export\n", __func__ );
// trying to fill interface now // trying to fill interface now
GetClientAPI( &clgame.dllFuncs ); GetClientAPI( &clgame.dllFuncs );
} }
else if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "F" )) != NULL ) else if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "F" )) != NULL )
{ {
Con_Reportf( "CL_LoadProgs: found single callback export (secured client dlls)\n" ); Con_Reportf( "%s: found single callback export (secured client dlls)\n", __func__ );
// trying to fill interface now // trying to fill interface now
CL_GetSecuredClientAPI( GetClientAPI ); CL_GetSecuredClientAPI( GetClientAPI );
@@ -3974,7 +4082,7 @@ qboolean CL_LoadProgs( const char *name )
// functions are cleared before all the extensions are evaluated // functions are cleared before all the extensions are evaluated
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL ) if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
{ {
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name ); Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
if( critical_exports ) if( critical_exports )
{ {
@@ -4001,13 +4109,13 @@ qboolean CL_LoadProgs( const char *name )
// functions are cleared before all the extensions are evaluated // functions are cleared before all the extensions are evaluated
// NOTE: new exports can be missed without stop the engine // NOTE: new exports can be missed without stop the engine
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL ) if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name ); Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
} }
if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION )) if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
{ {
COM_FreeLibrary( clgame.hInstance ); COM_FreeLibrary( clgame.hInstance );
Con_Reportf( "CL_LoadProgs: can't init client API\n" ); Con_Reportf( "%s: can't init client API\n", __func__ );
clgame.hInstance = NULL; clgame.hInstance = NULL;
return false; return false;
} }
@@ -4024,10 +4132,10 @@ qboolean CL_LoadProgs( const char *name )
CL_InitTempEnts (); CL_InitTempEnts ();
if( !R_InitRenderAPI()) // Xash3D extension if( !R_InitRenderAPI()) // Xash3D extension
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get render API\n" ); Con_Reportf( S_WARN "%s: couldn't get render API\n", __func__ );
if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" ); Con_Reportf( S_WARN "%s: couldn't get mobility API\n", __func__ );
CL_InitEdicts( cl.maxclients ); // initailize local player and world CL_InitEdicts( cl.maxclients ); // initailize local player and world
CL_InitClientMove(); // initialize pm_shared CL_InitClientMove(); // initialize pm_shared

View File

@@ -25,6 +25,14 @@ static void UI_UpdateUserinfo( void );
gameui_static_t gameui; gameui_static_t gameui;
static void UI_ToggleAllowConsole_f( void )
{
host.allow_console = host.allow_console_init = true;
if( gameui.globals )
gameui.globals->developer = true;
}
void UI_UpdateMenu( float realtime ) void UI_UpdateMenu( float realtime )
{ {
if( !gameui.hInstance ) return; if( !gameui.hInstance ) return;
@@ -216,12 +224,14 @@ UI_ShowConnectionWarning
show message box show message box
================= =================
*/ */
void UI_ShowMessageBox( const char *text ) qboolean UI_ShowMessageBox( const char *text )
{ {
if( gameui.dllFuncs2.pfnShowMessageBox ) if( gameui.dllFuncs2.pfnShowMessageBox )
{ {
gameui.dllFuncs2.pfnShowMessageBox( text ); gameui.dllFuncs2.pfnShowMessageBox( text );
return true;
} }
return false;
} }
void UI_ConnectionProgress_Disconnect( void ) void UI_ConnectionProgress_Disconnect( void )
@@ -397,28 +407,61 @@ void Host_Credits( void )
gameui.dllFuncs.pfnFinalCredits(); gameui.dllFuncs.pfnFinalCredits();
} }
static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in ) static void UI_ConvertGameInfo( gameinfo2_t *out, const gameinfo_t *in )
{ {
out->gi_version = GAMEINFO_VERSION;
Q_strncpy( out->gamefolder, in->gamefolder, sizeof( out->gamefolder )); Q_strncpy( out->gamefolder, in->gamefolder, sizeof( out->gamefolder ));
Q_strncpy( out->startmap, in->startmap, sizeof( out->startmap )); Q_strncpy( out->startmap, in->startmap, sizeof( out->startmap ));
Q_strncpy( out->trainmap, in->trainmap, sizeof( out->trainmap )); Q_strncpy( out->trainmap, in->trainmap, sizeof( out->trainmap ));
Q_strncpy( out->demomap, in->demomap, sizeof( out->demomap ));
Q_strncpy( out->title, in->title, sizeof( out->title )); Q_strncpy( out->title, in->title, sizeof( out->title ));
Q_snprintf( out->version, sizeof( out->version ), "%g", in->version ); Q_snprintf( out->version, sizeof( out->version ), "%g", in->version );
Q_strncpy( out->iconpath, in->iconpath, sizeof( out->iconpath ));
Q_strncpy( out->game_url, in->game_url, sizeof( out->game_url )); Q_strncpy( out->game_url, in->game_url, sizeof( out->game_url ));
Q_strncpy( out->update_url, in->update_url, sizeof( out->update_url )); Q_strncpy( out->update_url, in->update_url, sizeof( out->update_url ));
Q_strncpy( out->size, Q_pretifymem( in->size, 0 ), sizeof( out->size )); out->size = in->size;
Q_strncpy( out->type, in->type, sizeof( out->type )); Q_strncpy( out->type, in->type, sizeof( out->type ));
Q_strncpy( out->date, in->date, sizeof( out->date )); Q_strncpy( out->date, in->date, sizeof( out->date ));
out->gamemode = in->gamemode; out->gamemode = in->gamemode;
if( in->nomodels ) if( in->nomodels )
out->flags |= GFL_NOMODELS; SetBits( out->flags, GFL_NOMODELS );
if( in->noskills ) if( in->noskills )
out->flags |= GFL_NOSKILLS; SetBits( out->flags, GFL_NOSKILLS );
if( in->render_picbutton_text ) if( in->render_picbutton_text )
out->flags |= GFL_RENDER_PICBUTTON_TEXT; SetBits( out->flags, GFL_RENDER_PICBUTTON_TEXT );
if( in->hd_background )
SetBits( out->flags, GFL_HD_BACKGROUND );
if( in->animated_title )
SetBits( out->flags, GFL_ANIMATED_TITLE );
}
static void UI_ToOldGameInfo( GAMEINFO *out, const gameinfo2_t *in )
{
Q_strncpy( out->gamefolder, in->gamefolder, sizeof( out->gamefolder ));
Q_strncpy( out->startmap, in->startmap, sizeof( out->startmap ));
Q_strncpy( out->trainmap, in->trainmap, sizeof( out->trainmap ));
Q_strncpy( out->title, in->title, sizeof( out->title ));
Q_strncpy( out->version, in->version, sizeof( out->version ));
out->flags = in->flags & 0xFFFF;
Q_strncpy( out->game_url, in->game_url, sizeof( out->game_url ));
Q_strncpy( out->update_url, in->update_url, sizeof( out->update_url ));
Q_strncpy( out->size, Q_memprint( in->size ), sizeof( out->size ));
Q_strncpy( out->type, in->type, sizeof( out->type ));
Q_strncpy( out->date, in->date, sizeof( out->date ));
out->gamemode = in->gamemode;
}
static void UI_GetModsInfo( void )
{
int i;
gameui.modsInfo = Mem_Calloc( gameui.mempool, sizeof( *gameui.modsInfo ) * FI->numgames );
for( i = 0; i < FI->numgames; i++ )
UI_ConvertGameInfo( &gameui.modsInfo[i], FI->games[i] );
} }
/* /*
@@ -488,7 +531,7 @@ static HIMAGE GAME_EXPORT pfnPIC_Load( const char *szPicName, const byte *image_
if( !COM_CheckString( szPicName )) if( !COM_CheckString( szPicName ))
{ {
Con_Reportf( S_ERROR "CL_LoadImage: refusing to load image with empty name\n" ); Con_Reportf( S_ERROR "%s: refusing to load image with empty name\n", __func__ );
return 0; return 0;
} }
@@ -538,7 +581,7 @@ pfnPIC_Set
========= =========
*/ */
void GAME_EXPORT pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a ) static void GAME_EXPORT pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
{ {
gameui.ds.gl_texturenum = hPic; gameui.ds.gl_texturenum = hPic;
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
@@ -554,7 +597,7 @@ pfnPIC_Draw
========= =========
*/ */
void GAME_EXPORT pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc ) static void GAME_EXPORT pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
{ {
ref.dllFuncs.GL_SetRenderMode( kRenderNormal ); ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -566,7 +609,7 @@ pfnPIC_DrawTrans
========= =========
*/ */
void GAME_EXPORT pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc ) static void GAME_EXPORT pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
{ {
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture ); ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -578,7 +621,7 @@ pfnPIC_DrawHoles
========= =========
*/ */
void GAME_EXPORT pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc ) static void GAME_EXPORT pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
{ {
ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha ); ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -590,7 +633,7 @@ pfnPIC_DrawAdditive
========= =========
*/ */
void GAME_EXPORT pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc ) static void GAME_EXPORT pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
{ {
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd ); ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
PIC_DrawGeneric( x, y, width, height, prc ); PIC_DrawGeneric( x, y, width, height, prc );
@@ -918,11 +961,12 @@ pfnGetGameInfo
========= =========
*/ */
static int GAME_EXPORT pfnGetGameInfo( GAMEINFO *pgameinfo ) static int GAME_EXPORT pfnGetOldGameInfo( GAMEINFO *pgameinfo )
{ {
if( !pgameinfo ) return 0; if( !pgameinfo )
return 0;
*pgameinfo = gameui.gameInfo; UI_ToOldGameInfo( pgameinfo, &gameui.gameInfo );
return 1; return 1;
} }
@@ -934,8 +978,26 @@ pfnGetGamesList
*/ */
static GAMEINFO ** GAME_EXPORT pfnGetGamesList( int *numGames ) static GAMEINFO ** GAME_EXPORT pfnGetGamesList( int *numGames )
{ {
if( numGames ) *numGames = FI->numgames; if( numGames )
return gameui.modsInfo; *numGames = FI->numgames;
if( !gameui.oldModsInfo )
{
int i;
if( !gameui.modsInfo )
UI_GetModsInfo();
// first allocate array of pointers
gameui.oldModsInfo = Mem_Calloc( gameui.mempool, sizeof( *gameui.oldModsInfo ) * FI->numgames );
for( i = 0; i < FI->numgames; i++ )
{
gameui.oldModsInfo[i] = Mem_Calloc( gameui.mempool, sizeof( *gameui.oldModsInfo[i] ));
UI_ToOldGameInfo( gameui.oldModsInfo[i], &gameui.modsInfo[i] );
}
}
return gameui.oldModsInfo;
} }
/* /*
@@ -980,7 +1042,7 @@ pfnCheckGameDll
========= =========
*/ */
int GAME_EXPORT pfnCheckGameDll( void ) static int GAME_EXPORT pfnCheckGameDll( void )
{ {
#ifdef XASH_INTERNAL_GAMELIBS #ifdef XASH_INTERNAL_GAMELIBS
return true; return true;
@@ -1007,7 +1069,7 @@ pfnChangeInstance
*/ */
static void GAME_EXPORT pfnChangeInstance( const char *newInstance, const char *szFinalMessage ) static void GAME_EXPORT pfnChangeInstance( const char *newInstance, const char *szFinalMessage )
{ {
Con_Reportf( S_ERROR "ChangeInstance menu call is deprecated!\n" ); Con_Reportf( S_ERROR "%s menu call is deprecated!\n", __func__ );
} }
/* /*
@@ -1088,8 +1150,27 @@ static int pfnDelete( const char *path )
return FS_Delete( path ); return FS_Delete( path );
} }
static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
{
Con_DefaultColor( r, g, b, true );
}
static void GAME_EXPORT pfnSetCursor( void *hCursor )
{
uintptr_t cursor;
if( !gameui.use_extended_api )
return; // ignore original Xash menus
cursor = (uintptr_t)hCursor;
if( cursor < dc_user || cursor > dc_last )
return;
Platform_SetCursorType( cursor );
}
// engine callbacks // engine callbacks
static ui_enginefuncs_t gEngfuncs = static const ui_enginefuncs_t gEngfuncs =
{ {
pfnPIC_Load, pfnPIC_Load,
GL_FreeImage, GL_FreeImage,
@@ -1127,7 +1208,7 @@ static ui_enginefuncs_t gEngfuncs =
UI_DrawConsoleString, UI_DrawConsoleString,
UI_DrawSetTextColor, UI_DrawSetTextColor,
Con_DrawStringLen, Con_DrawStringLen,
Con_DefaultColor, pfnCon_DefaultColor,
pfnGetPlayerModel, pfnGetPlayerModel,
pfnSetPlayerModel, pfnSetPlayerModel,
pfnClearScene, pfnClearScene,
@@ -1153,7 +1234,7 @@ static ui_enginefuncs_t gEngfuncs =
pfnKeyGetState, pfnKeyGetState,
pfnMemAlloc, pfnMemAlloc,
pfnMemFree, pfnMemFree,
pfnGetGameInfo, pfnGetOldGameInfo,
pfnGetGamesList, pfnGetGamesList,
pfnGetFilesList, pfnGetFilesList,
SV_GetSaveComment, SV_GetSaveComment,
@@ -1167,7 +1248,7 @@ static ui_enginefuncs_t gEngfuncs =
pfnHostEndGame, pfnHostEndGame,
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,
IN_SetCursor, pfnSetCursor,
pfnIsMapValid, pfnIsMapValid,
GL_ProcessTexture, GL_ProcessTexture,
COM_CompareFileTime, COM_CompareFileTime,
@@ -1200,6 +1281,28 @@ static char *pfnParseFileSafe( char *data, char *buf, const int size, unsigned i
return COM_ParseFileSafe( data, buf, size, flags, len, NULL ); return COM_ParseFileSafe( data, buf, size, flags, len, NULL );
} }
static gameinfo2_t *pfnGetGameInfo( int gi_version )
{
if( gi_version != gameui.gameInfo.gi_version )
return NULL;
return &gameui.gameInfo;
}
static gameinfo2_t *pfnGetModInfo( int gi_version, int i )
{
if( i < 0 || i >= FI->numgames )
return NULL;
if( !gameui.modsInfo )
UI_GetModsInfo();
if( gi_version != gameui.modsInfo[i].gi_version )
return NULL;
return &gameui.modsInfo[i];
}
static ui_extendedfuncs_t gExtendedfuncs = static ui_extendedfuncs_t gExtendedfuncs =
{ {
pfnEnableTextInput, pfnEnableTextInput,
@@ -1211,6 +1314,10 @@ static ui_extendedfuncs_t gExtendedfuncs =
pfnParseFileSafe, pfnParseFileSafe,
NET_AdrToString, NET_AdrToString,
NET_CompareAdrSort, NET_CompareAdrSort,
Sys_GetNativeObject,
&gNetApi,
pfnGetGameInfo,
pfnGetModInfo,
}; };
void UI_UnloadProgs( void ) void UI_UnloadProgs( void )
@@ -1220,6 +1327,7 @@ void UI_UnloadProgs( void )
// deinitialize game // deinitialize game
gameui.dllFuncs.pfnShutdown(); gameui.dllFuncs.pfnShutdown();
Cmd_RemoveCommand( "ui_allowconsole" );
Cvar_FullSet( "host_gameuiloaded", "0", FCVAR_READ_ONLY ); Cvar_FullSet( "host_gameuiloaded", "0", FCVAR_READ_ONLY );
Cvar_Unlink( FCVAR_GAMEUIDLL ); Cvar_Unlink( FCVAR_GAMEUIDLL );
@@ -1270,71 +1378,65 @@ qboolean UI_LoadProgs( void )
if(( GetMenuAPI = (MENUAPI)COM_GetProcAddress( gameui.hInstance, "GetMenuAPI" )) == NULL ) if(( GetMenuAPI = (MENUAPI)COM_GetProcAddress( gameui.hInstance, "GetMenuAPI" )) == NULL )
{ {
COM_FreeLibrary( gameui.hInstance ); COM_FreeLibrary( gameui.hInstance );
Con_Reportf( "UI_LoadProgs: can't init menu API\n" ); Con_Reportf( "%s: can't init menu API\n", __func__ );
gameui.hInstance = NULL; gameui.hInstance = NULL;
return false; return false;
} }
gameui.use_text_api = false; gameui.use_extended_api = false;
// make local copy of engfuncs to prevent overwrite it with user dll // make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs )); gpEngfuncs = gEngfuncs;
gameui.mempool = Mem_AllocPool( "Menu Pool" ); gameui.mempool = Mem_AllocPool( "Menu Pool" );
if( !GetMenuAPI( &gameui.dllFuncs, &gpEngfuncs, gameui.globals )) if( !GetMenuAPI( &gameui.dllFuncs, &gpEngfuncs, gameui.globals ))
{ {
COM_FreeLibrary( gameui.hInstance ); COM_FreeLibrary( gameui.hInstance );
Con_Reportf( "UI_LoadProgs: can't init menu API\n" ); Con_Reportf( "%s: can't init menu API\n", __func__ );
Mem_FreePool( &gameui.mempool ); Mem_FreePool( &gameui.mempool );
gameui.hInstance = NULL; gameui.hInstance = NULL;
return false; return false;
} }
// make local copy of engfuncs to prevent overwrite it with user dll // make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpExtendedfuncs, &gExtendedfuncs, sizeof( gExtendedfuncs )); gpExtendedfuncs = gExtendedfuncs;
memset( &gameui.dllFuncs2, 0, sizeof( gameui.dllFuncs2 )); memset( &gameui.dllFuncs2, 0, sizeof( gameui.dllFuncs2 ));
// try to initialize new extended API // try to initialize new extended API
if( ( GetExtAPI = (UIEXTENEDEDAPI)COM_GetProcAddress( gameui.hInstance, "GetExtAPI" ) ) ) if( ( GetExtAPI = (UIEXTENEDEDAPI)COM_GetProcAddress( gameui.hInstance, "GetExtAPI" ) ) )
{ {
Con_Reportf( "UI_LoadProgs: extended Menu API found\n" ); Con_Reportf( "%s: extended Menu API found\n", __func__ );
if( GetExtAPI( MENU_EXTENDED_API_VERSION, &gameui.dllFuncs2, &gpExtendedfuncs ) ) if( GetExtAPI( MENU_EXTENDED_API_VERSION, &gameui.dllFuncs2, &gpExtendedfuncs ) )
{ {
Con_Reportf( "UI_LoadProgs: extended Menu API initialized\n" ); Con_Reportf( "%s: extended Menu API initialized\n", __func__ );
gameui.use_text_api = true; gameui.use_extended_api = true;
} }
} }
else // otherwise, fallback to old and deprecated extensions else // otherwise, fallback to old and deprecated extensions
{ {
if( ( GiveTextApi = (UITEXTAPI)COM_GetProcAddress( gameui.hInstance, "GiveTextAPI" ) ) ) if( ( GiveTextApi = (UITEXTAPI)COM_GetProcAddress( gameui.hInstance, "GiveTextAPI" ) ) )
{ {
Con_Reportf( "UI_LoadProgs: extended text API found\n" ); Con_Reportf( "%s: extended text API found\n", __func__ );
Con_Reportf( S_WARN "Text API is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" ); Con_Reportf( S_WARN "Text API is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
if( GiveTextApi( &gpExtendedfuncs ) ) // they are binary compatible, so we can just pass extended funcs API to menu if( GiveTextApi( &gpExtendedfuncs ) ) // they are binary compatible, so we can just pass extended funcs API to menu
{ {
Con_Reportf( "UI_LoadProgs: extended text API initialized\n" ); Con_Reportf( "%s: extended text API initialized\n", __func__ );
gameui.use_text_api = true; gameui.use_extended_api = true;
} }
} }
gameui.dllFuncs2.pfnAddTouchButtonToList = (ADDTOUCHBUTTONTOLIST)COM_GetProcAddress( gameui.hInstance, "AddTouchButtonToList" ); gameui.dllFuncs2.pfnAddTouchButtonToList = (ADDTOUCHBUTTONTOLIST)COM_GetProcAddress( gameui.hInstance, "AddTouchButtonToList" );
if( gameui.dllFuncs2.pfnAddTouchButtonToList ) if( gameui.dllFuncs2.pfnAddTouchButtonToList )
{ {
Con_Reportf( "UI_LoadProgs: AddTouchButtonToList call found\n" ); Con_Reportf( "%s: AddTouchButtonToList call found\n", __func__ );
Con_Reportf( S_WARN "AddTouchButtonToList is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" ); Con_Reportf( S_WARN "AddTouchButtonToList is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
} }
} }
Cvar_FullSet( "host_gameuiloaded", "1", FCVAR_READ_ONLY ); Cvar_FullSet( "host_gameuiloaded", "1", FCVAR_READ_ONLY );
Cmd_AddRestrictedCommand( "ui_allowconsole", UI_ToggleAllowConsole_f, "unlocks developer console" );
// setup gameinfo
for( i = 0; i < FI->numgames; i++ )
{
gameui.modsInfo[i] = Mem_Calloc( gameui.mempool, sizeof( GAMEINFO ));
UI_ConvertGameInfo( gameui.modsInfo[i], FI->games[i] );
}
UI_ConvertGameInfo( &gameui.gameInfo, FI->GameInfo ); // current gameinfo UI_ConvertGameInfo( &gameui.gameInfo, FI->GameInfo ); // current gameinfo

File diff suppressed because it is too large Load Diff

View File

@@ -20,8 +20,6 @@ GNU General Public License for more details.
#include "input.h" #include "input.h"
#include "platform/platform.h" #include "platform/platform.h"
static mobile_engfuncs_t *gMobileEngfuncs;
static CVAR_DEFINE_AUTO( vibration_length, "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "vibration length" ); static CVAR_DEFINE_AUTO( vibration_length, "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "vibration length" );
static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" ); static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" );
@@ -30,17 +28,9 @@ static float g_font_scale;
static void pfnVibrate( float life, char flags ) static void pfnVibrate( float life, char flags )
{ {
if( !vibration_enable.value ) if( !vibration_enable.value || life < 0.0f )
return; return;
if( life < 0.0f )
{
Con_Reportf( S_WARN "Negative vibrate time: %f\n", life );
return;
}
//Con_Reportf( "Vibrate: %f %d\n", life, flags );
// here goes platform-specific backends // here goes platform-specific backends
Platform_Vibrate( life * vibration_length.value, flags ); Platform_Vibrate( life * vibration_length.value, flags );
} }
@@ -102,7 +92,7 @@ static char *pfnParseFileSafe( char *data, char *buf, const int size, unsigned i
return COM_ParseFileSafe( data, buf, size, flags, len, NULL ); return COM_ParseFileSafe( data, buf, size, flags, len, NULL );
} }
static mobile_engfuncs_t gpMobileEngfuncs = static const mobile_engfuncs_t gMobileEngfuncs =
{ {
MOBILITY_API_VERSION, MOBILITY_API_VERSION,
pfnVibrate, pfnVibrate,
@@ -122,21 +112,38 @@ static mobile_engfuncs_t gpMobileEngfuncs =
qboolean Mobile_Init( void ) qboolean Mobile_Init( void )
{ {
qboolean success = false;
pfnMobilityInterface ExportToClient; pfnMobilityInterface ExportToClient;
// find a mobility interface Cmd_AddCommand( "vibrate", Vibrate_f, "Vibrate for specified time");
ExportToClient = COM_GetProcAddress( clgame.hInstance, MOBILITY_CLIENT_EXPORT );
gMobileEngfuncs = &gpMobileEngfuncs;
if( ExportToClient && !ExportToClient( gMobileEngfuncs ) )
success = true;
Cmd_AddCommand( "vibrate", (xcommand_t)Vibrate_f, "Vibrate for specified time");
Cvar_RegisterVariable( &vibration_length ); Cvar_RegisterVariable( &vibration_length );
Cvar_RegisterVariable( &vibration_enable ); Cvar_RegisterVariable( &vibration_enable );
return success; // find mobility interface
if(( ExportToClient = COM_GetProcAddress( clgame.hInstance, MOBILITY_CLIENT_EXPORT )))
{
static mobile_engfuncs_t mobile_engfuncs; // keep a copy, don't let user change engine pointers
mobile_engfuncs = gMobileEngfuncs;
if( !ExportToClient( &mobile_engfuncs ))
{
Con_Reportf( "%s: ^2initailized extended MobilityAPI ^7ver. %i\n", __func__, MOBILITY_API_VERSION );
return true;
}
// make sure that mobile functions are cleared
#if 1
// some SDKs define export as returning void, breaking the contract
// ignore result for now...
return true;
#else
memset( &mobile_engfuncs, 0, sizeof( mobile_engfuncs ));
return false; // just tell user about problems
#endif
}
return true; // mobile interface is missed
} }
void Mobile_Shutdown( void ) void Mobile_Shutdown( void )

View File

@@ -63,9 +63,9 @@ static byte netcolors[NETGRAPH_NET_COLORS+NETGRAPH_LERP_HEIGHT][4] =
// other will be generated through NetGraph_InitColors() // other will be generated through NetGraph_InitColors()
}; };
static byte sendcolor[4] = { 88, 29, 130, 255 }; static const byte sendcolor[4] = { 88, 29, 130, 255 };
static byte holdcolor[4] = { 255, 0, 0, 200 }; static const byte holdcolor[4] = { 255, 0, 0, 200 };
static byte extrap_base_color[4] = { 255, 255, 255, 255 }; static const byte extrap_base_color[4] = { 255, 255, 255, 255 };
static netbandwidthgraph_t netstat_graph[NET_TIMINGS]; static netbandwidthgraph_t netstat_graph[NET_TIMINGS];
static float packet_loss; static float packet_loss;
static float packet_choke; static float packet_choke;
@@ -79,7 +79,7 @@ NetGraph_DrawRect
NetGraph_FillRGBA shortcut 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 ref.dllFuncs.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
@@ -387,7 +387,7 @@ static void NetGraph_DrawTextFields( int x, int y, int w, wrect_t rect, int coun
// move rolling average // move rolling average
framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0f - FRAMERATE_AVG_FRAC ) * framerate; framerate = FRAMERATE_AVG_FRAC * host.frametime + ( 1.0f - FRAMERATE_AVG_FRAC ) * framerate;
ref.dllFuncs.GL_SetRenderMode( font->rendermode ); CL_SetFontRendermode( font );
if( framerate > 0.0f ) if( framerate > 0.0f )
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@ CL_ParseStaticEntity
static client entity static client entity
================== ==================
*/ */
void CL_LegacyParseStaticEntity( sizebuf_t *msg ) static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
{ {
int i; int i;
entity_state_t state; entity_state_t state;
@@ -98,7 +98,7 @@ void CL_LegacyParseStaticEntity( sizebuf_t *msg )
R_AddEfrags( ent ); // add link R_AddEfrags( ent ); // add link
} }
void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient ) static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
{ {
vec3_t pos; vec3_t pos;
int chan, sound; int chan, sound;
@@ -137,12 +137,7 @@ void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
if( FBitSet( flags, SND_SENTENCE )) if( FBitSet( flags, SND_SENTENCE ))
{ {
char sentenceName[32]; 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 ); Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound );
handle = S_RegisterSound( sentenceName ); handle = S_RegisterSound( sentenceName );
} }
else handle = cl.sound_index[sound]; // see precached sound else handle = cl.sound_index[sound]; // see precached sound
@@ -167,14 +162,14 @@ CL_PrecacheSound
prceache sound from server prceache sound from server
================ ================
*/ */
void CL_LegacyPrecacheSound( sizebuf_t *msg ) static void CL_LegacyPrecacheSound( sizebuf_t *msg )
{ {
int soundIndex; int soundIndex;
soundIndex = MSG_ReadUBitLong( msg, MAX_SOUND_BITS ); soundIndex = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
if( soundIndex < 0 || soundIndex >= MAX_SOUNDS ) if( soundIndex < 0 || soundIndex >= MAX_SOUNDS )
Host_Error( "CL_PrecacheSound: bad soundindex %i\n", soundIndex ); Host_Error( "%s: bad soundindex %i\n", __func__, soundIndex );
Q_strncpy( cl.sound_precache[soundIndex], MSG_ReadString( msg ), sizeof( cl.sound_precache[0] )); Q_strncpy( cl.sound_precache[soundIndex], MSG_ReadString( msg ), sizeof( cl.sound_precache[0] ));
@@ -184,7 +179,7 @@ void CL_LegacyPrecacheSound( sizebuf_t *msg )
cl.sound_index[soundIndex] = S_RegisterSound( cl.sound_precache[soundIndex] ); cl.sound_index[soundIndex] = S_RegisterSound( cl.sound_precache[soundIndex] );
} }
void CL_LegacyPrecacheModel( sizebuf_t *msg ) static void CL_LegacyPrecacheModel( sizebuf_t *msg )
{ {
int modelIndex; int modelIndex;
string model; string model;
@@ -192,9 +187,9 @@ void CL_LegacyPrecacheModel( sizebuf_t *msg )
modelIndex = MSG_ReadUBitLong( msg, MAX_LEGACY_MODEL_BITS ); modelIndex = MSG_ReadUBitLong( msg, MAX_LEGACY_MODEL_BITS );
if( modelIndex < 0 || modelIndex >= MAX_MODELS ) if( modelIndex < 0 || modelIndex >= MAX_MODELS )
Host_Error( "CL_PrecacheModel: bad modelindex %i\n", modelIndex ); Host_Error( "%s: bad modelindex %i\n", __func__, modelIndex );
Q_strncpy( model, MSG_ReadString( msg ), MAX_STRING ); Q_strncpy( model, MSG_ReadString( msg ), sizeof( model ));
//Q_strncpy( cl.model_precache[modelIndex], BF_ReadString( msg ), sizeof( cl.model_precache[0] )); //Q_strncpy( cl.model_precache[modelIndex], BF_ReadString( msg ), sizeof( cl.model_precache[0] ));
// when we loading map all resources is precached sequentially // when we loading map all resources is precached sequentially
@@ -214,14 +209,14 @@ void CL_LegacyPrecacheModel( sizebuf_t *msg )
cl.nummodels = Q_max( cl.nummodels, modelIndex ); cl.nummodels = Q_max( cl.nummodels, modelIndex );
} }
void CL_LegacyPrecacheEvent( sizebuf_t *msg ) static void CL_LegacyPrecacheEvent( sizebuf_t *msg )
{ {
int eventIndex; int eventIndex;
eventIndex = MSG_ReadUBitLong( msg, MAX_EVENT_BITS ); eventIndex = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
if( eventIndex < 0 || eventIndex >= MAX_EVENTS ) if( eventIndex < 0 || eventIndex >= MAX_EVENTS )
Host_Error( "CL_PrecacheEvent: bad eventindex %i\n", eventIndex ); Host_Error( "%s: bad eventindex %i\n", __func__, eventIndex );
Q_strncpy( cl.event_precache[eventIndex], MSG_ReadString( msg ), sizeof( cl.event_precache[0] )); Q_strncpy( cl.event_precache[eventIndex], MSG_ReadString( msg ), sizeof( cl.event_precache[0] ));
@@ -242,7 +237,7 @@ CL_ParseResourceList
============== ==============
*/ */
void CL_LegacyParseResourceList( sizebuf_t *msg ) static void CL_LegacyParseResourceList( sizebuf_t *msg )
{ {
int i = 0; int i = 0;
static struct static struct
@@ -261,10 +256,10 @@ void CL_LegacyParseResourceList( sizebuf_t *msg )
for( i = 0; i < reslist.rescount; i++ ) for( i = 0; i < reslist.rescount; i++ )
{ {
reslist.restype[i] = MSG_ReadWord( msg ); reslist.restype[i] = MSG_ReadWord( msg );
Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), MAX_QPATH ); Q_strncpy( reslist.resnames[i], MSG_ReadString( msg ), sizeof( reslist.resnames[i] ));
} }
if( CL_IsPlaybackDemo() ) if( cls.demoplayback )
return; return;
if( !cl_allow_download.value ) if( !cl_allow_download.value )
@@ -317,36 +312,19 @@ CL_ParseLegacyServerMessage
dispatch messages dispatch messages
===================== =====================
*/ */
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message ) void CL_ParseLegacyServerMessage( sizebuf_t *msg )
{ {
size_t bufStart, playerbytes; size_t bufStart, playerbytes;
int cmd, param1, param2; int cmd;
int old_background; int old_background;
const char *s; const char *s;
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
CL_Parse_Debug( true ); // begin parsing
if( normal_message )
{
// assume no entity/player update this packet
if( cls.state == ca_active )
{
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
}
else
{
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
}
}
// parse the message // parse the message
while( 1 ) while( 1 )
{ {
if( MSG_CheckOverflow( msg )) if( MSG_CheckOverflow( msg ))
{ {
Host_Error( "CL_ParseServerMessage: overflow!\n" ); Host_Error( "%s: overflow!\n", __func__ );
return; return;
} }
@@ -362,6 +340,9 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
// record command for debugging spew on parse problem // record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart ); CL_Parse_RecordCommand( cmd, bufStart );
if( CL_ParseCommonDLLMessage( msg, PROTO_LEGACY, cmd, bufStart ))
continue;
// other commands // other commands
switch( cmd ) switch( cmd )
{ {
@@ -376,7 +357,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
Host_AbortCurrentFrame (); Host_AbortCurrentFrame ();
break; break;
case svc_legacy_event: case svc_legacy_event:
CL_ParseEvent( msg ); CL_ParseEvent( msg, PROTO_LEGACY );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart; cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break; break;
case svc_legacy_changing: case svc_legacy_changing:
@@ -385,7 +366,9 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
{ {
int maxclients = cl.maxclients; int maxclients = cl.maxclients;
cls.changelevel = true; // we can only changelevel in singleplayer
// and singleplayer always runs in current protocol
// cls.changelevel = true;
S_StopAllSounds( true ); S_StopAllSounds( true );
Con_Printf( "Server changing, reconnecting\n" ); Con_Printf( "Server changing, reconnecting\n" );
@@ -436,20 +419,24 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
break; break;
case svc_time: case svc_time:
CL_ParseServerTime( msg ); CL_ParseServerTime( msg, PROTO_LEGACY );
break; break;
case svc_print: case svc_print:
Con_Printf( "%s", MSG_ReadString( msg )); Con_Printf( "%s", MSG_ReadString( msg ));
break; break;
case svc_stufftext: case svc_stufftext:
s = MSG_ReadString( msg ); s = MSG_ReadString( msg );
if( cl_trace_stufftext.value )
{
size_t len = Q_strlen( s );
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
}
#ifdef HACKS_RELATED_HLMODS #ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection // disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS ) if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early break; // too early
#endif #endif
Con_Reportf( "Stufftext: %s", s );
Cbuf_AddFilteredText( s ); Cbuf_AddFilteredText( s );
break; break;
case svc_setangle: case svc_setangle:
@@ -457,19 +444,19 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
break; break;
case svc_serverdata: case svc_serverdata:
Cbuf_Execute(); // make sure any stuffed commands are done Cbuf_Execute(); // make sure any stuffed commands are done
CL_ParseServerData( msg, true ); CL_ParseServerData( msg, PROTO_LEGACY );
break; break;
case svc_lightstyle: case svc_lightstyle:
CL_ParseLightStyle( msg ); CL_ParseLightStyle( msg, PROTO_LEGACY );
break; break;
case svc_updateuserinfo: case svc_updateuserinfo:
CL_UpdateUserinfo( msg, true ); CL_UpdateUserinfo( msg, PROTO_LEGACY );
break; break;
case svc_deltatable: case svc_deltatable:
Delta_ParseTableField( msg ); Delta_ParseTableField( msg );
break; break;
case svc_clientdata: case svc_clientdata:
CL_ParseClientData( msg ); CL_ParseClientData( msg, PROTO_LEGACY );
cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart; cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart;
break; break;
case svc_resource: case svc_resource:
@@ -479,82 +466,58 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
CL_UpdateUserPings( msg ); CL_UpdateUserPings( msg );
break; break;
case svc_particle: case svc_particle:
CL_ParseParticles( msg ); CL_ParseParticles( msg, PROTO_LEGACY );
break; break;
case svc_restoresound: case svc_restoresound:
CL_ParseRestoreSoundPacket( msg ); Con_Printf( S_ERROR "%s: svc_restoresound: implement me!\n", __func__ );
cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart;
break; break;
case svc_spawnstatic: case svc_spawnstatic:
CL_LegacyParseStaticEntity( msg ); CL_LegacyParseStaticEntity( msg );
break; break;
case svc_event_reliable: case svc_event_reliable:
CL_ParseReliableEvent( msg ); CL_ParseReliableEvent( msg, PROTO_LEGACY );
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart; cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
break; break;
case svc_spawnbaseline: case svc_spawnbaseline:
CL_ParseBaseline( msg, true ); CL_ParseBaseline( msg, PROTO_LEGACY );
break;
case svc_temp_entity:
CL_ParseTempEntity( msg );
cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart;
break; break;
case svc_setpause: case svc_setpause:
cl.paused = ( MSG_ReadOneBit( msg ) != 0 ); cl.paused = ( MSG_ReadOneBit( msg ) != 0 );
break; break;
case svc_signonnum: case svc_signonnum:
CL_ParseSignon( msg ); CL_ParseSignon( msg, PROTO_LEGACY );
break; break;
case svc_centerprint: case svc_centerprint:
CL_CenterPrint( MSG_ReadString( msg ), 0.25f ); CL_CenterPrint( MSG_ReadString( msg ), 0.25f );
break; break;
case svc_intermission:
cl.intermission = 1;
break;
case svc_legacy_modelindex: case svc_legacy_modelindex:
CL_LegacyPrecacheModel( msg ); CL_LegacyPrecacheModel( msg );
break; break;
case svc_legacy_soundindex: case svc_legacy_soundindex:
CL_LegacyPrecacheSound( msg ); CL_LegacyPrecacheSound( msg );
break; 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: case svc_restore:
CL_ParseRestore( msg ); CL_ParseRestore( msg );
break; break;
case svc_legacy_eventindex: case svc_legacy_eventindex:
CL_LegacyPrecacheEvent(msg); CL_LegacyPrecacheEvent(msg);
break; break;
case svc_weaponanim:
param1 = MSG_ReadByte( msg ); // iAnim
param2 = MSG_ReadByte( msg ); // body
CL_WeaponAnim( param1, param2 );
break;
case svc_bspdecal: case svc_bspdecal:
CL_ParseStaticDecal( msg ); CL_ParseStaticDecal( msg );
break; break;
case svc_roomtype:
param1 = MSG_ReadShort( msg );
Cvar_SetValue( "room_type", param1 );
break;
case svc_addangle: case svc_addangle:
CL_ParseAddAngle( msg ); CL_ParseAddAngle( msg );
break; break;
case svc_usermessage: case svc_usermessage:
CL_RegisterUserMessage( msg ); CL_RegisterUserMessage( msg, PROTO_LEGACY );
break; break;
case svc_packetentities: 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.players += playerbytes;
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes; cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
break; break;
case svc_deltapacketentities: 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.players += playerbytes;
cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes; cl.frames[cl.parsecountmod].graphdata.entities += MSG_GetNumBytesRead( msg ) - bufStart - playerbytes;
break; break;
@@ -601,41 +564,21 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
case svc_hltv: case svc_hltv:
CL_ParseHLTV( msg ); CL_ParseHLTV( msg );
break; break;
case svc_director:
CL_ParseDirector( msg );
break;
case svc_resourcelocation: case svc_resourcelocation:
CL_ParseResLocation( msg ); CL_ParseResLocation( msg );
break; break;
case svc_querycvarvalue: case svc_querycvarvalue:
CL_ParseCvarValue( msg, false ); CL_ParseCvarValue( msg, false, PROTO_LEGACY );
break; break;
case svc_querycvarvalue2: case svc_querycvarvalue2:
CL_ParseCvarValue( msg, true ); CL_ParseCvarValue( msg, true, PROTO_LEGACY );
break; break;
default: default:
CL_ParseUserMessage( msg, cmd ); CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart; cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
break; break;
} }
} }
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
CL_Parse_Debug( false ); // done
// we don't know if it is ok to save a demo message until
// after we have parsed the frame
if( !cls.demoplayback )
{
if( cls.demorecording && !cls.demowaiting )
{
CL_WriteDemoMessage( false, cls.starting_count, msg );
}
else if( cls.state != ca_active )
{
CL_WriteDemoMessage( true, cls.starting_count, msg );
}
}
} }
void CL_LegacyPrecache_f( void ) void CL_LegacyPrecache_f( void )
@@ -643,7 +586,7 @@ void CL_LegacyPrecache_f( void )
int spawncount, i; int spawncount, i;
model_t *mod; model_t *mod;
if( !cls.legacymode ) if( cls.legacymode != PROTO_LEGACY )
return; return;
spawncount = Q_atoi( Cmd_Argv( 1 )); spawncount = Q_atoi( Cmd_Argv( 1 ));
@@ -660,8 +603,8 @@ void CL_LegacyPrecache_f( void )
if( clgame.entities ) if( clgame.entities )
clgame.entities->model = cl.worldmodel; clgame.entities->model = cl.worldmodel;
// update the ref state. // load skybox
R_UpdateRefState (); R_SetupSky( clgame.movevars.skyName );
// tell rendering system we have a new set of models. // tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap (); ref.dllFuncs.R_NewMap ();
@@ -684,22 +627,5 @@ void CL_LegacyPrecache_f( void )
// Include server count in case server disconnects and changes level during d/l // Include server count in case server disconnects and changes level during d/l
MSG_BeginClientCmd( &cls.netchan.message, clc_stringcmd ); MSG_BeginClientCmd( &cls.netchan.message, clc_stringcmd );
MSG_WriteStringf( &cls.netchan.message, "begin %i", spawncount ); MSG_WriteStringf( &cls.netchan.message, "begin %i", spawncount );
cls.signon = SIGNONS; cls.signon = SIGNONS - 1;
}
void CL_LegacyUpdateInfo( void )
{
if( !cls.legacymode )
return;
if( cls.state != ca_active )
return;
MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
}
qboolean CL_LegacyMode( void )
{
return cls.legacymode;
} }

762
engine/client/cl_parse_gs.c Normal file
View 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__ );
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;
}
}
}

View File

@@ -54,37 +54,12 @@ void GAME_EXPORT CL_PopPMStates( void )
clgame.pushed = false; clgame.pushed = false;
} }
/*
=============
CL_PushTraceBounds
=============
*/
void GAME_EXPORT CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs )
{
hullnum = bound( 0, hullnum, 3 );
VectorCopy( mins, clgame.pmove->player_mins[hullnum] );
VectorCopy( maxs, clgame.pmove->player_maxs[hullnum] );
}
/*
=============
CL_PopTraceBounds
=============
*/
void GAME_EXPORT CL_PopTraceBounds( void )
{
memcpy( clgame.pmove->player_mins, host.player_mins, sizeof( host.player_mins ));
memcpy( clgame.pmove->player_maxs, host.player_maxs, sizeof( host.player_maxs ));
}
/* /*
=============== ===============
CL_IsPredicted CL_IsPredicted
=============== ===============
*/ */
qboolean CL_IsPredicted( void ) static qboolean CL_IsPredicted( void )
{ {
if( cl_nopred.value || cl.intermission ) if( cl_nopred.value || cl.intermission )
return false; return false;
@@ -417,7 +392,7 @@ CL_AddLinksToPmove
collect solid entities collect solid entities
==================== ====================
*/ */
void CL_AddLinksToPmove( frame_t *frame ) static void CL_AddLinksToPmove( frame_t *frame )
{ {
entity_state_t *state; entity_state_t *state;
model_t *model; model_t *model;
@@ -569,8 +544,8 @@ void GAME_EXPORT CL_SetSolidPlayers( int playernum )
// some fields needs to be override from cls.predicted_players // some fields needs to be override from cls.predicted_players
VectorCopy( player->origin, pe->origin ); VectorCopy( player->origin, pe->origin );
VectorCopy( player->angles, pe->angles ); VectorCopy( player->angles, pe->angles );
VectorCopy( clgame.pmove->player_mins[player->usehull], pe->mins ); VectorCopy( host.player_mins[player->usehull], pe->mins );
VectorCopy( clgame.pmove->player_maxs[player->usehull], pe->maxs ); VectorCopy( host.player_maxs[player->usehull], pe->maxs );
pe->movetype = player->movetype; pe->movetype = player->movetype;
pe->solid = player->solid; pe->solid = player->solid;
} }
@@ -687,11 +662,6 @@ cl_entity_t *CL_GetWaterEntity( const float *rgflPos )
return CL_GetEntityByIndex( entnum ); return CL_GetEntityByIndex( entnum );
} }
int GAME_EXPORT CL_TestLine( const vec3_t start, const vec3_t end, int flags )
{
return PM_TestLineExt( clgame.pmove, clgame.pmove->physents, clgame.pmove->numphysent, start, end, flags );
}
static int GAME_EXPORT pfnTestPlayerPosition( float *pos, pmtrace_t *ptrace ) static int GAME_EXPORT pfnTestPlayerPosition( float *pos, pmtrace_t *ptrace )
{ {
return PM_TestPlayerPosition( clgame.pmove, pos, ptrace, NULL ); return PM_TestPlayerPosition( clgame.pmove, pos, ptrace, NULL );
@@ -824,6 +794,16 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
cd = &from->client; cd = &from->client;
pmove->player_index = ps->number - 1; pmove->player_index = ps->number - 1;
// a1ba: workaround bug where the server refuse to send our local player in delta
// cl.playernum, in theory, must be equal to our local player index anyway
//
// this might not be a real solution, since everything else will be bogus
// but we need to properly run prediction and avoid potential memory
// corruption
if( pmove->player_index < 0 )
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
pmove->multiplayer = (cl.maxclients > 1); pmove->multiplayer = (cl.maxclients > 1);
pmove->runfuncs = runfuncs; pmove->runfuncs = runfuncs;
pmove->time = time * 1000.0f; pmove->time = time * 1000.0f;
@@ -873,10 +853,10 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
VectorCopy( cd->vuser4, pmove->vuser4 ); VectorCopy( cd->vuser4, pmove->vuser4 );
pmove->cmd = *ucmd; // copy current cmds pmove->cmd = *ucmd; // copy current cmds
Q_strncpy( pmove->physinfo, cls.physinfo, MAX_INFO_STRING ); Q_strncpy( pmove->physinfo, cls.physinfo, sizeof( pmove->physinfo ));
} }
const void CL_FinishPMove( const playermove_t *pmove, local_state_t *to ) static const void CL_FinishPMove( const playermove_t *pmove, local_state_t *to )
{ {
entity_state_t *ps; entity_state_t *ps;
clientdata_t *cd; clientdata_t *cd;
@@ -929,7 +909,7 @@ CL_RunUsercmd
Runs prediction code for user cmd Runs prediction code for user cmd
================= =================
*/ */
void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboolean runfuncs, double *time, unsigned int random_seed ) static void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboolean runfuncs, double *time, unsigned int random_seed )
{ {
usercmd_t cmd; usercmd_t cmd;

View File

@@ -22,22 +22,24 @@ GNU General Public License for more details.
#include "hltv.h" #include "hltv.h"
#include "input.h" #include "input.h"
#define STAT_HEALTH 0 enum {
#define STAT_FRAGS 1 STAT_HEALTH = 0,
#define STAT_WEAPON 2 STAT_FRAGS,
#define STAT_AMMO 3 STAT_WEAPON,
#define STAT_ARMOR 4 STAT_AMMO,
#define STAT_WEAPONFRAME 5 STAT_ARMOR,
#define STAT_SHELLS 6 STAT_WEAPONFRAME,
#define STAT_NAILS 7 STAT_SHELLS,
#define STAT_ROCKETS 8 STAT_NAILS,
#define STAT_CELLS 9 STAT_ROCKETS,
#define STAT_ACTIVEWEAPON 10 STAT_CELLS,
#define STAT_TOTALSECRETS 11 STAT_ACTIVEWEAPON,
#define STAT_TOTALMONSTERS 12 STAT_TOTALSECRETS,
#define STAT_SECRETS 13 // bumped on client side by svc_foundsecret STAT_TOTALMONSTERS,
#define STAT_MONSTERS 14 // bumped by svc_killedmonster STAT_SECRETS, // bumped on client side by svc_foundsecret
#define MAX_STATS 32 STAT_MONSTERS, // bumped by svc_killedmonster
MAX_STATS = 32,
};
static char cmd_buf[8192]; static char cmd_buf[8192];
static char msg_buf[8192]; static char msg_buf[8192];
@@ -211,7 +213,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
clgame.maxEntities = GI->max_edicts; clgame.maxEntities = GI->max_edicts;
clgame.maxEntities = bound( 600, clgame.maxEntities, MAX_EDICTS ); clgame.maxEntities = bound( 600, clgame.maxEntities, MAX_EDICTS );
clgame.maxModels = MAX_MODELS; clgame.maxModels = MAX_MODELS;
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), MAX_STRING ); Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
// Re-init hud video, especially if we changed game directories // Re-init hud video, especially if we changed game directories
clgame.dllFuncs.pfnVidInit(); clgame.dllFuncs.pfnVidInit();
@@ -328,7 +330,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
clgame.movevars.gravity = 800.0f; // quake doesn't write gravity in demos clgame.movevars.gravity = 800.0f; // quake doesn't write gravity in demos
clgame.movevars.maxvelocity = 2000.0f; clgame.movevars.maxvelocity = 2000.0f;
memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t )); clgame.oldmovevars = clgame.movevars;
} }
/* /*
@@ -414,7 +416,7 @@ If an entities model or origin changes from frame to frame, it must be
relinked. Other attributes can change without relinking. relinked. Other attributes can change without relinking.
================== ==================
*/ */
void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits ) static void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
{ {
int i, newnum, pack; int i, newnum, pack;
qboolean forcelink; qboolean forcelink;
@@ -429,7 +431,7 @@ void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits )
cls.signon = SIGNONS; cls.signon = SIGNONS;
// Clear loading plaque. // Clear loading plaque.
CL_SignonReply (); CL_SignonReply( PROTO_QUAKE );
} }
// alloc next slot to store update // alloc next slot to store update
@@ -565,7 +567,7 @@ CL_ParseQuakeParticles
================== ==================
*/ */
void CL_ParseQuakeParticle( sizebuf_t *msg ) static void CL_ParseQuakeParticle( sizebuf_t *msg )
{ {
int count, color; int count, color;
vec3_t org, dir; vec3_t org, dir;
@@ -587,7 +589,7 @@ CL_ParseQuakeStaticSound
=================== ===================
*/ */
void CL_ParseQuakeStaticSound( sizebuf_t *msg ) static void CL_ParseQuakeStaticSound( sizebuf_t *msg )
{ {
int sound_num; int sound_num;
float vol, attn; float vol, attn;
@@ -620,7 +622,7 @@ static void CL_ParseQuakeDamage( sizebuf_t *msg )
/* /*
=================== ===================
CL_ParseQuakeStaticEntity CL_ParseStaticEntity
=================== ===================
*/ */
@@ -646,7 +648,7 @@ static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
i = clgame.numStatics; i = clgame.numStatics;
if( i >= MAX_STATIC_ENTITIES ) if( i >= MAX_STATIC_ENTITIES )
{ {
Con_Printf( S_ERROR "CL_ParseStaticEntity: static entities limit exceeded!\n" ); Con_Printf( S_ERROR "%s: static entities limit exceeded!\n", __func__ );
return; return;
} }
@@ -697,7 +699,7 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
newnum = MSG_ReadWord( msg ); // entnum newnum = MSG_ReadWord( msg ); // entnum
if( newnum >= clgame.maxEntities ) if( newnum >= clgame.maxEntities )
Host_Error( "CL_AllocEdict: no free edicts\n" ); Host_Error( "%s: no free edicts\n", __func__ );
// parse baseline // parse baseline
memset( &state, 0, sizeof( state )); memset( &state, 0, sizeof( state ));
@@ -715,8 +717,7 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
ent = CL_EDICT_NUM( newnum ); ent = CL_EDICT_NUM( newnum );
ent->index = newnum; ent->index = newnum;
ent->player = CL_IsPlayerIndex( newnum ); ent->player = CL_IsPlayerIndex( newnum );
memcpy( &ent->baseline, &state, sizeof( entity_state_t )); ent->prevstate = ent->baseline = state;
memcpy( &ent->prevstate, &state, sizeof( entity_state_t ));
} }
/* /*
@@ -778,7 +779,7 @@ static void CL_ParseQuakeSignon( sizebuf_t *msg )
int i = MSG_ReadByte( msg ); int i = MSG_ReadByte( msg );
if( i == 3 ) cls.signon = SIGNONS - 1; if( i == 3 ) cls.signon = SIGNONS - 1;
Con_Reportf( "CL_Signon: %d\n", i ); Con_Reportf( "%s: %d\n", __func__, i );
} }
/* /*
@@ -816,7 +817,7 @@ CL_QuakeStuffText
================== ==================
*/ */
void CL_QuakeStuffText( const char *text ) static void CL_QuakeStuffText( const char *text )
{ {
Q_strncat( cmd_buf, text, sizeof( cmd_buf )); Q_strncat( cmd_buf, text, sizeof( cmd_buf ));
@@ -831,7 +832,7 @@ CL_QuakeExecStuff
================== ==================
*/ */
void CL_QuakeExecStuff( void ) static void CL_QuakeExecStuff( void )
{ {
char *text = cmd_buf; char *text = cmd_buf;
char token[256]; char token[256];
@@ -886,38 +887,21 @@ CL_ParseQuakeMessage
================== ==================
*/ */
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message ) void CL_ParseQuakeMessage( sizebuf_t *msg )
{ {
int cmd, param1, param2; int cmd, param1, param2;
size_t bufStart; size_t bufStart;
const char *str; const char *str;
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
CL_Parse_Debug( true ); // begin parsing
// init excise buffer // init excise buffer
MSG_Init( &msg_demo, "UserMsg", msg_buf, sizeof( msg_buf )); MSG_Init( &msg_demo, "UserMsg", msg_buf, sizeof( msg_buf ));
if( normal_message )
{
// assume no entity/player update this packet
if( cls.state == ca_active )
{
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].valid = false;
cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK].choked = false;
}
else
{
CL_ResetFrame( &cl.frames[cls.netchan.incoming_sequence & CL_UPDATE_MASK] );
}
}
// parse the message // parse the message
while( 1 ) while( 1 )
{ {
if( MSG_CheckOverflow( msg )) if( MSG_CheckOverflow( msg ))
{ {
Host_Error( "CL_ParseServerMessage: overflow!\n" ); Host_Error( "%s: overflow!\n", __func__ );
return; return;
} }
@@ -966,7 +950,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message )
break; break;
case svc_time: case svc_time:
Cbuf_AddText( "\n" ); // new frame was started Cbuf_AddText( "\n" ); // new frame was started
CL_ParseServerTime( msg ); CL_ParseServerTime( msg, PROTO_QUAKE );
break; break;
case svc_print: case svc_print:
str = MSG_ReadString( msg ); str = MSG_ReadString( msg );
@@ -1108,14 +1092,11 @@ void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message )
} }
break; break;
default: default:
Host_Error( "CL_ParseServerMessage: Illegible server message\n" ); Host_Error( "%s: Illegible server message\n", __func__ );
break; break;
} }
} }
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
CL_Parse_Debug( false ); // done
// now process packet. // now process packet.
CL_ProcessPacket( &cl.frames[cl.parsecountmod] ); CL_ProcessPacket( &cl.frames[cl.parsecountmod] );

View File

@@ -78,7 +78,7 @@ CL_CreateRawTextureFromPixels
Convert texture_t struct into mstudiotexture_t prototype Convert texture_t struct into mstudiotexture_t prototype
==================== ====================
*/ */
byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor ) static byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
{ {
static mstudiotexture_t pin; static mstudiotexture_t pin;
byte *pal; byte *pal;
@@ -111,7 +111,7 @@ CL_DuplicateTexture
Dupliacte texture with remap pixels Dupliacte texture with remap pixels
==================== ====================
*/ */
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor ) static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{ {
const char *name; const char *name;
texture_t *tx = NULL; texture_t *tx = NULL;
@@ -154,7 +154,7 @@ CL_UpdateStudioTexture
Update texture top and bottom colors Update texture top and bottom colors
==================== ====================
*/ */
void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor ) static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{ {
rgbdata_t *pic; rgbdata_t *pic;
texture_t *tx = NULL; texture_t *tx = NULL;
@@ -215,7 +215,7 @@ CL_UpdateAliasTexture
Update texture top and bottom colors Update texture top and bottom colors
==================== ====================
*/ */
void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor ) static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
{ {
char texname[MAX_QPATH]; char texname[MAX_QPATH];
rgbdata_t skin, *pic; rgbdata_t skin, *pic;
@@ -247,6 +247,68 @@ void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int sk
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor ); ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
} }
/*
====================
CL_FreeRemapInfo
Release remap info per entity
====================
*/
static void CL_FreeRemapInfo( remap_info_t *info )
{
int i;
Assert( info != NULL );
// release all colormap texture copies
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
}
if( info->textures[i] != 0 )
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
}
Mem_Free( info ); // release struct
}
/*
====================
CL_UpdateRemapInfo
Update all remaps per entity
====================
*/
static void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
{
remap_info_t *info;
int i;
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
info = clgame.remap_info[i];
if( !info ) return; // no remap info
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
return; // values is valid
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
}
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
}
info->topcolor = topcolor;
info->bottomcolor = bottomcolor;
}
/* /*
==================== ====================
CL_AllocRemapInfo CL_AllocRemapInfo
@@ -255,7 +317,7 @@ Allocate new remap info per entity
and make copy of remap textures and make copy of remap textures
==================== ====================
*/ */
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor ) static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
{ {
remap_info_t *info; remap_info_t *info;
studiohdr_t *phdr; studiohdr_t *phdr;
@@ -362,68 +424,6 @@ void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int b
info->model = model; info->model = model;
} }
/*
====================
CL_UpdateRemapInfo
Update all remaps per entity
====================
*/
void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
{
remap_info_t *info;
int i;
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
info = clgame.remap_info[i];
if( !info ) return; // no remap info
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
return; // values is valid
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
}
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
}
info->topcolor = topcolor;
info->bottomcolor = bottomcolor;
}
/*
====================
CL_FreeRemapInfo
Release remap info per entity
====================
*/
void CL_FreeRemapInfo( remap_info_t *info )
{
int i;
Assert( info != NULL );
// release all colormap texture copies
for( i = 0; i < info->numtextures; i++ )
{
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
}
if( info->textures[i] != 0 )
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
}
Mem_Free( info ); // release struct
}
/* /*
==================== ====================
CL_ClearAllRemaps CL_ClearAllRemaps
@@ -446,3 +446,21 @@ void CL_ClearAllRemaps( void )
} }
clgame.remap_info = NULL; clgame.remap_info = NULL;
} }
/*
=============
CL_EntitySetRemapColors
=============
*/
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom )
{
CL_AllocRemapInfo( e, mod, top, bottom );
if( CL_GetRemapInfoForEntity( e ))
{
CL_UpdateRemapInfo( e, top, bottom );
return true;
}
return false;
}

View File

@@ -20,7 +20,7 @@ GNU General Public License for more details.
int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis ) int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis )
{ {
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis ); return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis, false );
} }
lightstyle_t *CL_GetLightStyle( int number ) lightstyle_t *CL_GetLightStyle( int number )
@@ -126,7 +126,7 @@ CL_GenericHandle
============= =============
*/ */
const char *CL_GenericHandle( int fileindex ) static const char *CL_GenericHandle( int fileindex )
{ {
if( fileindex < 0 || fileindex >= MAX_CUSTOM ) if( fileindex < 0 || fileindex >= MAX_CUSTOM )
return 0; return 0;
@@ -142,8 +142,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return 1; return 1;
#endif #endif
return 0; return 0;
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARAM_GAMEPAUSED: case PARAM_GAMEPAUSED:
return cl.paused; return cl.paused;
case PARM_CLIENT_INGAME: case PARM_CLIENT_INGAME:
@@ -172,6 +170,12 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return refState.width; return refState.width;
case PARM_SCREEN_HEIGHT: case PARM_SCREEN_HEIGHT:
return refState.height; return refState.height;
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARM_SURF_SAMPLESIZE:
if( arg >= 0 && arg < cl.worldmodel->numsurfaces )
return Mod_SampleSizeForFace( &cl.worldmodel->surfaces[arg] );
return LM_SAMPLE_SIZE;
default: default:
// indicates call from client.dll // indicates call from client.dll
if( checkRef ) if( checkRef )
@@ -187,26 +191,30 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return CL_IsThirdPerson(); return CL_IsThirdPerson();
case PARM_QUAKE_COMPATIBLE: case PARM_QUAKE_COMPATIBLE:
return Host_IsQuakeCompatible(); return Host_IsQuakeCompatible();
case PARM_PLAYER_INDEX:
return cl.playernum + 1;
case PARM_VIEWENT_INDEX:
return cl.viewentity;
case PARM_CONNSTATE: case PARM_CONNSTATE:
return (int)cls.state; return (int)cls.state;
case PARM_PLAYING_DEMO: case PARM_PLAYING_DEMO:
return cls.demoplayback; return cls.demoplayback;
case PARM_WATER_LEVEL: case PARM_WATER_LEVEL:
return cl.local.waterlevel; return cl.local.waterlevel;
case PARM_MAX_CLIENTS:
return cl.maxclients;
case PARM_LOCAL_HEALTH: case PARM_LOCAL_HEALTH:
return cl.local.health; return cl.local.health;
case PARM_LOCAL_GAME: case PARM_LOCAL_GAME:
return Host_IsLocalGame(); return Host_IsLocalGame();
case PARM_NUMENTITIES: case PARM_NUMENTITIES:
return pfnNumberOfEntities(); return pfnNumberOfEntities();
case PARM_NUMMODELS: case PARM_GET_CLIENT_PTR:
return cl.nummodels; return (intptr_t)&cl.time; // with the offset
case PARM_GET_HOST_PTR:
return (intptr_t)&host.realtime; // with the offset
case PARM_GET_WORLD_PTR:
return (intptr_t)&world;
case PARM_GET_MOVEVARS_PTR:
return (intptr_t)&clgame.movevars;
case PARM_GET_PALETTE_PTR:
return (intptr_t)&clgame.palette;
case PARM_GET_VIEWENT_PTR:
return (intptr_t)&clgame.viewent;
} }
} }
return 0; return 0;
@@ -339,7 +347,7 @@ qboolean R_InitRenderAPI( void )
{ {
if( clgame.dllFuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &clgame.drawFuncs )) if( clgame.dllFuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &clgame.drawFuncs ))
{ {
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION ); Con_Reportf( "%s: ^2initailized extended RenderAPI ^7ver. %i\n", __func__, CL_RENDER_INTERFACE_VERSION );
return true; return true;
} }

View File

@@ -24,7 +24,7 @@ CVAR_DEFINE_AUTO( scr_centertime, "2.5", 0, "centerprint hold time" );
CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" ); CVAR_DEFINE_AUTO( scr_loading, "0", 0, "loading bar progress" );
CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" ); CVAR_DEFINE_AUTO( scr_download, "-1", 0, "downloading bar progress" );
CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" ); CVAR_DEFINE( scr_viewsize, "viewsize", "120", FCVAR_ARCHIVE, "screen size (quake only)" );
CVAR_DEFINE_AUTO( cl_testlights, "0", 0, "test dynamic lights" ); CVAR_DEFINE_AUTO( cl_testlights, "0", FCVAR_CHEAT, "test dynamic lights" );
CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" ); CVAR_DEFINE( cl_allow_levelshots, "allow_levelshots", "0", FCVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" ); CVAR_DEFINE_AUTO( cl_levelshot_name, "*black", 0, "contains path to current levelshot" );
static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" ); static CVAR_DEFINE_AUTO( cl_envshot_size, "256", FCVAR_ARCHIVE, "envshot size of cube side" );
@@ -32,6 +32,7 @@ CVAR_DEFINE_AUTO( v_dark, "0", 0, "starts level from dark screen" );
static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" ); static CVAR_DEFINE_AUTO( net_speeds, "0", FCVAR_ARCHIVE, "show network packets" );
static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" ); static CVAR_DEFINE_AUTO( cl_showfps, "0", FCVAR_ARCHIVE, "show client fps" );
static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" ); static CVAR_DEFINE_AUTO( cl_showpos, "0", FCVAR_ARCHIVE, "show local player position and velocity" );
static CVAR_DEFINE_AUTO( cl_showents, "0", FCVAR_ARCHIVE | FCVAR_CHEAT, "show entities information (largely undone)" );
typedef struct typedef struct
{ {
@@ -122,7 +123,7 @@ void SCR_DrawPos( void )
if( cls.state != ca_active || !cl_showpos.value || cl.background ) if( cls.state != ca_active || !cl_showpos.value || cl.background )
return; return;
ent = CL_GetLocalPlayer(); ent = CL_EDICT_NUM( cl.playernum + 1 );
speed = VectorLength( cl.simvel ); speed = VectorLength( cl.simvel );
Q_snprintf( msg, MAX_SYSPATH, Q_snprintf( msg, MAX_SYSPATH,
@@ -140,6 +141,68 @@ void SCR_DrawPos( void )
Con_DrawString( refState.width / 2, 4, msg, color ); Con_DrawString( refState.width / 2, 4, msg, color );
} }
/*
==============
SCR_DrawEnts
==============
*/
void SCR_DrawEnts( void )
{
rgba_t color = { 255, 255, 255, 255 };
int i;
if( cls.state != ca_active || !cl_showents.value || ( cl.maxclients > 1 && !cls.demoplayback ))
return;
// this probably better hook CL_AddVisibleEntities
// as entities might get added by client.dll
for( i = 0; i < clgame.maxEntities; i++ )
{
const cl_entity_t *ent = &clgame.entities[i];
string msg;
vec3_t screen, pos;
if( ent->curstate.messagenum != cl.parsecount )
continue;
VectorCopy( ent->origin, pos );
if( ent->model != NULL )
{
vec3_t v;
// simple model type filter
if( cl_showents.value > 1 )
{
if( ent->model->type != (modtype_t)( cl_showents.value - 2 ))
continue;
}
VectorAverage( ent->model->mins, ent->model->maxs, v );
VectorAdd( pos, v, pos );
}
if( !ref.dllFuncs.WorldToScreen( pos, screen ))
{
Q_snprintf( msg, sizeof( msg ),
"entity %d\n"
"model %s\n"
"movetype %d\n",
ent->index,
ent->model ? ent->model->name : "(null)",
ent->curstate.movetype );
screen[0] = 0.5f * screen[0] * refState.width;
screen[1] = -0.5f * screen[1] * refState.height;
screen[0] += 0.5f * refState.width;
screen[1] += 0.5f * refState.height;
Con_DrawString( screen[0], screen[1], msg, color );
}
}
}
/* /*
============== ==============
SCR_NetSpeeds SCR_NetSpeeds
@@ -252,7 +315,7 @@ VID_WriteOverviewScript
Create overview script file Create overview script file
=============== ===============
*/ */
void VID_WriteOverviewScript( void ) static void VID_WriteOverviewScript( void )
{ {
ref_overview_t *ov = &clgame.overView; ref_overview_t *ov = &clgame.overView;
string filename; string filename;
@@ -288,10 +351,15 @@ void SCR_MakeScreenShot( void )
qboolean iRet = false; qboolean iRet = false;
int viewsize; int viewsize;
if( cls.scrshot_action == scrshot_inactive )
return;
if( cls.envshot_viewsize > 0 ) if( cls.envshot_viewsize > 0 )
viewsize = cls.envshot_viewsize; viewsize = cls.envshot_viewsize;
else viewsize = cl_envshot_size.value; else viewsize = cl_envshot_size.value;
V_CheckGamma();
switch( cls.scrshot_action ) switch( cls.scrshot_action )
{ {
case scrshot_normal: case scrshot_normal:
@@ -317,8 +385,6 @@ void SCR_MakeScreenShot( void )
if( iRet ) if( iRet )
VID_WriteOverviewScript(); // store overview script too VID_WriteOverviewScript(); // store overview script too
break; break;
case scrshot_inactive:
return;
} }
// report // report
@@ -342,7 +408,7 @@ void SCR_MakeScreenShot( void )
SCR_DrawPlaque SCR_DrawPlaque
================ ================
*/ */
void SCR_DrawPlaque( void ) static qboolean SCR_DrawPlaque( void )
{ {
if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background ) if(( cl_allow_levelshots.value && !cls.changelevel ) || cl.background )
{ {
@@ -350,7 +416,11 @@ void SCR_DrawPlaque( void )
ref.dllFuncs.GL_SetRenderMode( kRenderNormal ); ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot ); ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING ); if( !cl.background ) CL_DrawHUD( CL_LOADING );
return true;
} }
return false;
} }
/* /*
@@ -360,15 +430,10 @@ SCR_BeginLoadingPlaque
*/ */
void SCR_BeginLoadingPlaque( qboolean is_background ) void SCR_BeginLoadingPlaque( qboolean is_background )
{ {
float oldclear = 0;;
S_StopAllSounds( true ); S_StopAllSounds( true );
cl.audio_prepped = false; // don't play ambients cl.audio_prepped = false; // don't play ambients
cl.video_prepped = false;
if( !Host_IsDedicated() ) if( cls.key_dest == key_menu && !cls.changedemo && !is_background )
oldclear = gl_clear.value;
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{ {
UI_SetActiveMenu( false ); UI_SetActiveMenu( false );
if( cls.state == ca_disconnected && !(GameState->curstate == STATE_RUNFRAME && GameState->nextstate != STATE_RUNFRAME) ) if( cls.state == ca_disconnected && !(GameState->curstate == STATE_RUNFRAME && GameState->nextstate != STATE_RUNFRAME) )
@@ -381,18 +446,15 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
if( cls.key_dest == key_console ) if( cls.key_dest == key_console )
return; return;
if( !Host_IsDedicated() )
gl_clear.value = 0.0f;
if( is_background ) IN_MouseSavePos( ); if( is_background ) IN_MouseSavePos( );
cls.draw_changelevel = !is_background; cls.draw_changelevel = !is_background;
SCR_UpdateScreen(); SCR_UpdateScreen();
// set video_prepped after update screen, so engine can draw last remaining frame
cl.video_prepped = false;
cls.disable_screen = host.realtime; cls.disable_screen = host.realtime;
cl.background = is_background; // set right state before svc_serverdata is came cl.background = is_background; // set right state before svc_serverdata is came
if( !Host_IsDedicated() )
gl_clear.value = oldclear;
// SNDDMA_LockSound(); // SNDDMA_LockSound();
} }
@@ -413,7 +475,7 @@ void SCR_EndLoadingPlaque( void )
SCR_AddDirtyPoint SCR_AddDirtyPoint
================= =================
*/ */
void SCR_AddDirtyPoint( int x, int y ) static void SCR_AddDirtyPoint( int x, int y )
{ {
if( x < scr_dirty.x1 ) scr_dirty.x1 = x; if( x < scr_dirty.x1 ) scr_dirty.x1 = x;
if( x > scr_dirty.x2 ) scr_dirty.x2 = x; if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
@@ -442,7 +504,7 @@ void SCR_TileClear( void )
int i, top, bottom, left, right; int i, top, bottom, left, right;
dirty_t clear; dirty_t clear;
if( scr_viewsize.value >= 120 ) if( likely( scr_viewsize.value >= 120 ))
return; // full screen rendering return; // full screen rendering
// erase rect will be the union of the past three frames // erase rect will be the union of the past three frames
@@ -520,6 +582,8 @@ text to the screen.
*/ */
void SCR_UpdateScreen( void ) void SCR_UpdateScreen( void )
{ {
qboolean screen_redraw = true; // assume screen has been redrawn
if( !V_PreRender( )) return; if( !V_PreRender( )) return;
switch( cls.state ) switch( cls.state )
@@ -530,7 +594,7 @@ void SCR_UpdateScreen( void )
case ca_connecting: case ca_connecting:
case ca_connected: case ca_connected:
case ca_validate: case ca_validate:
SCR_DrawPlaque(); screen_redraw = SCR_DrawPlaque();
break; break;
case ca_active: case ca_active:
Con_RunConsole (); Con_RunConsole ();
@@ -540,10 +604,14 @@ void SCR_UpdateScreen( void )
SCR_DrawCinematic(); SCR_DrawCinematic();
break; break;
default: default:
Host_Error( "SCR_UpdateScreen: bad cls.state\n" ); Host_Error( "%s: bad cls.state\n", __func__ );
break; break;
} }
// during changelevel we might have a few frames when we have nothing to draw
// (assuming levelshots are off) and drawing 2d on top of nothing or cleared screen
// is ugly, specifically with Adreno and ImgTec GPUs
if( screen_redraw || !cls.changelevel || !cls.changedemo )
V_PostRender(); V_PostRender();
} }
@@ -570,15 +638,15 @@ void SCR_LoadCreditsFont( void )
"creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 ) "creditsfont_%s.fnt", Cvar_VariableString( "con_charset" )) > 0 )
{ {
if( FS_FileExists( charsetFnt, false )) if( FS_FileExists( charsetFnt, false ))
success = Con_LoadVariableWidthFont( charsetFnt, font, scale, kRenderTransAdd, TF_FONT ); success = Con_LoadVariableWidthFont( charsetFnt, font, scale, &hud_fontrender, TF_FONT );
} }
} }
if( !success ) if( !success )
success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, kRenderTransAdd, TF_FONT ); success = Con_LoadVariableWidthFont( "gfx/creditsfont.fnt", font, scale, &hud_fontrender, TF_FONT );
if( !success ) if( !success )
success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransAdd, TF_FONT ); success = Con_LoadFixedWidthFont( "gfx/conchars", font, scale, &hud_fontrender, TF_FONT );
// copy font size for client.dll // copy font size for client.dll
if( success ) if( success )
@@ -600,7 +668,7 @@ SCR_InstallParticlePalette
INTERNAL RESOURCE INTERNAL RESOURCE
================ ================
*/ */
void SCR_InstallParticlePalette( void ) static void SCR_InstallParticlePalette( void )
{ {
rgbdata_t *pic; rgbdata_t *pic;
int i; int i;
@@ -646,21 +714,21 @@ void SCR_RegisterTextures( void )
// register gfx.wad images // register gfx.wad images
if( FS_FileExists( "gfx/paused.lmp", false )) if( FS_FileExists( "gfx/paused.lmp", false ))
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE ); cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
else if( FS_FileExists( "gfx/pause.lmp", false )) else if( FS_FileExists( "gfx/pause.lmp", false ))
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE ); cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
if( FS_FileExists( "gfx/lambda.lmp", false )) if( FS_FileExists( "gfx/lambda.lmp", false ))
{ {
if( cl_allow_levelshots.value ) if( cl_allow_levelshots.value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE ); cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|TF_ALLOW_NEAREST );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE ); else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
} }
else if( FS_FileExists( "gfx/loading.lmp", false )) else if( FS_FileExists( "gfx/loading.lmp", false ))
{ {
if( cl_allow_levelshots.value ) if( cl_allow_levelshots.value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE ); cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE|TF_ALLOW_NEAREST );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE ); else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_ALLOW_NEAREST );
} }
cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP ); cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
@@ -673,7 +741,7 @@ SCR_SizeUp_f
Keybinding command Keybinding command
================= =================
*/ */
void SCR_SizeUp_f( void ) static void SCR_SizeUp_f( void )
{ {
Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 )); Cvar_SetValue( "viewsize", Q_min( scr_viewsize.value + 10, 120 ));
} }
@@ -686,7 +754,7 @@ SCR_SizeDown_f
Keybinding command Keybinding command
================= =================
*/ */
void SCR_SizeDown_f( void ) static void SCR_SizeDown_f( void )
{ {
Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 )); Cvar_SetValue( "viewsize", Q_max( scr_viewsize.value - 10, 30 ));
} }
@@ -750,6 +818,9 @@ void SCR_Init( void )
Cvar_RegisterVariable( &net_speeds ); Cvar_RegisterVariable( &net_speeds );
Cvar_RegisterVariable( &cl_showfps ); Cvar_RegisterVariable( &cl_showfps );
Cvar_RegisterVariable( &cl_showpos ); Cvar_RegisterVariable( &cl_showpos );
#ifdef _DEBUG
Cvar_RegisterVariable( &cl_showents );
#endif // NDEBUG
// register our commands // register our commands
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" ); Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );

File diff suppressed because it is too large Load Diff

View File

@@ -77,11 +77,9 @@ 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_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_PlayerSprites( int client, int modelIndex, int count, int size );
void R_Sprite_WallPuff( struct tempent_s *pTemp, float scale ); 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 ); void R_RicochetSound( const vec3_t pos );
struct dlight_s *CL_AllocDlight( int key ); struct dlight_s *CL_AllocDlight( int key );
struct dlight_s *CL_AllocElight( int key ); struct dlight_s *CL_AllocElight( int key );
void CL_UpdateFlashlight( cl_entity_t *pEnt );
void CL_AddEntityEffects( cl_entity_t *ent ); void CL_AddEntityEffects( cl_entity_t *ent );
void CL_AddModelEffects( cl_entity_t *ent ); void CL_AddModelEffects( cl_entity_t *ent );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags ); void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );

View File

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

View File

@@ -29,13 +29,13 @@ V_CalcViewRect
calc frame rectangle (Quake1 style) calc frame rectangle (Quake1 style)
=============== ===============
*/ */
void V_CalcViewRect( void ) static void V_CalcViewRect( void )
{ {
qboolean full = false; qboolean full = false;
int sb_lines; int sb_lines;
float size; float size;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE )) if( Host_IsQuakeCompatible( ))
{ {
// intermission is always full screen // intermission is always full screen
if( cl.intermission ) size = 120.0f; if( cl.intermission ) size = 120.0f;
@@ -88,7 +88,7 @@ void V_CalcViewRect( void )
V_SetupViewModel V_SetupViewModel
=============== ===============
*/ */
void V_SetupViewModel( void ) static void V_SetupViewModel( void )
{ {
cl_entity_t *view = &clgame.viewent; cl_entity_t *view = &clgame.viewent;
player_info_t *info = &cl.players[cl.playernum]; player_info_t *info = &cl.players[cl.playernum];
@@ -118,7 +118,7 @@ void V_SetupViewModel( void )
V_SetRefParams V_SetRefParams
=============== ===============
*/ */
void V_SetRefParams( ref_params_t *fd ) static void V_SetRefParams( ref_params_t *fd )
{ {
memset( fd, 0, sizeof( ref_params_t )); memset( fd, 0, sizeof( ref_params_t ));
@@ -144,7 +144,9 @@ void V_SetRefParams( ref_params_t *fd )
VectorCopy( cl.viewangles, fd->cl_viewangles ); VectorCopy( cl.viewangles, fd->cl_viewangles );
fd->health = cl.local.health; fd->health = cl.local.health;
VectorCopy( cl.crosshairangle, fd->crosshairangle ); VectorCopy( cl.crosshairangle, fd->crosshairangle );
if( Host_IsQuakeCompatible( ))
fd->viewsize = scr_viewsize.value; fd->viewsize = scr_viewsize.value;
else fd->viewsize = 120.0f;
VectorCopy( cl.punchangle, fd->punchangle ); VectorCopy( cl.punchangle, fd->punchangle );
fd->maxclients = cl.maxclients; fd->maxclients = cl.maxclients;
@@ -182,7 +184,7 @@ V_MergeOverviewRefdef
merge refdef with overview settings merge refdef with overview settings
=============== ===============
*/ */
void V_RefApplyOverview( ref_viewpass_t *rvp ) static void V_RefApplyOverview( ref_viewpass_t *rvp )
{ {
ref_overview_t *ov = &clgame.overView; ref_overview_t *ov = &clgame.overView;
float aspect; float aspect;
@@ -281,7 +283,7 @@ static void V_AdjustFov( float *fov_x, float *fov_y, float width, float height,
V_GetRefParams V_GetRefParams
============= =============
*/ */
void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp ) static void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
{ {
// part1: deniable updates // part1: deniable updates
VectorCopy( fd->simvel, cl.simvel ); VectorCopy( fd->simvel, cl.simvel );
@@ -341,12 +343,14 @@ qboolean V_PreRender( void )
{ {
if(( host.realtime - cls.disable_screen ) > cl_timeout.value ) if(( host.realtime - cls.disable_screen ) > cl_timeout.value )
{ {
Con_Reportf( "V_PreRender: loading plaque timed out\n" ); Con_Reportf( "%s: loading plaque timed out\n", __func__ );
cls.disable_screen = 0.0f; cls.disable_screen = 0.0f;
} }
return false; return false;
} }
V_CheckGamma();
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active )); ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
GL_UpdateSwapInterval( ); GL_UpdateSwapInterval( );
@@ -406,14 +410,14 @@ void V_RenderView( void )
#define NODE_INTERVAL_X(x) (x * 16.0f) #define NODE_INTERVAL_X(x) (x * 16.0f)
#define NODE_INTERVAL_Y(x) (x * 16.0f) #define NODE_INTERVAL_Y(x) (x * 16.0f)
void R_DrawLeafNode( float x, float y, float scale ) static void R_DrawLeafNode( float x, float y, float scale )
{ {
float downScale = scale * 0.25f;// * POINT_SIZE; float downScale = scale * 0.25f;// * POINT_SIZE;
ref.dllFuncs.R_DrawStretchPic( x - downScale * 0.5f, y - downScale * 0.5f, downScale, downScale, 0, 0, 1, 1, R_GetBuiltinTexture( REF_PARTICLE_TEXTURE ) ); ref.dllFuncs.R_DrawStretchPic( x - downScale * 0.5f, y - downScale * 0.5f, downScale, downScale, 0, 0, 1, 1, R_GetBuiltinTexture( REF_PARTICLE_TEXTURE ) );
} }
void R_DrawNodeConnection( float x, float y, float x2, float y2 ) static void R_DrawNodeConnection( float x, float y, float x2, float y2 )
{ {
ref.dllFuncs.Begin( TRI_LINES ); ref.dllFuncs.Begin( TRI_LINES );
ref.dllFuncs.Vertex3f( x, y, 0 ); ref.dllFuncs.Vertex3f( x, y, 0 );
@@ -421,7 +425,7 @@ void R_DrawNodeConnection( float x, float y, float x2, float y2 )
ref.dllFuncs.End( ); ref.dllFuncs.End( );
} }
void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf ) static void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
{ {
float downScale = scale * 0.8f; float downScale = scale * 0.8f;
@@ -468,7 +472,7 @@ void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes,
world.recursion_level--; world.recursion_level--;
} }
void R_ShowTree( void ) static void R_ShowTree( void )
{ {
float x = (float)((refState.width - (int)POINT_SIZE) >> 1); float x = (float)((refState.width - (int)POINT_SIZE) >> 1);
float y = NODE_INTERVAL_Y(1.0f); float y = NODE_INTERVAL_Y(1.0f);
@@ -504,7 +508,6 @@ V_PostRender
*/ */
void V_PostRender( void ) void V_PostRender( void )
{ {
static double oldtime;
qboolean draw_2d = false; qboolean draw_2d = false;
ref.dllFuncs.R_AllowFog( false ); ref.dllFuncs.R_AllowFog( false );
@@ -531,6 +534,7 @@ void V_PostRender( void )
SCR_RSpeeds(); SCR_RSpeeds();
SCR_NetSpeeds(); SCR_NetSpeeds();
SCR_DrawPos(); SCR_DrawPos();
SCR_DrawEnts();
SCR_DrawNetGraph(); SCR_DrawNetGraph();
SV_DrawOrthoTriangles(); SV_DrawOrthoTriangles();
CL_DrawDemoRecording(); CL_DrawDemoRecording();
@@ -549,5 +553,8 @@ void V_PostRender( void )
SCR_MakeScreenShot(); SCR_MakeScreenShot();
ref.dllFuncs.R_AllowFog( true ); ref.dllFuncs.R_AllowFog( true );
Platform_SetTimer( 0.0f );
ref.dllFuncs.R_EndFrame(); ref.dllFuncs.R_EndFrame();
V_CheckGammaEnd();
} }

View File

@@ -129,7 +129,6 @@ typedef struct
// misc local info // misc local info
qboolean repredicting; // repredicting in progress qboolean repredicting; // repredicting in progress
qboolean thirdperson;
qboolean apply_effects; // local player will not added but we should apply their effects: flashlight etc qboolean apply_effects; // local player will not added but we should apply their effects: flashlight etc
float idealpitch; float idealpitch;
int viewmodel; int viewmodel;
@@ -174,6 +173,26 @@ typedef struct
// at every server map change // at every server map change
typedef struct typedef struct
{ {
// ==== shared through RefAPI's ref_client_t ====
double time; // this is the time value that the client
// is rendering at. always <= cls.realtime
// a lerp point for other data
double oldtime; // previous cl.time, time-oldtime is used
// to decay light values and smooth step ups
int viewentity;
// server state information
int playernum;
int maxclients;
int nummodels;
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
qboolean paused;
vec3_t simorg; // predicted origin
// ==== shared through RefAPI's ref_client_t ===
int servercount; // server identification for prespawns int servercount; // server identification for prespawns
int validsequence; // this is the sequence number of the last good int validsequence; // this is the sequence number of the last good
// world snapshot/update we got. If this is 0, we can't // world snapshot/update we got. If this is 0, we can't
@@ -183,7 +202,6 @@ typedef struct
qboolean video_prepped; // false if on new level or new ref dll qboolean video_prepped; // false if on new level or new ref dll
qboolean audio_prepped; // false if on new level or new snd dll qboolean audio_prepped; // false if on new level or new snd dll
qboolean paused;
int delta_sequence; // acknowledged sequence number int delta_sequence; // acknowledged sequence number
@@ -205,17 +223,12 @@ typedef struct
runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds
local_state_t predicted_frames[MULTIPLAYER_BACKUP]; // local client state local_state_t predicted_frames[MULTIPLAYER_BACKUP]; // local client state
double time; // this is the time value that the client
// is rendering at. always <= cls.realtime
// a lerp point for other data
double oldtime; // previous cl.time, time-oldtime is used
// to decay light values and smooth step ups
double timedelta; // floating delta between two updates double timedelta; // floating delta between two updates
char serverinfo[MAX_SERVERINFO_STRING]; char serverinfo[MAX_SERVERINFO_STRING];
player_info_t players[MAX_CLIENTS]; // collected info about all other players include himself player_info_t players[MAX_CLIENTS]; // collected info about all other players include himself
double lastresourcecheck; double lastresourcecheck;
string downloadUrl; qboolean http_download;
event_state_t events; event_state_t events;
// predicting stuff but not only... // predicting stuff but not only...
@@ -223,7 +236,6 @@ typedef struct
// player final info // player final info
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
int viewentity;
vec3_t viewangles; vec3_t viewangles;
vec3_t viewheight; vec3_t viewheight;
vec3_t punchangle; vec3_t punchangle;
@@ -236,14 +248,9 @@ typedef struct
float addangletotal; float addangletotal;
float prevaddangletotal; float prevaddangletotal;
// predicted origin and velocity // predicted velocity
vec3_t simorg;
vec3_t simvel; vec3_t simvel;
// server state information
int playernum;
int maxclients;
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES]; entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
int instanced_baseline_count; int instanced_baseline_count;
@@ -251,8 +258,6 @@ typedef struct
char event_precache[MAX_EVENTS][MAX_QPATH]; char event_precache[MAX_EVENTS][MAX_QPATH];
char files_precache[MAX_CUSTOM][MAX_QPATH]; char files_precache[MAX_CUSTOM][MAX_QPATH];
lightstyle_t lightstyles[MAX_LIGHTSTYLES]; lightstyle_t lightstyles[MAX_LIGHTSTYLES];
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
int nummodels;
int numfiles; int numfiles;
consistency_t consistency_list[MAX_MODELS]; consistency_t consistency_list[MAX_MODELS];
@@ -270,6 +275,10 @@ typedef struct
model_t *worldmodel; // pointer to world model_t *worldmodel; // pointer to world
int lostpackets; // count lost packets and show dialog in menu int lostpackets; // count lost packets and show dialog in menu
double frametime_remainder;
uint worldmapCRC;
} client_t; } client_t;
/* /*
@@ -336,8 +345,7 @@ typedef struct
byte charWidths[256]; // scaled widths byte charWidths[256]; // scaled widths
int charHeight; // scaled height int charHeight; // scaled height
int type; // fixed width font or variable int type; // fixed width font or variable
int rendermode; // default rendermode convar_t *rendermode; // user-defined default rendermode
qboolean nearest; // nearest filtering enabled
qboolean valid; // all rectangles are valid qboolean valid; // all rectangles are valid
} cl_font_t; } cl_font_t;
@@ -486,7 +494,6 @@ typedef struct
net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more
efrag_t *free_efrags; // linked efrags
cl_entity_t viewent; // viewmodel cl_entity_t viewent; // viewmodel
qboolean client_dll_uses_sdl; qboolean client_dll_uses_sdl;
@@ -503,8 +510,9 @@ typedef struct
player_info_t playerinfo; // local playerinfo player_info_t playerinfo; // local playerinfo
gameui_draw_t ds; // draw2d stuff (menu images) gameui_draw_t ds; // draw2d stuff (menu images)
GAMEINFO gameInfo; // current gameInfo gameinfo2_t gameInfo; // current gameInfo
GAMEINFO *modsInfo[MAX_MODS]; // simplified gameInfo for MainUI gameinfo2_t *modsInfo; // simplified gameInfo for MainUI, allocated by demand
GAMEINFO **oldModsInfo; // simplified gameInfo for older MainUI, allocated by demand
ui_globalvars_t *globals; ui_globalvars_t *globals;
@@ -513,7 +521,7 @@ typedef struct
int logo_yres; int logo_yres;
float logo_length; float logo_length;
qboolean use_text_api; qboolean use_extended_api;
} gameui_static_t; } gameui_static_t;
typedef struct typedef struct
@@ -534,12 +542,8 @@ typedef struct
poolhandle_t mempool; // client premamnent pool: edicts etc poolhandle_t mempool; // client premamnent pool: edicts etc
netadr_t hltv_listen_address;
int signon; // 0 to SIGNONS, for the signon sequence. int signon; // 0 to SIGNONS, for the signon sequence.
int quakePort; // a 16 bit value that allows quake servers
// to work around address translating routers
// g-cont. this port allow many copies of engine in multiplayer game
// connection information // connection information
char servername[MAX_QPATH]; // name of server from original connect char servername[MAX_QPATH]; // name of server from original connect
double connect_time; // for connection retransmits double connect_time; // for connection retransmits
@@ -623,12 +627,14 @@ typedef struct
char internetservers_query[512]; // cached query char internetservers_query[512]; // cached query
uint32_t internetservers_query_len; uint32_t internetservers_query_len;
// legacy mode support // multiprotocol support
qboolean legacymode; // one-way 48 protocol compatibility connprotocol_t legacymode;
netadr_t legacyserver;
int extensions; int extensions;
netadr_t serveradr; netadr_t serveradr;
// do we accept utf8 as input
qboolean accept_utf8;
} client_static_t; } client_static_t;
#ifdef __cplusplus #ifdef __cplusplus
@@ -647,15 +653,13 @@ extern gameui_static_t gameui;
// //
// cvars // cvars
// //
extern convar_t showpause;
extern convar_t mp_decals; extern convar_t mp_decals;
extern convar_t cl_logofile; extern convar_t cl_logomaxdim;
extern convar_t cl_logocolor;
extern convar_t cl_allow_download; extern convar_t cl_allow_download;
extern convar_t cl_allow_upload;
extern convar_t cl_download_ingame; extern convar_t cl_download_ingame;
extern convar_t cl_nopred; extern convar_t cl_nopred;
extern convar_t cl_timeout; extern convar_t cl_timeout;
extern convar_t cl_nodelta;
extern convar_t cl_interp; extern convar_t cl_interp;
extern convar_t cl_nointerp; extern convar_t cl_nointerp;
extern convar_t cl_showerror; extern convar_t cl_showerror;
@@ -668,19 +672,20 @@ extern convar_t cl_updaterate;
extern convar_t cl_solid_players; extern convar_t cl_solid_players;
extern convar_t cl_idealpitchscale; extern convar_t cl_idealpitchscale;
extern convar_t cl_allow_levelshots; extern convar_t cl_allow_levelshots;
extern convar_t cl_lightstyle_lerping;
extern convar_t cl_draw_particles; extern convar_t cl_draw_particles;
extern convar_t cl_draw_tracers; extern convar_t cl_draw_tracers;
extern convar_t cl_levelshot_name; extern convar_t cl_levelshot_name;
extern convar_t cl_draw_beams; extern convar_t cl_draw_beams;
extern convar_t cl_clockreset; extern convar_t cl_clockreset;
extern convar_t cl_fixtimerate;
extern convar_t hud_fontscale; extern convar_t hud_fontscale;
extern convar_t hud_fontrender;
extern convar_t hud_scale; extern convar_t hud_scale;
extern convar_t hud_scale_minimal_width;
extern convar_t r_showtextures; extern convar_t r_showtextures;
extern convar_t cl_bmodelinterp; extern convar_t cl_bmodelinterp;
extern convar_t cl_lw; // local weapons extern convar_t cl_lw; // local weapons
extern convar_t cl_charset; extern convar_t cl_charset;
extern convar_t cl_trace_stufftext;
extern convar_t cl_trace_messages; extern convar_t cl_trace_messages;
extern convar_t cl_trace_events; extern convar_t cl_trace_events;
extern convar_t hud_utf8; extern convar_t hud_utf8;
@@ -694,11 +699,11 @@ extern convar_t rate;
extern convar_t m_ignore; extern convar_t m_ignore;
extern convar_t r_showtree; extern convar_t r_showtree;
extern convar_t ui_renderworld; extern convar_t ui_renderworld;
extern convar_t cl_fixmodelinterpolationartifacts;
//============================================================================= //=============================================================================
void CL_SetLightstyle( int style, const char* s, float f ); void CL_SetLightstyle( int style, const char* s, float f );
void CL_RunLightStyles( void );
void CL_DecayLights( void ); void CL_DecayLights( void );
dlight_t *CL_GetDynamicLight( int number ); dlight_t *CL_GetDynamicLight( int number );
dlight_t *CL_GetEntityLight( int number ); dlight_t *CL_GetEntityLight( int number );
@@ -709,12 +714,8 @@ dlight_t *CL_GetEntityLight( int number );
// cl_cmds.c // cl_cmds.c
// //
void CL_Quit_f( void ); void CL_Quit_f( void );
void CL_ScreenShot_f( void ); void CL_GenericShot_f( void );
void CL_SnapShot_f( void );
void CL_PlayCDTrack_f( void ); void CL_PlayCDTrack_f( void );
void CL_EnvShot_f( void );
void CL_SkyShot_f( void );
void CL_SaveShot_f( void );
void CL_LevelShot_f( void ); void CL_LevelShot_f( void );
void CL_SetSky_f( void ); void CL_SetSky_f( void );
void SCR_Viewpos_f( void ); void SCR_Viewpos_f( void );
@@ -735,8 +736,6 @@ void CL_ClearResourceLists( void );
void CL_Parse_Debug( qboolean enable ); void CL_Parse_Debug( qboolean enable );
void CL_Parse_RecordCommand( int cmd, int startoffset ); void CL_Parse_RecordCommand( int cmd, int startoffset );
void CL_ResetFrame( frame_t *frame ); void CL_ResetFrame( frame_t *frame );
void CL_WriteMessageHistory( void );
const char *CL_MsgInfo( int cmd );
// //
// cl_efx.c // cl_efx.c
@@ -747,7 +746,6 @@ void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel );
// cl_main.c // cl_main.c
// //
void CL_Init( void ); void CL_Init( void );
void CL_SendCommand( void );
void CL_Disconnect_f( void ); void CL_Disconnect_f( void );
void CL_ProcessFile( qboolean successfully_received, const char *filename ); void CL_ProcessFile( qboolean successfully_received, const char *filename );
void CL_WriteUsercmd( sizebuf_t *msg, int from, int to ); void CL_WriteUsercmd( sizebuf_t *msg, int from, int to );
@@ -756,8 +754,7 @@ qboolean CL_PrecacheResources( void );
void CL_SetupOverviewParams( void ); void CL_SetupOverviewParams( void );
void CL_UpdateFrameLerp( void ); void CL_UpdateFrameLerp( void );
int CL_IsDevOverviewMode( void ); int CL_IsDevOverviewMode( void );
void CL_PingServers_f( void ); void CL_SignonReply( connprotocol_t proto );
void CL_SignonReply( void );
void CL_ClearState( void ); void CL_ClearState( void );
// //
@@ -774,8 +771,6 @@ void CL_CheckStartupDemos( void );
void CL_WriteDemoJumpTime( void ); void CL_WriteDemoJumpTime( void );
void CL_CloseDemoHeader( void ); void CL_CloseDemoHeader( void );
void CL_DemoCompleted( void ); void CL_DemoCompleted( void );
void CL_StopPlayback( void );
void CL_StopRecord( void );
void CL_PlayDemo_f( void ); void CL_PlayDemo_f( void );
void CL_TimeDemo_f( void ); void CL_TimeDemo_f( void );
void CL_StartDemos_f( void ); void CL_StartDemos_f( void );
@@ -783,19 +778,18 @@ void CL_Demos_f( void );
void CL_DeleteDemo_f( void ); void CL_DeleteDemo_f( void );
void CL_Record_f( void ); void CL_Record_f( void );
void CL_Stop_f( void ); void CL_Stop_f( void );
void CL_ListDemo_f( void );
int CL_GetDemoComment( const char *demoname, char *comment );
// //
// cl_events.c // cl_events.c
// //
void CL_ParseEvent( sizebuf_t *msg ); void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseReliableEvent( sizebuf_t *msg ); void CL_ParseReliableEvent( sizebuf_t *msg, connprotocol_t proto );
void CL_SetEventIndex( const char *szEvName, int ev_index ); void CL_SetEventIndex( const char *szEvName, int ev_index );
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args );
void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin, void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func ); void CL_RegisterEvent( int lastnum, const char *szEvName, pfnEventHook func );
void CL_BatchResourceRequest( qboolean initialize );
int CL_EstimateNeededResources( void );
void CL_ResetEvent( event_info_t *ei ); void CL_ResetEvent( event_info_t *ei );
word CL_EventIndex( const char *name ); word CL_EventIndex( const char *name );
void CL_FireEvents( void ); void CL_FireEvents( void );
@@ -804,9 +798,10 @@ void CL_FireEvents( void );
// cl_font.c // cl_font.c
// //
qboolean CL_FixedFont( cl_font_t *font ); qboolean CL_FixedFont( cl_font_t *font );
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags ); qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, int rendermode, uint texFlags ); qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
void CL_FreeFont( cl_font_t *font ); void CL_FreeFont( cl_font_t *font );
void CL_SetFontRendermode( cl_font_t *font );
int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags ); int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags );
int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *font, int flags ); int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *font, int flags );
void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height ); void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height );
@@ -819,10 +814,7 @@ int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags,
// //
void CL_UnloadProgs( void ); void CL_UnloadProgs( void );
qboolean CL_LoadProgs( const char *name ); qboolean CL_LoadProgs( const char *name );
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize ); void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize );
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
void CL_ParseTextMessage( sizebuf_t *msg );
void CL_DrawHUD( int state ); void CL_DrawHUD( int state );
void CL_InitEdicts( int maxclients ); void CL_InitEdicts( int maxclients );
void CL_FreeEdicts( void ); void CL_FreeEdicts( void );
@@ -839,33 +831,30 @@ model_t *CL_LoadClientSprite( const char *filename );
model_t *CL_LoadModel( const char *modelname, int *index ); model_t *CL_LoadModel( const char *modelname, int *index );
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags ); HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags );
void SPR_AdjustSize( float *x, float *y, float *w, float *h ); void SPR_AdjustSize( float *x, float *y, float *w, float *h );
void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 );
int CL_GetScreenInfo( SCREENINFO *pscrinfo ); int CL_GetScreenInfo( SCREENINFO *pscrinfo );
void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a );
pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ); pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );
const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend ); const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend );
int PM_CL_PointContents( const float *p, int *truecontents ); int PM_CL_PointContents( const float *p, int *truecontents );
void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input
cl_entity_t* CL_GetViewModel( void );
physent_t *pfnGetPhysent( int idx ); physent_t *pfnGetPhysent( int idx );
struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend ); struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend );
movevars_t *pfnGetMoveVars( void ); movevars_t *pfnGetMoveVars( void );
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height ); void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
void CL_DisableScissor( scissor_state_t *scissor ); void CL_DisableScissor( scissor_state_t *scissor );
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 ); qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
struct cl_entity_s *CL_GetEntityByIndex( int index );
_inline cl_entity_t *CL_EDICT_NUM( int n ) _inline cl_entity_t *CL_EDICT_NUM( int n )
{ {
if( !clgame.entities ) if( !clgame.entities )
{ {
Host_Error( "CL_EDICT_NUM: clgame.entities is NULL\n"); Host_Error( "%s: clgame.entities is NULL\n", __func__ );
return NULL; return NULL;
} }
if(( n >= 0 ) && ( n < clgame.maxEntities )) if(( n >= 0 ) && ( n < clgame.maxEntities ))
return clgame.entities + n; return clgame.entities + n;
Host_Error( "CL_EDICT_NUM: bad number %i\n", n ); Host_Error( "%s: bad number %i\n", __func__, n );
return NULL; return NULL;
} }
@@ -873,20 +862,21 @@ _inline cl_entity_t *CL_EDICT_NUM( int n )
// cl_parse.c // cl_parse.c
// //
void CL_ParseSetAngle( sizebuf_t *msg ); void CL_ParseSetAngle( sizebuf_t *msg );
void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ); void CL_ParseServerData( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseLightStyle( sizebuf_t *msg ); void CL_ParseLightStyle( sizebuf_t *msg, connprotocol_t proto );
void CL_UpdateUserinfo( sizebuf_t *msg, qboolean legacy ); void CL_UpdateUserinfo( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseResource( sizebuf_t *msg ); 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_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_ParseRestoreSoundPacket( sizebuf_t *msg );
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy ); void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseSignon( sizebuf_t *msg ); void CL_ParseSignon( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseRestore( sizebuf_t *msg ); void CL_ParseRestore( sizebuf_t *msg );
void CL_ParseStaticDecal( sizebuf_t *msg ); void CL_ParseStaticDecal( sizebuf_t *msg );
void CL_ParseAddAngle( 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_ParseMovevars( sizebuf_t *msg );
void CL_ParseResourceRequest( sizebuf_t *msg ); void CL_ParseResourceRequest( sizebuf_t *msg );
void CL_ParseCustomization( sizebuf_t *msg ); void CL_ParseCustomization( sizebuf_t *msg );
@@ -895,30 +885,42 @@ void CL_ParseSoundFade( sizebuf_t *msg );
void CL_ParseFileTransferFailed( sizebuf_t *msg ); void CL_ParseFileTransferFailed( sizebuf_t *msg );
void CL_ParseHLTV( sizebuf_t *msg ); void CL_ParseHLTV( sizebuf_t *msg );
void CL_ParseDirector( 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_ParseResLocation( sizebuf_t *msg );
void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext ); void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto );
void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ); 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_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
qboolean CL_RequestMissingResources( void ); qboolean CL_RequestMissingResources( void );
void CL_RegisterResources ( sizebuf_t *msg ); void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto );
void CL_ParseViewEntity( sizebuf_t *msg ); void CL_ParseViewEntity( sizebuf_t *msg );
void CL_ParseServerTime( sizebuf_t *msg ); 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 );
// //
// cl_parse_48.c // cl_parse_48.c
// //
void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message ); void CL_ParseLegacyServerMessage( sizebuf_t *msg );
void CL_LegacyPrecache_f( void ); void CL_LegacyPrecache_f( void );
//
// cl_parse_gs.c
//
void CL_ParseGoldSrcServerMessage( sizebuf_t *msg );
// //
// cl_scrn.c // cl_scrn.c
// //
void SCR_VidInit( void ); void SCR_VidInit( void );
void SCR_TileClear( void ); void SCR_TileClear( void );
void SCR_DirtyScreen( void ); void SCR_DirtyScreen( void );
void SCR_AddDirtyPoint( int x, int y );
void SCR_InstallParticlePalette( void );
void SCR_EndLoadingPlaque( void ); void SCR_EndLoadingPlaque( void );
void SCR_RegisterTextures( void ); void SCR_RegisterTextures( void );
void SCR_LoadCreditsFont( void ); void SCR_LoadCreditsFont( void );
@@ -928,6 +930,7 @@ void SCR_NetSpeeds( void );
void SCR_RSpeeds( void ); void SCR_RSpeeds( void );
void SCR_DrawFPS( int height ); void SCR_DrawFPS( int height );
void SCR_DrawPos( void ); void SCR_DrawPos( void );
void SCR_DrawEnts( void );
// //
// cl_netgraph.c // cl_netgraph.c
@@ -953,52 +956,46 @@ void CL_SetSolidPlayers( int playernum );
void CL_InitClientMove( void ); void CL_InitClientMove( void );
void CL_PredictMovement( qboolean repredicting ); void CL_PredictMovement( qboolean repredicting );
void CL_CheckPredictionError( void ); void CL_CheckPredictionError( void );
qboolean CL_IsPredicted( void );
int CL_TruePointContents( const vec3_t p );
int CL_WaterEntity( const float *rgflPos ); int CL_WaterEntity( const float *rgflPos );
cl_entity_t *CL_GetWaterEntity( const float *rgflPos ); cl_entity_t *CL_GetWaterEntity( const float *rgflPos );
int CL_TestLine( const vec3_t start, const vec3_t end, int flags );
pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags ); pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags );
pmtrace_t CL_TraceLine( vec3_t start, vec3_t end, int flags ); pmtrace_t CL_TraceLine( vec3_t start, vec3_t end, int flags );
void CL_PushTraceBounds( int hullnum, const float *mins, const float *maxs );
void CL_PopTraceBounds( void );
void CL_MoveSpectatorCamera( void ); void CL_MoveSpectatorCamera( void );
void CL_SetLastUpdate( void ); void CL_SetLastUpdate( void );
void CL_RedoPrediction( void ); void CL_RedoPrediction( void );
void CL_PushPMStates( void ); void CL_PushPMStates( void );
void CL_PopPMStates( void ); void CL_PopPMStates( void );
void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient ); void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient );
void CL_SetIdealPitch( void );
// //
// cl_qparse.c // cl_qparse.c
// //
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message ); void CL_ParseQuakeMessage( sizebuf_t *msg );
// //
// cl_frame.c // cl_frame.c
// //
struct channel_s; struct channel_s;
struct rawchan_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 ); qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType );
void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset ); void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset );
qboolean CL_GetEntitySpatialization( struct channel_s *ch ); qboolean CL_GetEntitySpatialization( struct channel_s *ch );
qboolean CL_GetMovieSpatialization( struct rawchan_s *ch ); qboolean CL_GetMovieSpatialization( struct rawchan_s *ch );
void CL_ProcessPlayerState( int playerindex, entity_state_t *state );
void CL_ComputePlayerOrigin( cl_entity_t *clent ); void CL_ComputePlayerOrigin( cl_entity_t *clent );
void CL_ProcessPacket( frame_t *frame ); void CL_ProcessPacket( frame_t *frame );
void CL_MoveThirdpersonCamera( void ); void CL_MoveThirdpersonCamera( void );
qboolean CL_IsPlayerIndex( int idx ); qboolean CL_IsPlayerIndex( int idx );
void CL_SetIdealPitch( void );
void CL_EmitEntities( void ); void CL_EmitEntities( void );
// //
// cl_remap.c // cl_remap.c
// //
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e ); remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor ); qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom );
void CL_FreeRemapInfo( remap_info_t *info );
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
void CL_ClearAllRemaps( void ); void CL_ClearAllRemaps( void );
// //
@@ -1015,6 +1012,7 @@ const ref_overview_t *GL_GetOverviewParms( void );
// //
void R_StoreEfrags( efrag_t **ppefrag, int framecount ); void R_StoreEfrags( efrag_t **ppefrag, int framecount );
void R_AddEfrags( cl_entity_t *ent ); void R_AddEfrags( cl_entity_t *ent );
// //
// cl_tent.c // cl_tent.c
// //
@@ -1025,7 +1023,6 @@ void CL_ClearEfrags( void );
void CL_TestLights( void ); void CL_TestLights( void );
void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale ); void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags ); void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
void CL_PlayerDecal( int playerIndex, int textureIndex, int entityIndex, float *pos );
void R_FreeDeadParticles( struct particle_s **ppparticles ); void R_FreeDeadParticles( struct particle_s **ppparticles );
void CL_AddClientResource( const char *filename, int type ); void CL_AddClientResource( const char *filename, int type );
void CL_AddClientResources( void ); void CL_AddClientResources( void );
@@ -1033,7 +1030,6 @@ void CL_InitParticles( void );
void CL_ClearParticles( void ); void CL_ClearParticles( void );
void CL_FreeParticles( void ); void CL_FreeParticles( void );
void CL_InitTempEnts( void ); void CL_InitTempEnts( void );
void CL_ClearTempEnts( void );
void CL_FreeTempEnts( void ); void CL_FreeTempEnts( void );
void CL_TempEntUpdate( void ); void CL_TempEntUpdate( void );
void CL_InitViewBeams( void ); void CL_InitViewBeams( void );
@@ -1047,7 +1043,6 @@ void CL_ReadPointFile_f( void );
void CL_DrawEFX( float time, qboolean fTrans ); void CL_DrawEFX( float time, qboolean fTrans );
void CL_ThinkParticle( double frametime, particle_t *p ); void CL_ThinkParticle( double frametime, particle_t *p );
void CL_ReadLineFile_f( void ); void CL_ReadLineFile_f( void );
void CL_RunLightStyles( void );
// //
// console.c // console.c
@@ -1067,27 +1062,22 @@ int Con_UtfProcessChar( int in );
int Con_UtfProcessCharForce( int in ); int Con_UtfProcessCharForce( int in );
int Con_UtfMoveLeft( char *str, int pos ); int Con_UtfMoveLeft( char *str, int pos );
int Con_UtfMoveRight( char *str, int pos, int length ); int Con_UtfMoveRight( char *str, int pos, int length );
void Con_DefaultColor( int r, int g, int b ); void Con_DefaultColor( int r, int g, int b, qboolean gameui );
void Con_InvalidateFonts( void );
cl_font_t *Con_GetCurFont( void ); cl_font_t *Con_GetCurFont( void );
cl_font_t *Con_GetFont( int num ); cl_font_t *Con_GetFont( int num );
void Con_DrawCharacterLen( int number, int *width, int *height );
int Con_DrawString( int x, int y, const char *string, rgba_t setColor ); // legacy, use cl_font.c int Con_DrawString( int x, int y, const char *string, rgba_t setColor ); // legacy, use cl_font.c
void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c
void Con_CharEvent( int key ); void Con_CharEvent( int key );
void Con_RestoreFont( void );
void Key_Console( int key ); void Key_Console( int key );
void Key_Message( int key ); void Key_Message( int key );
void Con_FastClose( void ); void Con_FastClose( void );
void Con_Bottom( void ); void Con_Bottom( void );
void Con_Top( void );
void Con_PageDown( int lines ); void Con_PageDown( int lines );
void Con_PageUp( int lines ); void Con_PageUp( int lines );
// //
// s_main.c // s_main.c
// //
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data );
void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime ); void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime );
void S_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath ); void S_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath );
void S_StopBackgroundTrack( void ); void S_StopBackgroundTrack( void );
@@ -1125,7 +1115,7 @@ qboolean UI_MouseInRect( void );
qboolean UI_IsVisible( void ); qboolean UI_IsVisible( void );
void UI_ResetPing( void ); void UI_ResetPing( void );
void UI_ShowUpdateDialog( qboolean preferStore ); void UI_ShowUpdateDialog( qboolean preferStore );
void UI_ShowMessageBox( const char *text ); qboolean UI_ShowMessageBox( const char *text );
void UI_AddTouchButtonToList( const char *name, const char *texture, const char *command, unsigned char *color, int flags ); void UI_AddTouchButtonToList( const char *name, const char *texture, const char *command, unsigned char *color, int flags );
void UI_ConnectionProgress_Disconnect( void ); void UI_ConnectionProgress_Disconnect( void );
void UI_ConnectionProgress_Download( const char *pszFileName, const char *pszServerName, const char *pszServerPath, int iCurrent, int iTotal, const char *comment ); void UI_ConnectionProgress_Download( const char *pszFileName, const char *pszServerName, const char *pszServerPath, int iCurrent, int iTotal, const char *comment );
@@ -1134,11 +1124,6 @@ void UI_ConnectionProgress_Precache( void );
void UI_ConnectionProgress_Connect( const char *server ); void UI_ConnectionProgress_Connect( const char *server );
void UI_ConnectionProgress_ChangeLevel( void ); void UI_ConnectionProgress_ChangeLevel( void );
void UI_ConnectionProgress_ParseServerInfo( const char *server ); void UI_ConnectionProgress_ParseServerInfo( const char *server );
void pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a );
void pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc );
void pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc );
void pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc );
void pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc );
// //
// cl_mobile.c // cl_mobile.c
@@ -1184,5 +1169,7 @@ int Key_ToUpper( int key );
void OSK_Draw( void ); void OSK_Draw( void );
extern rgba_t g_color_table[8]; extern rgba_t g_color_table[8];
extern triangleapi_t gTriApi;
extern net_api_t gNetApi;
#endif//CLIENT_H #endif//CLIENT_H

View File

@@ -21,18 +21,20 @@ GNU General Public License for more details.
#include "qfont.h" #include "qfont.h"
#include "wadfile.h" #include "wadfile.h"
#include "input.h" #include "input.h"
#include "utflib.h"
static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" ); static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" );
static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" ); static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" );
CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" ); CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
static CVAR_DEFINE_AUTO( con_fontrender, "2", FCVAR_ARCHIVE, "console font render mode (0: additive, 1: holes, 2: trans)" );
static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" ); static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" ); static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" ); static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" ); static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" );
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
static int g_codepage = 0; static int g_codepage = 0;
static qboolean g_utf8 = false;
static qboolean g_messagemode_privileged = true; static qboolean g_messagemode_privileged = true;
@@ -139,8 +141,9 @@ typedef struct
static console_t con; static console_t con;
void Con_ClearField( field_t *edit ); static void Con_ClearField( field_t *edit );
void Field_CharEvent( field_t *edit, int ch ); static void Field_CharEvent( field_t *edit, int ch );
static void Con_InvalidateFonts( void );
static void Con_LoadHistory( con_history_t *self ); static void Con_LoadHistory( con_history_t *self );
static void Con_SaveHistory( con_history_t *self ); static void Con_SaveHistory( con_history_t *self );
@@ -150,7 +153,7 @@ static void Con_SaveHistory( con_history_t *self );
Con_Clear_f Con_Clear_f
================ ================
*/ */
void Con_Clear_f( void ) static void Con_Clear_f( void )
{ {
con.lines_count = 0; con.lines_count = 0;
con.backscroll = 0; // go to end con.backscroll = 0; // go to end
@@ -174,10 +177,10 @@ static void Con_SetColor( void )
switch( num ) switch( num )
{ {
case 1: case 1:
Con_DefaultColor( r, r, r ); Con_DefaultColor( r, r, r, false );
break; break;
case 3: case 3:
Con_DefaultColor( r, g, b ); Con_DefaultColor( r, g, b, false );
break; break;
default: default:
Cvar_DirectSet( &con_color, con_color.def_string ); Cvar_DirectSet( &con_color, con_color.def_string );
@@ -205,7 +208,7 @@ void Con_ClearNotify( void )
Con_ClearTyping Con_ClearTyping
================ ================
*/ */
void Con_ClearTyping( void ) static void Con_ClearTyping( void )
{ {
Con_ClearField( &con.input ); Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth; con.input.widthInChars = con.linewidth;
@@ -218,7 +221,7 @@ void Con_ClearTyping( void )
Con_MessageMode_f Con_MessageMode_f
================ ================
*/ */
void Con_MessageMode_f( void ) static void Con_MessageMode_f( void )
{ {
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged(); g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
@@ -234,7 +237,7 @@ void Con_MessageMode_f( void )
Con_MessageMode2_f Con_MessageMode2_f
================ ================
*/ */
void Con_MessageMode2_f( void ) static void Con_MessageMode2_f( void )
{ {
g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged(); g_messagemode_privileged = Cmd_CurrentCommandIsPrivileged();
@@ -279,7 +282,7 @@ void Con_ToggleConsole_f( void )
Con_SetTimes_f Con_SetTimes_f
================ ================
*/ */
void Con_SetTimes_f( void ) static void Con_SetTimes_f( void )
{ {
int newtimes; int newtimes;
@@ -302,7 +305,7 @@ Notifies the console code about the current time
went backwards) went backwards)
================ ================
*/ */
void Con_FixTimes( void ) static void Con_FixTimes( void )
{ {
double diff; double diff;
int i; int i;
@@ -323,7 +326,7 @@ Con_DeleteLine
Deletes the first line from the console history. Deletes the first line from the console history.
================ ================
*/ */
void Con_DeleteLine( void ) static void Con_DeleteLine( void )
{ {
if( con.lines_count == 0 ) if( con.lines_count == 0 )
return; return;
@@ -338,7 +341,7 @@ Con_DeleteLastLine
Deletes the last line from the console history. Deletes the last line from the console history.
================ ================
*/ */
void Con_DeleteLastLine( void ) static void Con_DeleteLastLine( void )
{ {
if( con.lines_count == 0 ) if( con.lines_count == 0 )
return; return;
@@ -397,7 +400,7 @@ Con_AddLine
Appends a given string as a new line to the console. Appends a given string as a new line to the console.
================ ================
*/ */
void Con_AddLine( const char *line, int length, qboolean newline ) static void Con_AddLine( const char *line, int length, qboolean newline )
{ {
char *putpos; char *putpos;
con_lineinfo_t *p; con_lineinfo_t *p;
@@ -443,7 +446,7 @@ Con_CheckResize
If the line width has changed, reformat the buffer. If the line width has changed, reformat the buffer.
================ ================
*/ */
void Con_CheckResize( void ) static void Con_CheckResize( void )
{ {
int charWidth = 8; int charWidth = 8;
int i, width; int i, width;
@@ -492,7 +495,7 @@ void Con_PageDown( int lines )
Con_Top Con_Top
================ ================
*/ */
void Con_Top( void ) static void Con_Top( void )
{ {
con.backscroll = CON_MAXLINES; con.backscroll = CON_MAXLINES;
} }
@@ -543,10 +546,9 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
if( font->valid ) if( font->valid )
return; // already loaded return; // already loaded
// loading conchars if( con_oldfont.value )
if( Sys_CheckParm( "-oldfont" ))
{ {
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST ); success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
} }
else else
{ {
@@ -559,14 +561,14 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
if( Q_snprintf( path, sizeof( path ), if( Q_snprintf( path, sizeof( path ),
"font%i_%s.fnt", fontNumber, Cvar_VariableString( "con_charset" )) > 0 ) "font%i_%s.fnt", fontNumber, Cvar_VariableString( "con_charset" )) > 0 )
{ {
success = Con_LoadVariableWidthFont( path, font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST ); success = Con_LoadVariableWidthFont( path, font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
} }
} }
if( !success ) if( !success )
{ {
Q_snprintf( path, sizeof( path ), "fonts/font%i", fontNumber ); Q_snprintf( path, sizeof( path ), "fonts/font%i", fontNumber );
success = Con_LoadVariableWidthFont( path, font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST ); success = Con_LoadVariableWidthFont( path, font, scale, &con_fontrender, TF_FONT|TF_NEAREST );
} }
} }
@@ -574,7 +576,7 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
{ {
// quake fixed font as fallback // quake fixed font as fallback
// keep source to print directly into conback image // keep source to print directly into conback image
if( !Con_LoadFixedWidthFont( "gfx/conchars", font, scale, kRenderTransTexture, TF_FONT|TF_KEEP_SOURCE )) if( !Con_LoadFixedWidthFont( "gfx/conchars", font, scale, &con_fontrender, TF_FONT|TF_NEAREST|TF_KEEP_SOURCE ))
Con_DPrintf( S_ERROR "failed to load console font\n" ); Con_DPrintf( S_ERROR "failed to load console font\n" );
} }
} }
@@ -608,19 +610,6 @@ static void Con_LoadConchars( void )
con.curFont = &con.chars[fontSize]; con.curFont = &con.chars[fontSize];
} }
// CP1251 table
int table_cp1251[64] = {
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x007F, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457
};
/* /*
============================ ============================
Con_UtfProcessChar Con_UtfProcessChar
@@ -630,84 +619,28 @@ Convert utf char to current font's single-byte encoding
*/ */
int Con_UtfProcessCharForce( int in ) int Con_UtfProcessCharForce( int in )
{ {
static int m = -1, k = 0; //multibyte state // TODO: get rid of global state where possible
static int uc = 0; //unicode char static utfstate_t state = { 0 };
if( !in ) int ch = Q_DecodeUTF8( &state, in );
{
m = -1;
k = 0;
uc = 0;
return 0;
}
// Get character length
if(m == -1)
{
uc = 0;
if( in >= 0xF8 )
return 0;
else if( in >= 0xF0 )
uc = in & 0x07, m = 3;
else if( in >= 0xE0 )
uc = in & 0x0F, m = 2;
else if( in >= 0xC0 )
uc = in & 0x1F, m = 1;
else if( in <= 0x7F)
return in; //ascii
// return 0 if we need more chars to decode one
k=0;
return 0;
}
// get more chars
else if( k <= m )
{
uc <<= 6;
uc += in & 0x3F;
k++;
}
if( in > 0xBF || m < 0 )
{
m = -1;
return 0;
}
if( k == m )
{
k = m = -1;
if( g_codepage == 1251 ) if( g_codepage == 1251 )
{ return Q_UnicodeToCP1251( ch );
// cp1251 now if( g_codepage == 1252 )
if( uc >= 0x0410 && uc <= 0x042F ) return Q_UnicodeToCP1252( ch );
return uc - 0x410 + 0xC0;
if( uc >= 0x0430 && uc <= 0x044F )
return uc - 0x430 + 0xE0;
else
{
int i;
for( i = 0; i < 64; i++ )
if( table_cp1251[i] == uc )
return i + 0x80;
}
}
else if( g_codepage == 1252 )
{
if( uc < 255 )
return uc;
}
// not implemented yet return '?'; // not implemented yet
return '?';
}
return 0;
} }
int GAME_EXPORT Con_UtfProcessChar( int in ) int GAME_EXPORT Con_UtfProcessChar( int in )
{ {
if( !g_utf8 ) if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return in; return in;
else
// otherwise, decode it and convert to selected codepage
return Con_UtfProcessCharForce( in ); return Con_UtfProcessCharForce( in );
} }
/* /*
================= =================
Con_UtfMoveLeft Con_UtfMoveLeft
@@ -717,16 +650,22 @@ get position of previous printful char
*/ */
int Con_UtfMoveLeft( char *str, int pos ) int Con_UtfMoveLeft( char *str, int pos )
{ {
int i, k = 0; utfstate_t state = { 0 };
// int j; int k = 0;
if( !g_utf8 ) int i;
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return pos - 1; return pos - 1;
Con_UtfProcessChar( 0 );
if(pos == 1) return 0; if( pos == 1 )
return 0;
for( i = 0; i < pos - 1; i++ ) for( i = 0; i < pos - 1; i++ )
if( Con_UtfProcessChar( (unsigned char)str[i] ) ) {
if( Q_DecodeUTF8( &state, (byte)str[i] ))
k = i + 1; k = i + 1;
Con_UtfProcessChar( 0 ); }
return k; return k;
} }
@@ -739,16 +678,18 @@ get next of previous printful char
*/ */
int Con_UtfMoveRight( char *str, int pos, int length ) int Con_UtfMoveRight( char *str, int pos, int length )
{ {
utfstate_t state = { 0 };
int i; int i;
if( !g_utf8 )
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return pos + 1; return pos + 1;
Con_UtfProcessChar( 0 );
for( i = pos; i <= length; i++ ) for( i = pos; i <= length; i++ )
{ {
if( Con_UtfProcessChar( (unsigned char)str[i] ) ) if( Q_DecodeUTF8( &state, (byte)str[i] ))
return i + 1; return i + 1;
} }
Con_UtfProcessChar( 0 );
return pos + 1; return pos + 1;
} }
@@ -839,8 +780,11 @@ void Con_Init( void )
Cvar_RegisterVariable( &con_fontsize ); Cvar_RegisterVariable( &con_fontsize );
Cvar_RegisterVariable( &con_charset ); Cvar_RegisterVariable( &con_charset );
Cvar_RegisterVariable( &con_fontscale ); Cvar_RegisterVariable( &con_fontscale );
Cvar_RegisterVariable( &con_fontrender );
Cvar_RegisterVariable( &con_fontnum ); Cvar_RegisterVariable( &con_fontnum );
Cvar_RegisterVariable( &con_color ); Cvar_RegisterVariable( &con_color );
Cvar_RegisterVariable( &scr_drawversion );
Cvar_RegisterVariable( &con_oldfont );
// init the console buffer // init the console buffer
con.bufsize = CON_TEXTSIZE; con.bufsize = CON_TEXTSIZE;
@@ -903,7 +847,6 @@ void Con_Print( const char *txt )
static char buf[MAX_PRINT_MSG]; static char buf[MAX_PRINT_MSG];
qboolean norefresh = false; qboolean norefresh = false;
static int lastlength = 0; static int lastlength = 0;
static qboolean inupdate;
static int bufpos = 0; static int bufpos = 0;
int c, mask = 0; int c, mask = 0;
@@ -994,6 +937,27 @@ void Con_Print( const char *txt )
} }
} }
/*
================
Con_NXPrintfv
Draw a single debug line with specified height, color and time to live
================
*/
static void Con_NXPrintfv( keydest_t key_dest, const con_nprint_t *info, const char *fmt, va_list va )
{
if( info->index < 0 || info->index >= ARRAYSIZE( con.notify ))
return;
Q_vsnprintf( con.notify[info->index].szNotify, sizeof( con.notify[info->index].szNotify ), fmt, va );
// setup values
con.notify[info->index].key_dest = key_dest;
con.notify[info->index].expire = host.realtime + info->time_to_live;
MakeRGBA( con.notify[info->index].color, (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), 255 );
con.draw_notify = true;
}
/* /*
================ ================
Con_NPrint Con_NPrint
@@ -1004,21 +968,16 @@ Draw a single debug line with specified height
void GAME_EXPORT Con_NPrintf( int idx, const char *fmt, ... ) void GAME_EXPORT Con_NPrintf( int idx, const char *fmt, ... )
{ {
va_list args; va_list args;
con_nprint_t info =
if( idx < 0 || idx >= MAX_DBG_NOTIFY ) {
return; .index = idx,
.time_to_live = 4.0f,
memset( con.notify[idx].szNotify, 0, MAX_STRING ); .color = { 1.0f, 1.0f, 1.0f },
};
va_start( args, fmt ); va_start( args, fmt );
Q_vsnprintf( con.notify[idx].szNotify, MAX_STRING, fmt, args ); Con_NXPrintfv( key_game, &info, fmt, args );
va_end( args ); va_end( args );
// reset values
con.notify[idx].key_dest = key_game;
con.notify[idx].expire = host.realtime + 4.0f;
MakeRGBA( con.notify[idx].color, 255, 255, 255, 255 );
con.draw_notify = true;
} }
/* /*
@@ -1034,20 +993,9 @@ void GAME_EXPORT Con_NXPrintf( con_nprint_t *info, const char *fmt, ... )
if( !info ) return; if( !info ) return;
if( info->index < 0 || info->index >= MAX_DBG_NOTIFY )
return;
memset( con.notify[info->index].szNotify, 0, MAX_STRING );
va_start( args, fmt ); va_start( args, fmt );
Q_vsnprintf( con.notify[info->index].szNotify, MAX_STRING, fmt, args ); Con_NXPrintfv( key_game, info, fmt, args );
va_end( args ); va_end( args );
// setup values
con.notify[info->index].key_dest = key_game;
con.notify[info->index].expire = host.realtime + info->time_to_live;
MakeRGBA( con.notify[info->index].color, (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), 255 );
con.draw_notify = true;
} }
/* /*
@@ -1060,21 +1008,16 @@ Draw a single debug line with specified height (menu version)
void GAME_EXPORT UI_NPrintf( int idx, const char *fmt, ... ) void GAME_EXPORT UI_NPrintf( int idx, const char *fmt, ... )
{ {
va_list args; va_list args;
con_nprint_t info =
if( idx < 0 || idx >= MAX_DBG_NOTIFY ) {
return; .index = idx,
.time_to_live = 4.0f,
memset( con.notify[idx].szNotify, 0, MAX_STRING ); .color = { 1.0f, 1.0f, 1.0f },
};
va_start( args, fmt ); va_start( args, fmt );
Q_vsnprintf( con.notify[idx].szNotify, MAX_STRING, fmt, args ); Con_NXPrintfv( key_menu, &info, fmt, args );
va_end( args ); va_end( args );
// reset values
con.notify[idx].key_dest = key_menu;
con.notify[idx].expire = host.realtime + 4.0f;
MakeRGBA( con.notify[idx].color, 255, 255, 255, 255 );
con.draw_notify = true;
} }
/* /*
@@ -1090,20 +1033,9 @@ void GAME_EXPORT UI_NXPrintf( con_nprint_t *info, const char *fmt, ... )
if( !info ) return; if( !info ) return;
if( info->index < 0 || info->index >= MAX_DBG_NOTIFY )
return;
memset( con.notify[info->index].szNotify, 0, MAX_STRING );
va_start( args, fmt ); va_start( args, fmt );
Q_vsnprintf( con.notify[info->index].szNotify, MAX_STRING, fmt, args ); Con_NXPrintfv( key_menu, info, fmt, args );
va_end( args ); va_end( args );
// setup values
con.notify[info->index].key_dest = key_menu;
con.notify[info->index].expire = host.realtime + info->time_to_live;
MakeRGBA( con.notify[info->index].color, (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), 255 );
con.draw_notify = true;
} }
/* /*
@@ -1118,9 +1050,9 @@ EDIT FIELDS
Con_ClearField Con_ClearField
================ ================
*/ */
void Con_ClearField( field_t *edit ) static void Con_ClearField( field_t *edit )
{ {
memset( edit->buffer, 0, MAX_STRING ); memset( edit->buffer, 0, sizeof( edit->buffer ));
edit->cursor = 0; edit->cursor = 0;
edit->scroll = 0; edit->scroll = 0;
} }
@@ -1133,7 +1065,7 @@ Field_Set
static void Field_Set( field_t *f, const char *string ) static void Field_Set( field_t *f, const char *string )
{ {
f->scroll = 0; f->scroll = 0;
f->cursor = Q_strncpy( f->buffer, string, MAX_STRING ); f->cursor = Q_strncpy( f->buffer, string, sizeof( f->buffer ));
} }
/* /*
@@ -1141,7 +1073,7 @@ static void Field_Set( field_t *f, const char *string )
Field_Paste Field_Paste
================ ================
*/ */
void Field_Paste( field_t *edit ) static void Field_Paste( field_t *edit )
{ {
char *cbd; char *cbd;
int i, pasteLen; int i, pasteLen;
@@ -1177,7 +1109,7 @@ in-game talk, and menu fields
Key events are used for non-printable characters, others are gotten from char events. Key events are used for non-printable characters, others are gotten from char events.
================= =================
*/ */
void Field_KeyDownEvent( field_t *edit, int key ) static void Field_KeyDownEvent( field_t *edit, int key )
{ {
int len; int len;
@@ -1248,7 +1180,7 @@ void Field_KeyDownEvent( field_t *edit, int key )
Field_CharEvent Field_CharEvent
================== ==================
*/ */
void Field_CharEvent( field_t *edit, int ch ) static void Field_CharEvent( field_t *edit, int ch )
{ {
int len; int len;
@@ -1309,7 +1241,7 @@ void Field_CharEvent( field_t *edit, int ch )
Field_DrawInputLine Field_DrawInputLine
================== ==================
*/ */
void Field_DrawInputLine( int x, int y, field_t *edit ) static void Field_DrawInputLine( int x, int y, field_t *edit )
{ {
int len, cursorChar; int len, cursorChar;
int drawLen; int drawLen;
@@ -1439,36 +1371,49 @@ static void Con_HistoryAppend( con_history_t *self, field_t *from )
static void Con_LoadHistory( con_history_t *self ) static void Con_LoadHistory( con_history_t *self )
{ {
const byte *aFile = FS_LoadFile( "console_history.txt", NULL, true );
const char *pLine, *pFile;
int i, len;
field_t *f; field_t *f;
file_t *fd;
int i;
if( !aFile ) fd = FS_Open( "console_history.txt", "rb", true );
if( !fd )
return; return;
for( pFile = pLine = (char *)aFile; *pFile; pFile++ ) while( !FS_Eof( fd ))
{ {
if( *pFile != '\n' ) f = &self->lines[self->next % CON_HISTORY];
Con_ClearField( f );
f->widthInChars = con.linewidth;
FS_Gets( fd, f->buffer, sizeof( f->buffer ));
f->cursor = Q_strlen( f->buffer );
// skip empty lines
if( f->cursor == 0 )
continue; continue;
Con_ClearField( &self->lines[self->next] ); // skip repeating lines
if( self->next > 0 )
len = Q_min( pFile - pLine + 1, sizeof( f->buffer )); {
f = &self->lines[self->next % CON_HISTORY]; field_t *prev;
f->widthInChars = con.linewidth; prev = &self->lines[(self->next - 1) % CON_HISTORY];
f->cursor = len - 1; if( !Q_stricmp( prev->buffer, f->buffer ))
Q_strncpy( f->buffer, pLine, len); continue;
}
self->next++; self->next++;
pLine = pFile + 1;
} }
FS_Close( fd );
for( i = self->next; i < CON_HISTORY; i++ ) for( i = self->next; i < CON_HISTORY; i++ )
{ {
Con_ClearField( &self->lines[i] ); f = &self->lines[i];
self->lines[i].widthInChars = con.linewidth;
Con_ClearField( f );
f->widthInChars = con.linewidth;
} }
self->line = self->next; self->line = self->next;
@@ -1486,10 +1431,18 @@ static void Con_SaveHistory( con_history_t *self )
if( historyStart < 0 ) if( historyStart < 0 )
historyStart = 0; historyStart = 0;
f = FS_Open( "console_history.txt", "w", true ); f = FS_Open( "console_history.txt", "wb", true );
for( i = historyStart; i < self->next; i++ ) for( i = historyStart; i < self->next; i++ )
FS_Printf( f, "%s\n", self->lines[i % CON_HISTORY].buffer ); {
const char *s = self->lines[i % CON_HISTORY].buffer;
// HACKHACK: don't save lines that have something that looks like a password
if( Q_stristr( s, "password" ) || Q_stristr( s, "_pw" ))
continue;
FS_Printf( f, "%s\n", s );
}
FS_Close( f ); FS_Close( f );
} }
@@ -1531,6 +1484,9 @@ void Key_Console( int key )
Con_Printf( ">%s\n", con.input.buffer ); Con_Printf( ">%s\n", con.input.buffer );
// copy line to history buffer // copy line to history buffer
// just in case, remove all CR and LF characters pushing it to the history
// not sure how they get even added in the first place
COM_RemoveLineFeed( con.input.buffer, sizeof( con.input.buffer ));
Con_HistoryAppend( &con.history, &con.input ); Con_HistoryAppend( &con.history, &con.input );
Con_ClearField( &con.input ); Con_ClearField( &con.input );
@@ -1681,7 +1637,7 @@ Con_DrawInput
The input line scrolls horizontally if typing goes beyond the right edge The input line scrolls horizontally if typing goes beyond the right edge
================ ================
*/ */
void Con_DrawInput( int lines ) static void Con_DrawInput( int lines )
{ {
int y; int y;
@@ -1701,7 +1657,7 @@ Con_DrawDebugLines
Custom debug messages Custom debug messages
================ ================
*/ */
int Con_DrawDebugLines( void ) static int Con_DrawDebugLines( void )
{ {
notify_t *notify = con.notify; notify_t *notify = con.notify;
int i, count = 0; int i, count = 0;
@@ -1786,7 +1742,7 @@ Con_DrawNotify
Draws the last few lines of output transparently over the game top Draws the last few lines of output transparently over the game top
================ ================
*/ */
void Con_DrawNotify( void ) static void Con_DrawNotify( void )
{ {
double time = cl.time; double time = cl.time;
int i, x, y = 0; int i, x, y = 0;
@@ -1797,7 +1753,7 @@ void Con_DrawNotify( void )
if( host.allow_console && ( !Cvar_VariableInteger( "cl_background" ) && !Cvar_VariableInteger( "sv_background" ))) if( host.allow_console && ( !Cvar_VariableInteger( "cl_background" ) && !Cvar_VariableInteger( "sv_background" )))
{ {
for( i = CON_LINES_COUNT - con.num_times; i < CON_LINES_COUNT; i++ ) for( i = Q_max( 0, CON_LINES_COUNT - con.num_times ); i < CON_LINES_COUNT; i++ )
{ {
con_lineinfo_t *l = &CON_LINES( i ); con_lineinfo_t *l = &CON_LINES( i );
@@ -1838,7 +1794,7 @@ If alpha is 0, the line is not drawn, but still wrapped and its height
returned. returned.
================ ================
*/ */
int Con_DrawConsoleLine( int y, int lineno ) static int Con_DrawConsoleLine( int y, int lineno )
{ {
con_lineinfo_t *li = &CON_LINES( lineno ); con_lineinfo_t *li = &CON_LINES( lineno );
@@ -1893,7 +1849,7 @@ Con_DrawConsole
Draws the console with the solid background Draws the console with the solid background
================ ================
*/ */
void Con_DrawSolidConsole( int lines ) static void Con_DrawSolidConsole( int lines )
{ {
int i, x, y; int i, x, y;
float fraction; float fraction;
@@ -2047,26 +2003,30 @@ void Con_DrawVersion( void )
byte *color = g_color_table[7]; byte *color = g_color_table[7];
int stringLen, charH = 0; int stringLen, charH = 0;
int start, height = refState.height; int start, height = refState.height;
qboolean draw_version = false;
string curbuild; string curbuild;
switch( cls.scrshot_action ) if( !scr_drawversion.value || CL_IsDevOverviewMode() == 2 || net_graph.value )
{
case scrshot_normal:
case scrshot_snapshot:
draw_version = true;
break;
}
if( host.force_draw_version_time > host.realtime )
draw_version = true;
if(( cls.key_dest != key_menu && !draw_version ) || CL_IsDevOverviewMode() == 2 || net_graph.value )
return; return;
if( draw_version ) if( cls.key_dest == key_menu )
Q_snprintf( curbuild, MAX_STRING, XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( )); {
else Q_snprintf( curbuild, MAX_STRING, "v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( )); Q_snprintf( curbuild, sizeof( curbuild ),
"v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
}
else
{
qboolean draw_version;
draw_version = cls.scrshot_action == scrshot_normal
|| cls.scrshot_action == scrshot_snapshot
|| host.force_draw_version_time > host.realtime;
if( !draw_version )
return;
Q_snprintf( curbuild, sizeof( curbuild ),
XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
}
Con_DrawStringLen( curbuild, &stringLen, &charH ); Con_DrawStringLen( curbuild, &stringLen, &charH );
start = refState.width - stringLen * 1.05f; start = refState.width - stringLen * 1.05f;
@@ -2091,9 +2051,13 @@ void Con_RunConsole( void )
// decide on the destination height of the console // decide on the destination height of the console
if( host.allow_console && cls.key_dest == key_console ) if( host.allow_console && cls.key_dest == key_console )
{ {
#if XASH_MOBILE_PLATFORM
con.showlines = refState.height; // always full screen on mobile devices
#else
if( cls.state < ca_active || cl.first_frame ) if( cls.state < ca_active || cl.first_frame )
con.showlines = refState.height; // full screen con.showlines = refState.height; // full screen
else con.showlines = (refState.height >> 1); // half screen else con.showlines = (refState.height >> 1); // half screen
#endif
} }
else con.showlines = 0; // none visible else con.showlines = 0; // none visible
@@ -2112,10 +2076,7 @@ void Con_RunConsole( void )
con.vislines = con.showlines; con.vislines = con.showlines;
} }
if( FBitSet( con_charset.flags, FCVAR_CHANGED ) || if( FBitSet( con_charset.flags|con_fontscale.flags|con_fontnum.flags|cl_charset.flags|con_oldfont.flags, FCVAR_CHANGED ))
FBitSet( con_fontscale.flags, FCVAR_CHANGED ) ||
FBitSet( con_fontnum.flags, FCVAR_CHANGED ) ||
FBitSet( cl_charset.flags, FCVAR_CHANGED ))
{ {
// update codepage parameters // update codepage parameters
if( !Q_stricmp( con_charset.string, "cp1251" )) if( !Q_stricmp( con_charset.string, "cp1251" ))
@@ -2134,13 +2095,14 @@ void Con_RunConsole( void )
g_codepage = 1252; g_codepage = 1252;
} }
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" ); cls.accept_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
Con_InvalidateFonts(); Con_InvalidateFonts();
Con_LoadConchars(); Con_LoadConchars();
ClearBits( con_charset.flags, FCVAR_CHANGED ); ClearBits( con_charset.flags, FCVAR_CHANGED );
ClearBits( con_fontnum.flags, FCVAR_CHANGED ); ClearBits( con_fontnum.flags, FCVAR_CHANGED );
ClearBits( con_fontscale.flags, FCVAR_CHANGED ); ClearBits( con_fontscale.flags, FCVAR_CHANGED );
ClearBits( cl_charset.flags, FCVAR_CHANGED ); ClearBits( cl_charset.flags, FCVAR_CHANGED );
ClearBits( con_oldfont.flags, FCVAR_CHANGED );
} }
} }
@@ -2171,6 +2133,34 @@ void Con_CharEvent( int key )
} }
} }
static int Con_LoadSimpleConback( const char *name, int flags )
{
const char *paths[] = {
"gfx/shell/%s.dds",
"gfx/shell/%s.bmp",
"gfx/shell/%s.tga",
"cached/%s640",
"cached/%s",
};
size_t i;
for( i = 0; i < ARRAYSIZE( paths ); i++ )
{
string path;
Q_snprintf( path, sizeof( path ), paths[i], name );
if( g_fsapi.FileExists( path, false ))
{
int gl_texturenum = ref.dllFuncs.GL_LoadTexture( path, NULL, 0, flags );
if( gl_texturenum )
return gl_texturenum;
}
}
return 0;
}
/* /*
========= =========
Con_VidInit Con_VidInit
@@ -2180,46 +2170,25 @@ INTERNAL RESOURCE
*/ */
void Con_VidInit( void ) void Con_VidInit( void )
{ {
const uint flags = TF_IMAGE|TF_ALLOW_NEAREST;
if( !con.historyLoaded ) if( !con.historyLoaded )
{ {
Con_LoadHistory( &con.history ); Con_LoadHistory( &con.history );
con.historyLoaded = true; con.historyLoaded = true;
} }
if( Sys_CheckParm( "-oldfont" ))
Cvar_DirectSet( &con_oldfont, "1" );
Con_LoadConchars(); Con_LoadConchars();
Con_CheckResize(); Con_CheckResize();
#if XASH_LOW_MEMORY #if XASH_LOW_MEMORY
con.background = R_GetBuiltinTexture( REF_BLACK_TEXTURE ); con.background = R_GetBuiltinTexture( REF_GRAY_TEXTURE );
#else #else
// loading console image // loading console image
if( host.allow_console ) con.background = Con_LoadSimpleConback( host.allow_console ? "conback" : "loading", flags );
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/conback640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/conback", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
}
}
else
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/loading640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/loading", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
}
}
if( !con.background ) // last chance - quake conback image if( !con.background ) // last chance - quake conback image
{ {
@@ -2303,11 +2272,20 @@ Con_DefaultColor
called from MainUI called from MainUI
========= =========
*/ */
void GAME_EXPORT Con_DefaultColor( int r, int g, int b ) void Con_DefaultColor( int r, int g, int b, qboolean gameui )
{ {
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 255 ); b = bound( 0, b, 255 );
// gameui wants to override console color... check if it's not default
if( gameui && ( g_color_table[7][0] != r || g_color_table[7][1] != g || g_color_table[7][2] != b ))
{
// yes, different from default orange, disable con_color
SetBits( con_color.flags, FCVAR_READ_ONLY );
ClearBits( con_color.flags, FCVAR_CHANGED );
}
MakeRGBA( g_color_table[7], r, g, b, 255 ); MakeRGBA( g_color_table[7], r, g, b, 255 );
} }

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