Compare commits

..

229 Commits

Author SHA1 Message Date
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
151 changed files with 4394 additions and 2664 deletions

View File

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

@@ -45,11 +45,11 @@ 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
env: env:
SDL_VERSION: 2.28.1 SDL_VERSION: 2.28.5
GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CPU_ARCH: ${{ matrix.targetarch }}
ANDROID_SDK_TOOLS_VER: 4333796 ANDROID_SDK_TOOLS_VER: 4333796
steps: steps:

View File

@@ -70,9 +70,11 @@ 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 |
@@ -88,6 +90,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 +98,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

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

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

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

@@ -27,4 +27,19 @@ GNU General Public License for more details.
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer #define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
#define ENGINE_STEP_POSHISTORY_LERP (1U<<31) // enable MOVETYPE_STEP interpolation based on position history. Incompatible with ENGINE_COMPUTE_STUDIO_LERP!
// adjust the mask when features will be added or removed
#define ENGINE_FEATURES_MASK \
( ENGINE_WRITE_LARGE_COORD \
| ENGINE_QUAKE_COMPATIBLE \
| ENGINE_LOAD_DELUXEDATA \
| ENGINE_PHYSICS_PUSHER_EXT \
| ENGINE_LARGE_LIGHTMAPS \
| ENGINE_COMPENSATE_QUAKE_BUG \
| ENGINE_IMPROVED_LINETRACE \
| ENGINE_COMPUTE_STUDIO_LERP \
| ENGINE_LINEAR_GAMMA_SPACE \
| ENGINE_STEP_POSHISTORY_LERP )
#endif//FEATURES_H #endif//FEATURES_H

View File

@@ -19,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)
/* /*
======================================================================== ========================================================================

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_ASSERT( sizeof( kbutton_t ) == 12, "kbutton_t isn't 12 bytes!" );
#endif // KBUTTON_H

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_ASSERT( sizeof( netadr_t ) == 20, "netadr_t isn't 20 bytes!" );
#endif//NETADR_H #endif // NET_ADR_H

View File

@@ -229,7 +229,7 @@ typedef struct render_api_s
void (*R_Reserved0)( void ); void (*R_Reserved0)( void );
// static allocations // static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); 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

@@ -58,9 +58,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))
@@ -88,18 +85,21 @@ typedef uint64_t longtime_t;
#define _format(x) __attribute__((format(printf, x, x+1))) #define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull)) #define NONNULL __attribute__((nonnull))
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport ) #define EXPORT __declspec( dllexport )
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL #define NONNULL
#define ALLOC_CHECK(x)
#else #else
#define EXPORT #define EXPORT
#define GAME_EXPORT #define GAME_EXPORT
#define _format(x) #define _format(x)
#define NORETURN #define NORETURN
#define NONNULL #define NONNULL
#define ALLOC_CHECK(x)
#endif #endif
#if ( __GNUC__ >= 3 ) #if ( __GNUC__ >= 3 )
@@ -118,10 +118,18 @@ typedef uint64_t longtime_t;
#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 static_assert #define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y )
#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 #endif
#ifdef XASH_BIG_ENDIAN #ifdef XASH_BIG_ENDIAN

View File

@@ -1,177 +1,181 @@
/*** /*
* 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.
*
****/
{-0.525731, 0.000000, 0.850651}, This program is free software; you can redistribute it and/or
{-0.442863, 0.238856, 0.864188}, modify it under the terms of the GNU General Public License
{-0.295242, 0.000000, 0.955423}, as published by the Free Software Foundation; either version 2
{-0.309017, 0.500000, 0.809017}, of the License, or (at your option) any later version.
{-0.162460, 0.262866, 0.951056},
{0.000000, 0.000000, 1.000000}, This program is distributed in the hope that it will be useful,
{0.000000, 0.850651, 0.525731}, but WITHOUT ANY WARRANTY; without even the implied warranty of
{-0.147621, 0.716567, 0.681718}, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
{0.147621, 0.716567, 0.681718},
{0.000000, 0.525731, 0.850651}, See the GNU General Public License for more details.
{0.309017, 0.500000, 0.809017},
{0.525731, 0.000000, 0.850651}, You should have received a copy of the GNU General Public License
{0.295242, 0.000000, 0.955423}, along with this program; if not, write to the Free Software
{0.442863, 0.238856, 0.864188}, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
{0.162460, 0.262866, 0.951056},
{-0.681718, 0.147621, 0.716567}, */
{-0.809017, 0.309017, 0.500000}, {-0.525731, 0.000000, 0.850651},
{-0.587785, 0.425325, 0.688191}, {-0.442863, 0.238856, 0.864188},
{-0.850651, 0.525731, 0.000000}, {-0.295242, 0.000000, 0.955423},
{-0.864188, 0.442863, 0.238856}, {-0.309017, 0.500000, 0.809017},
{-0.716567, 0.681718, 0.147621}, {-0.162460, 0.262866, 0.951056},
{-0.688191, 0.587785, 0.425325}, {0.000000, 0.000000, 1.000000},
{-0.500000, 0.809017, 0.309017}, {0.000000, 0.850651, 0.525731},
{-0.238856, 0.864188, 0.442863}, {-0.147621, 0.716567, 0.681718},
{-0.425325, 0.688191, 0.587785}, {0.147621, 0.716567, 0.681718},
{-0.716567, 0.681718, -0.147621}, {0.000000, 0.525731, 0.850651},
{-0.500000, 0.809017, -0.309017}, {0.309017, 0.500000, 0.809017},
{-0.525731, 0.850651, 0.000000}, {0.525731, 0.000000, 0.850651},
{0.000000, 0.850651, -0.525731}, {0.295242, 0.000000, 0.955423},
{-0.238856, 0.864188, -0.442863}, {0.442863, 0.238856, 0.864188},
{0.000000, 0.955423, -0.295242}, {0.162460, 0.262866, 0.951056},
{-0.262866, 0.951056, -0.162460}, {-0.681718, 0.147621, 0.716567},
{0.000000, 1.000000, 0.000000}, {-0.809017, 0.309017, 0.500000},
{0.000000, 0.955423, 0.295242}, {-0.587785, 0.425325, 0.688191},
{-0.262866, 0.951056, 0.162460}, {-0.850651, 0.525731, 0.000000},
{0.238856, 0.864188, 0.442863}, {-0.864188, 0.442863, 0.238856},
{0.262866, 0.951056, 0.162460}, {-0.716567, 0.681718, 0.147621},
{0.500000, 0.809017, 0.309017}, {-0.688191, 0.587785, 0.425325},
{0.238856, 0.864188, -0.442863}, {-0.500000, 0.809017, 0.309017},
{0.262866, 0.951056, -0.162460}, {-0.238856, 0.864188, 0.442863},
{0.500000, 0.809017, -0.309017}, {-0.425325, 0.688191, 0.587785},
{0.850651, 0.525731, 0.000000}, {-0.716567, 0.681718, -0.147621},
{0.716567, 0.681718, 0.147621}, {-0.500000, 0.809017, -0.309017},
{0.716567, 0.681718, -0.147621}, {-0.525731, 0.850651, 0.000000},
{0.525731, 0.850651, 0.000000}, {0.000000, 0.850651, -0.525731},
{0.425325, 0.688191, 0.587785}, {-0.238856, 0.864188, -0.442863},
{0.864188, 0.442863, 0.238856}, {0.000000, 0.955423, -0.295242},
{0.688191, 0.587785, 0.425325}, {-0.262866, 0.951056, -0.162460},
{0.809017, 0.309017, 0.500000}, {0.000000, 1.000000, 0.000000},
{0.681718, 0.147621, 0.716567}, {0.000000, 0.955423, 0.295242},
{0.587785, 0.425325, 0.688191}, {-0.262866, 0.951056, 0.162460},
{0.955423, 0.295242, 0.000000}, {0.238856, 0.864188, 0.442863},
{1.000000, 0.000000, 0.000000}, {0.262866, 0.951056, 0.162460},
{0.951056, 0.162460, 0.262866}, {0.500000, 0.809017, 0.309017},
{0.850651, -0.525731, 0.000000}, {0.238856, 0.864188, -0.442863},
{0.955423, -0.295242, 0.000000}, {0.262866, 0.951056, -0.162460},
{0.864188, -0.442863, 0.238856}, {0.500000, 0.809017, -0.309017},
{0.951056, -0.162460, 0.262866}, {0.850651, 0.525731, 0.000000},
{0.809017, -0.309017, 0.500000}, {0.716567, 0.681718, 0.147621},
{0.681718, -0.147621, 0.716567}, {0.716567, 0.681718, -0.147621},
{0.850651, 0.000000, 0.525731}, {0.525731, 0.850651, 0.000000},
{0.864188, 0.442863, -0.238856}, {0.425325, 0.688191, 0.587785},
{0.809017, 0.309017, -0.500000}, {0.864188, 0.442863, 0.238856},
{0.951056, 0.162460, -0.262866}, {0.688191, 0.587785, 0.425325},
{0.525731, 0.000000, -0.850651}, {0.809017, 0.309017, 0.500000},
{0.681718, 0.147621, -0.716567}, {0.681718, 0.147621, 0.716567},
{0.681718, -0.147621, -0.716567}, {0.587785, 0.425325, 0.688191},
{0.850651, 0.000000, -0.525731}, {0.955423, 0.295242, 0.000000},
{0.809017, -0.309017, -0.500000}, {1.000000, 0.000000, 0.000000},
{0.864188, -0.442863, -0.238856}, {0.951056, 0.162460, 0.262866},
{0.951056, -0.162460, -0.262866}, {0.850651, -0.525731, 0.000000},
{0.147621, 0.716567, -0.681718}, {0.955423, -0.295242, 0.000000},
{0.309017, 0.500000, -0.809017}, {0.864188, -0.442863, 0.238856},
{0.425325, 0.688191, -0.587785}, {0.951056, -0.162460, 0.262866},
{0.442863, 0.238856, -0.864188}, {0.809017, -0.309017, 0.500000},
{0.587785, 0.425325, -0.688191}, {0.681718, -0.147621, 0.716567},
{0.688191, 0.587785, -0.425325}, {0.850651, 0.000000, 0.525731},
{-0.147621, 0.716567, -0.681718}, {0.864188, 0.442863, -0.238856},
{-0.309017, 0.500000, -0.809017}, {0.809017, 0.309017, -0.500000},
{0.000000, 0.525731, -0.850651}, {0.951056, 0.162460, -0.262866},
{-0.525731, 0.000000, -0.850651}, {0.525731, 0.000000, -0.850651},
{-0.442863, 0.238856, -0.864188}, {0.681718, 0.147621, -0.716567},
{-0.295242, 0.000000, -0.955423}, {0.681718, -0.147621, -0.716567},
{-0.162460, 0.262866, -0.951056}, {0.850651, 0.000000, -0.525731},
{0.000000, 0.000000, -1.000000}, {0.809017, -0.309017, -0.500000},
{0.295242, 0.000000, -0.955423}, {0.864188, -0.442863, -0.238856},
{0.162460, 0.262866, -0.951056}, {0.951056, -0.162460, -0.262866},
{-0.442863, -0.238856, -0.864188}, {0.147621, 0.716567, -0.681718},
{-0.309017, -0.500000, -0.809017}, {0.309017, 0.500000, -0.809017},
{-0.162460, -0.262866, -0.951056}, {0.425325, 0.688191, -0.587785},
{0.000000, -0.850651, -0.525731}, {0.442863, 0.238856, -0.864188},
{-0.147621, -0.716567, -0.681718}, {0.587785, 0.425325, -0.688191},
{0.147621, -0.716567, -0.681718}, {0.688191, 0.587785, -0.425325},
{0.000000, -0.525731, -0.850651}, {-0.147621, 0.716567, -0.681718},
{0.309017, -0.500000, -0.809017}, {-0.309017, 0.500000, -0.809017},
{0.442863, -0.238856, -0.864188}, {0.000000, 0.525731, -0.850651},
{0.162460, -0.262866, -0.951056}, {-0.525731, 0.000000, -0.850651},
{0.238856, -0.864188, -0.442863}, {-0.442863, 0.238856, -0.864188},
{0.500000, -0.809017, -0.309017}, {-0.295242, 0.000000, -0.955423},
{0.425325, -0.688191, -0.587785}, {-0.162460, 0.262866, -0.951056},
{0.716567, -0.681718, -0.147621}, {0.000000, 0.000000, -1.000000},
{0.688191, -0.587785, -0.425325}, {0.295242, 0.000000, -0.955423},
{0.587785, -0.425325, -0.688191}, {0.162460, 0.262866, -0.951056},
{0.000000, -0.955423, -0.295242}, {-0.442863, -0.238856, -0.864188},
{0.000000, -1.000000, 0.000000}, {-0.309017, -0.500000, -0.809017},
{0.262866, -0.951056, -0.162460}, {-0.162460, -0.262866, -0.951056},
{0.000000, -0.850651, 0.525731}, {0.000000, -0.850651, -0.525731},
{0.000000, -0.955423, 0.295242}, {-0.147621, -0.716567, -0.681718},
{0.238856, -0.864188, 0.442863}, {0.147621, -0.716567, -0.681718},
{0.262866, -0.951056, 0.162460}, {0.000000, -0.525731, -0.850651},
{0.500000, -0.809017, 0.309017}, {0.309017, -0.500000, -0.809017},
{0.716567, -0.681718, 0.147621}, {0.442863, -0.238856, -0.864188},
{0.525731, -0.850651, 0.000000}, {0.162460, -0.262866, -0.951056},
{-0.238856, -0.864188, -0.442863}, {0.238856, -0.864188, -0.442863},
{-0.500000, -0.809017, -0.309017}, {0.500000, -0.809017, -0.309017},
{-0.262866, -0.951056, -0.162460}, {0.425325, -0.688191, -0.587785},
{-0.850651, -0.525731, 0.000000}, {0.716567, -0.681718, -0.147621},
{-0.716567, -0.681718, -0.147621}, {0.688191, -0.587785, -0.425325},
{-0.716567, -0.681718, 0.147621}, {0.587785, -0.425325, -0.688191},
{-0.525731, -0.850651, 0.000000}, {0.000000, -0.955423, -0.295242},
{-0.500000, -0.809017, 0.309017}, {0.000000, -1.000000, 0.000000},
{-0.238856, -0.864188, 0.442863}, {0.262866, -0.951056, -0.162460},
{-0.262866, -0.951056, 0.162460}, {0.000000, -0.850651, 0.525731},
{-0.864188, -0.442863, 0.238856}, {0.000000, -0.955423, 0.295242},
{-0.809017, -0.309017, 0.500000}, {0.238856, -0.864188, 0.442863},
{-0.688191, -0.587785, 0.425325}, {0.262866, -0.951056, 0.162460},
{-0.681718, -0.147621, 0.716567}, {0.500000, -0.809017, 0.309017},
{-0.442863, -0.238856, 0.864188}, {0.716567, -0.681718, 0.147621},
{-0.587785, -0.425325, 0.688191}, {0.525731, -0.850651, 0.000000},
{-0.309017, -0.500000, 0.809017}, {-0.238856, -0.864188, -0.442863},
{-0.147621, -0.716567, 0.681718}, {-0.500000, -0.809017, -0.309017},
{-0.425325, -0.688191, 0.587785}, {-0.262866, -0.951056, -0.162460},
{-0.162460, -0.262866, 0.951056}, {-0.850651, -0.525731, 0.000000},
{0.442863, -0.238856, 0.864188}, {-0.716567, -0.681718, -0.147621},
{0.162460, -0.262866, 0.951056}, {-0.716567, -0.681718, 0.147621},
{0.309017, -0.500000, 0.809017}, {-0.525731, -0.850651, 0.000000},
{0.147621, -0.716567, 0.681718}, {-0.500000, -0.809017, 0.309017},
{0.000000, -0.525731, 0.850651}, {-0.238856, -0.864188, 0.442863},
{0.425325, -0.688191, 0.587785}, {-0.262866, -0.951056, 0.162460},
{0.587785, -0.425325, 0.688191}, {-0.864188, -0.442863, 0.238856},
{0.688191, -0.587785, 0.425325}, {-0.809017, -0.309017, 0.500000},
{-0.955423, 0.295242, 0.000000}, {-0.688191, -0.587785, 0.425325},
{-0.951056, 0.162460, 0.262866}, {-0.681718, -0.147621, 0.716567},
{-1.000000, 0.000000, 0.000000}, {-0.442863, -0.238856, 0.864188},
{-0.850651, 0.000000, 0.525731}, {-0.587785, -0.425325, 0.688191},
{-0.955423, -0.295242, 0.000000}, {-0.309017, -0.500000, 0.809017},
{-0.951056, -0.162460, 0.262866}, {-0.147621, -0.716567, 0.681718},
{-0.864188, 0.442863, -0.238856}, {-0.425325, -0.688191, 0.587785},
{-0.951056, 0.162460, -0.262866}, {-0.162460, -0.262866, 0.951056},
{-0.809017, 0.309017, -0.500000}, {0.442863, -0.238856, 0.864188},
{-0.864188, -0.442863, -0.238856}, {0.162460, -0.262866, 0.951056},
{-0.951056, -0.162460, -0.262866}, {0.309017, -0.500000, 0.809017},
{-0.809017, -0.309017, -0.500000}, {0.147621, -0.716567, 0.681718},
{-0.681718, 0.147621, -0.716567}, {0.000000, -0.525731, 0.850651},
{-0.681718, -0.147621, -0.716567}, {0.425325, -0.688191, 0.587785},
{-0.850651, 0.000000, -0.525731}, {0.587785, -0.425325, 0.688191},
{-0.688191, 0.587785, -0.425325}, {0.688191, -0.587785, 0.425325},
{-0.587785, 0.425325, -0.688191}, {-0.955423, 0.295242, 0.000000},
{-0.425325, 0.688191, -0.587785}, {-0.951056, 0.162460, 0.262866},
{-0.425325, -0.688191, -0.587785}, {-1.000000, 0.000000, 0.000000},
{-0.587785, -0.425325, -0.688191}, {-0.850651, 0.000000, 0.525731},
{-0.688191, -0.587785, -0.425325}, {-0.955423, -0.295242, 0.000000},
{-0.951056, -0.162460, 0.262866},
{-0.864188, 0.442863, -0.238856},
{-0.951056, 0.162460, -0.262866},
{-0.809017, 0.309017, -0.500000},
{-0.864188, -0.442863, -0.238856},
{-0.951056, -0.162460, -0.262866},
{-0.809017, -0.309017, -0.500000},
{-0.681718, 0.147621, -0.716567},
{-0.681718, -0.147621, -0.716567},
{-0.850651, 0.000000, -0.525731},
{-0.688191, 0.587785, -0.425325},
{-0.587785, 0.425325, -0.688191},
{-0.425325, 0.688191, -0.587785},
{-0.425325, -0.688191, -0.587785},
{-0.587785, -0.425325, -0.688191},
{-0.688191, -0.587785, -0.425325},

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

View File

@@ -372,7 +372,7 @@ void CL_WriteDemoHeader( const char *name )
demo.header.id = IDEMOHEADER; demo.header.id = IDEMOHEADER;
demo.header.dem_protocol = DEMO_PROTOCOL; demo.header.dem_protocol = DEMO_PROTOCOL;
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION; demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
demo.header.host_fps = 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 ));
@@ -570,6 +570,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;

View File

@@ -175,7 +175,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 )
{ {
@@ -226,7 +226,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 )
{ {

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
/* /*
================== ==================
@@ -54,17 +54,28 @@ Store another position into interpolation circular buffer
*/ */
void CL_UpdatePositions( cl_entity_t *ent ) 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 // a1ba: for some reason, this sometimes still may happen
ph->animtime = cl.time; // at this time, I'm not sure whether this bug happens in delta readwrite code
// or server just decides to go backwards and really sends these values
if( ph->animtime < prev->animtime )
{
// try to deduce real animtime by looking up the difference between
// server messages (cl.mtime is never modified ny the interpolation code)
float diff = Q_max( 0, ent->curstate.msg_time - ent->prevstate.msg_time );
ph->animtime = prev->animtime + diff;
}
} }
/* /*
@@ -159,6 +170,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 && e->model && e->model->type == mod_studio )
return false;
} }
return true; return true;
@@ -171,7 +189,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;
@@ -349,11 +367,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 +378,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 +406,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 +421,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 +429,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 +455,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 +507,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 +545,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;
@@ -1212,17 +1228,33 @@ 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 );
// disable step interpolation in client.dll if( !FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
ent->curstate.movetype = MOVETYPE_NONE; {
// disable step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_NONE;
}
} }
else else
{ {
// restore step interpolation in client.dll if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
ent->curstate.movetype = MOVETYPE_STEP; {
interpolate = true;
}
else
{
// restore step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_STEP;
}
} }
#endif #endif
} }
@@ -1247,11 +1279,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 && 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

View File

@@ -1109,12 +1109,12 @@ void CL_InitEdicts( int maxclients )
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos ); 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 );
@@ -1235,11 +1235,7 @@ 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 ))
{ {
@@ -1250,7 +1246,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
Q_strncpy( name, filename, sizeof( name )); Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name ); COM_FixSlashes( name );
for( i = 0, mod = clgame.sprites + 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 +1263,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 +1323,10 @@ 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 )
{ {
model_t *spr; model_t *spr;
@@ -1368,9 +1372,10 @@ 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 numFrames = 0; int numFrames = 0;

View File

@@ -414,11 +414,15 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
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 );
} }
/* /*

View File

@@ -78,6 +78,8 @@ CVAR_DEFINE_AUTO( cl_trace_events, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable event
static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" ); static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" );
CVAR_DEFINE_AUTO( hud_utf8, "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" ); CVAR_DEFINE_AUTO( hud_utf8, "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" );
CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is visible" ); CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is visible" );
static CVAR_DEFINE_AUTO( cl_maxframetime, "0", 0, "set deadline timer for client rendering to catch freezes" );
CVAR_DEFINE_AUTO( cl_fixmodelinterpolationartifacts, "1", 0, "try to fix up models interpolation on a moving platforms (monsters on trains for example)" );
// //
// userinfo // userinfo
@@ -605,10 +607,10 @@ void CL_CreateCmd( void )
// message we are constructing. // message we are constructing.
i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK; i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
pcmd = &cl.commands[i]; pcmd = &cl.commands[i];
pcmd->processedfuncs = false;
if( !cls.demoplayback ) if( !cls.demoplayback )
{ {
pcmd->processedfuncs = false;
pcmd->senttime = host.realtime; pcmd->senttime = host.realtime;
memset( &pcmd->cmd, 0, sizeof( pcmd->cmd )); memset( &pcmd->cmd, 0, sizeof( pcmd->cmd ));
pcmd->receivedtime = -1.0; pcmd->receivedtime = -1.0;
@@ -2189,9 +2191,20 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
// serverlist got from masterserver // serverlist got from masterserver
while( MSG_GetNumBitsLeft( msg ) > 8 ) while( MSG_GetNumBitsLeft( msg ) > 8 )
{ {
MSG_ReadBytes( msg, servadr.ip, sizeof( servadr.ip )); // 4 bytes for IP uint8_t addr[16];
if( from.type6 == NA_IP6 ) // IPv6 master server only sends IPv6 addresses
{
MSG_ReadBytes( msg, addr, sizeof( addr ));
NET_IP6BytesToNetadr( &servadr, addr );
servadr.type6 = NA_IP6;
}
else
{
MSG_ReadBytes( msg, servadr.ip, sizeof( servadr.ip )); // 4 bytes for IP
servadr.type = NA_IP;
}
servadr.port = MSG_ReadShort( msg ); // 2 bytes for Port servadr.port = MSG_ReadShort( msg ); // 2 bytes for Port
servadr.type = NA_IP;
// list is ends here // list is ends here
if( !servadr.port ) if( !servadr.port )
@@ -2917,10 +2930,8 @@ void CL_InitLocal( void )
Cvar_RegisterVariable( &cl_showevents ); Cvar_RegisterVariable( &cl_showevents );
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" ); Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );
Cvar_RegisterVariable( &ui_renderworld ); Cvar_RegisterVariable( &ui_renderworld );
Cvar_RegisterVariable( &cl_maxframetime );
// these two added to shut up CS 1.5 about 'unknown' commands Cvar_RegisterVariable( &cl_fixmodelinterpolationartifacts );
Cvar_Get( "lightgamma", "1", FCVAR_ARCHIVE, "ambient lighting level (legacy, unused)" );
Cvar_Get( "direct", "1", FCVAR_ARCHIVE, "direct lighting level (legacy, unused)" );
// server commands // server commands
Cmd_AddCommand ("noclip", NULL, "enable or disable no clipping mode" ); Cmd_AddCommand ("noclip", NULL, "enable or disable no clipping mode" );
@@ -3057,6 +3068,8 @@ void Host_ClientFrame( void )
{ {
// if client is not active, do nothing // if client is not active, do nothing
if( !cls.initialized ) return; if( !cls.initialized ) return;
if( cls.key_dest == key_game && cls.state == ca_active && !Con_Visible() )
Platform_SetTimer( cl_maxframetime.value );
// if running the server remotely, send intentions now after // if running the server remotely, send intentions now after
// the incoming messages have been read // the incoming messages have been read

View File

@@ -903,7 +903,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle )); Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
background = MSG_ReadOneBit( msg ); background = MSG_ReadOneBit( msg );
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder )); Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
host.features = (uint)MSG_ReadLong( msg ); Host_ValidateEngineFeatures( MSG_ReadDword( msg ));
if( !legacy ) if( !legacy )
{ {
@@ -1638,9 +1638,6 @@ void CL_RegisterResources( sizebuf_t *msg )
CL_ClearWorld (); CL_ClearWorld ();
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models. // tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap (); ref.dllFuncs.R_NewMap ();

View File

@@ -660,9 +660,6 @@ 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.
R_UpdateRefState ();
// tell rendering system we have a new set of models. // tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap (); ref.dllFuncs.R_NewMap ();

View File

@@ -824,6 +824,27 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
cd = &from->client; cd = &from->client;
pmove->player_index = ps->number - 1; pmove->player_index = ps->number - 1;
// a1ba: workaround bug on old protocol where the server refuse to send
// our local player in delta. cl.playernum, in theory, must be equal
// to our local player index anyway
// this might not be a real solution, since everything else will be bogus
// but we need to properly run prediction and avoid potential memory
// corruption
// either debug this, or remove when old protocol will be dropped!!!
if( pmove->player_index < 0 )
{
if( cls.legacymode )
{
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
}
else
{
// if this happens, record a demo and send it to a1ba
Host_Error( "%s: ps->number == %d\n", __func__, ps->number );
}
}
pmove->multiplayer = (cl.maxclients > 1); pmove->multiplayer = (cl.maxclients > 1);
pmove->runfuncs = runfuncs; pmove->runfuncs = runfuncs;
pmove->time = time * 1000.0f; pmove->time = time * 1000.0f;

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

@@ -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:
@@ -187,26 +185,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;

View File

@@ -292,6 +292,8 @@ void SCR_MakeScreenShot( void )
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:

View File

@@ -2624,7 +2624,7 @@ CL_UpdateFlashlight
update client flashlight update client flashlight
================ ================
*/ */
void CL_UpdateFlashlight( cl_entity_t *ent ) static void CL_UpdateFlashlight( cl_entity_t *ent )
{ {
vec3_t forward, view_ofs; vec3_t forward, view_ofs;
vec3_t vecSrc, vecEnd; vec3_t vecSrc, vecEnd;
@@ -2665,7 +2665,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
// update flashlight endpos // update flashlight endpos
dl = CL_AllocDlight( ent->index ); dl = CL_AllocDlight( ent->index );
#if 1 #if 1
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace.ent].info ); hit = CL_GetEntityByIndex( clgame.pmove->physents[trace.ent].info );
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio )) if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
VectorCopy( hit->origin, dl->origin ); VectorCopy( hit->origin, dl->origin );
else VectorCopy( trace.endpos, dl->origin ); else VectorCopy( trace.endpos, dl->origin );
@@ -2684,6 +2684,41 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
dl->radius = 80; dl->radius = 80;
} }
static void R_EntityDimlight( cl_entity_t *ent, int key )
{
dlight_t *dl = CL_AllocDlight( key );
VectorCopy( ent->origin, dl->origin );
dl->color.r = dl->color.g = dl->color.b = 100;
dl->radius = COM_RandomFloat( 200.0f, 231.0f );
dl->die = cl.time + 0.001;
}
static void R_EntityLight( cl_entity_t *ent, int key )
{
dlight_t *dl = CL_AllocDlight( key );
VectorCopy( ent->origin, dl->origin );
dl->color.r = dl->color.g = dl->color.b = 100;
dl->radius = 200;
dl->die = cl.time + 0.001;
R_RocketFlare( ent->origin );
}
static void R_EntityBrightlight( cl_entity_t *ent, int key, int radius )
{
dlight_t *dl = CL_AllocDlight( key );
VectorCopy( ent->origin, dl->origin );
dl->origin[2] += 16.0f;
dl->color.r = dl->color.g = dl->color.b = 250;
if( !radius )
dl->radius = COM_RandomFloat( 400.0f, 431.0f );
else dl->radius = 400;
dl->die = cl.time + 0.001;
}
/* /*
================ ================
CL_AddEntityEffects CL_AddEntityEffects
@@ -2693,50 +2728,41 @@ apply various effects to entity origin or attachment
*/ */
void CL_AddEntityEffects( cl_entity_t *ent ) void CL_AddEntityEffects( cl_entity_t *ent )
{ {
// yellow flies effect 'monster stuck in the wall' // players have special set of effects, from CL_LinkPlayers
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ) && !RP_LOCALCLIENT( ent )) if( ent->player && ent->index != cl.viewentity )
R_EntityParticles( ent );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
{ {
if( ent->player && !Host_IsQuakeCompatible( )) if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
{ R_EntityBrightlight( ent, ent->index /* 4 in GoldSrc */, 0 );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
R_EntityDimlight( ent, ent->index /* 4 in GoldSrc */ );
}
else if( RP_LOCALCLIENT( ent ))
{
// from CL_PlayerFlashlight
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
R_EntityBrightlight( ent, ent->index /* 1 in GoldSrc */, 400 );
else if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
CL_UpdateFlashlight( ent ); CL_UpdateFlashlight( ent );
}
else
{
dlight_t *dl = CL_AllocDlight( ent->index );
dl->color.r = dl->color.g = dl->color.b = 100;
dl->radius = COM_RandomFloat( 200, 231 );
VectorCopy( ent->origin, dl->origin );
dl->die = cl.time + 0.001;
}
} }
else
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
{ {
dlight_t *dl = CL_AllocDlight( ent->index ); // from CL_LinkPacketEntities
dl->color.r = dl->color.g = dl->color.b = 250; if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ))
if( ent->player ) dl->radius = 400; // don't flickering R_EntityParticles( ent );
else dl->radius = COM_RandomFloat( 400, 431 );
VectorCopy( ent->origin, dl->origin );
dl->die = cl.time + 0.001;
dl->origin[2] += 16.0f;
}
// add light effect if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
if( FBitSet( ent->curstate.effects, EF_LIGHT )) R_EntityBrightlight( ent, ent->index, 0 );
{
dlight_t *dl = CL_AllocDlight( ent->index ); if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
dl->color.r = dl->color.g = dl->color.b = 100; R_EntityDimlight( ent, ent->index );
VectorCopy( ent->origin, dl->origin );
R_RocketFlare( ent->origin ); if( FBitSet( ent->curstate.effects, EF_LIGHT ))
dl->die = cl.time + 0.001; R_EntityLight( ent, ent->curstate.number );
dl->radius = 200;
} }
// studio models are handle muzzleflashes difference // studio models are handle muzzleflashes difference
if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && Mod_AliasExtradata( ent->model )) if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && ent->model && ent->model->type == mod_alias )
{ {
dlight_t *dl = CL_AllocDlight( ent->index ); dlight_t *dl = CL_AllocDlight( ent->index );
vec3_t fv; vec3_t fv;
@@ -2765,15 +2791,11 @@ void CL_AddModelEffects( cl_entity_t *ent )
vec3_t neworigin; vec3_t neworigin;
vec3_t oldorigin; vec3_t oldorigin;
if( !ent->model ) return; if( !ent->model || ent->player )
return;
switch( ent->model->type ) if( ent->model->type != mod_alias && ent->model->type != mod_studio )
{ return;
case mod_alias:
case mod_studio:
break;
default: return;
}
if( cls.demoplayback == DEMO_QUAKE1 ) if( cls.demoplayback == DEMO_QUAKE1 )
{ {
@@ -2793,19 +2815,15 @@ void CL_AddModelEffects( cl_entity_t *ent )
if( FBitSet( ent->model->flags, STUDIO_GIB )) if( FBitSet( ent->model->flags, STUDIO_GIB ))
R_RocketTrail( oldorigin, neworigin, 2 ); R_RocketTrail( oldorigin, neworigin, 2 );
else if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
R_RocketTrail( oldorigin, neworigin, 4 ); R_RocketTrail( oldorigin, neworigin, 4 );
else if( FBitSet( ent->model->flags, STUDIO_TRACER ))
if( FBitSet( ent->model->flags, STUDIO_TRACER ))
R_RocketTrail( oldorigin, neworigin, 3 ); R_RocketTrail( oldorigin, neworigin, 3 );
else if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
R_RocketTrail( oldorigin, neworigin, 5 ); R_RocketTrail( oldorigin, neworigin, 5 );
else if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
{ {
dlight_t *dl = CL_AllocDlight( ent->index ); dlight_t *dl = CL_AllocDlight( ent->curstate.number );
dl->color.r = dl->color.g = dl->color.b = 200; dl->color.r = dl->color.g = dl->color.b = 200;
VectorCopy( ent->origin, dl->origin ); VectorCopy( ent->origin, dl->origin );
@@ -2819,11 +2837,9 @@ void CL_AddModelEffects( cl_entity_t *ent )
R_RocketTrail( oldorigin, neworigin, 0 ); R_RocketTrail( oldorigin, neworigin, 0 );
} }
else if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
R_RocketTrail( oldorigin, neworigin, 1 ); R_RocketTrail( oldorigin, neworigin, 1 );
else if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
R_RocketTrail( oldorigin, neworigin, 6 ); R_RocketTrail( oldorigin, neworigin, 6 );
} }

View File

@@ -81,7 +81,6 @@ 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

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

@@ -347,6 +347,8 @@ qboolean V_PreRender( void )
return false; return false;
} }
V_CheckGamma();
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active )); ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
GL_UpdateSwapInterval( ); GL_UpdateSwapInterval( );
@@ -549,5 +551,6 @@ 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();
} }

View File

@@ -174,6 +174,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 +203,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,11 +224,6 @@ 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];
@@ -223,7 +237,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 +249,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 +259,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];
@@ -694,6 +700,7 @@ 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;
//============================================================================= //=============================================================================
@@ -996,9 +1003,7 @@ 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 );
// //

View File

@@ -29,7 +29,8 @@ static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font cha
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_utf8 = false;
@@ -543,8 +544,7 @@ 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, kRenderTransTexture, TF_FONT|TF_NEAREST );
} }
@@ -841,6 +841,8 @@ void Con_Init( void )
Cvar_RegisterVariable( &con_fontscale ); Cvar_RegisterVariable( &con_fontscale );
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;
@@ -2047,26 +2049,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;
@@ -2112,10 +2118,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" ))
@@ -2141,6 +2144,7 @@ void Con_RunConsole( void )
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 );
} }
} }
@@ -2186,6 +2190,9 @@ void Con_VidInit( void )
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

428
engine/client/gamma.c Normal file
View File

@@ -0,0 +1,428 @@
/*
gamma.c - gamma routines
Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "client.h"
#include "xash3d_mathlib.h"
#include "enginefeatures.h"
//-----------------------------------------------------------------------------
// Gamma conversion support
//-----------------------------------------------------------------------------
static byte texgammatable[256];
static uint lightgammatable[1024];
static uint lineargammatable[1024];
static uint screengammatable[1024];
static CVAR_DEFINE( v_direct, "direct", "0.9", 0, "direct studio lighting" );
static CVAR_DEFINE( v_texgamma, "texgamma", "2.0", 0, "texgamma amount" );
static CVAR_DEFINE( v_lightgamma, "lightgamma", "2.5", 0, "lightgamma amount" );
static CVAR_DEFINE( v_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
static CVAR_DEFINE( v_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
static void BuildGammaTable( const float gamma, const float brightness, const float texgamma, const float lightgamma )
{
float g1, g2, g3;
int i;
if( gamma != 0.0 )
g1 = 1.0 / gamma;
else g1 = 0.4;
g2 = g1 * texgamma;
if( brightness <= 0.0 )
g3 = 0.125;
else if( brightness <= 1.0 )
g3 = 0.125 - brightness * brightness * 0.075;
else
g3 = 0.05;
for( i = 0; i < 256; i++ )
{
double d = pow( i / 255.0, (double)g2 );
int inf = d * 255.0;
texgammatable[i] = bound( 0, inf, 255 );
}
for( i = 0; i < 1024; i++ )
{
double d;
float f = pow( i / 1023.0, (double)lightgamma );
int inf;
if( brightness > 1.0 )
f *= brightness;
if( f <= g3 )
f = ( f / g3 ) * 0.125;
else
f = (( f - g3 ) / ( 1.0 - g3 )) * 0.875 + 0.125;
d = pow( (double)f, (double)g1 ); // do not remove the cast, or tests fail
inf = d * 1023.0;
lightgammatable[i] = bound( 0, inf, 1023 );
// do these calculations in the same loop...
lineargammatable[i] = pow( i / 1023.0, (double)gamma ) * 1023.0;
screengammatable[i] = pow( i / 1023.0, 1.0 / gamma ) * 1023.0;
}
}
static void V_ValidateGammaCvars( void )
{
if( Host_IsLocalGame( ))
return;
if( v_gamma.value < 1.8f )
Cvar_DirectSet( &v_gamma, "1.8" );
else if( v_gamma.value > 3.0f )
Cvar_DirectSet( &v_gamma, "3" );
if( v_texgamma.value < 1.8f )
Cvar_DirectSet( &v_texgamma, "1.8" );
else if( v_texgamma.value > 3.0f )
Cvar_DirectSet( &v_texgamma, "3" );
if( v_lightgamma.value < 1.8f )
Cvar_DirectSet( &v_lightgamma, "1.8" );
else if( v_lightgamma.value > 3.0f )
Cvar_DirectSet( &v_lightgamma, "3" );
if( v_brightness.value < 0.0f )
Cvar_DirectSet( &v_brightness, "0" );
else if( v_brightness.value > 2.0f )
Cvar_DirectSet( &v_brightness, "2" );
}
void V_CheckGamma( void )
{
static qboolean dirty = false;
qboolean notify_refdll = false;
// because these cvars were defined as archive
// but wasn't doing anything useful
// reset them into default values
// this might be removed after a while
if( v_direct.value == 1.0f || v_lightgamma.value == 1.0f )
{
Cvar_DirectSet( &v_direct, "0.9" );
Cvar_DirectSet( &v_lightgamma, "2.5" );
}
if( cls.scrshot_action == scrshot_envshot || cls.scrshot_action == scrshot_skyshot )
{
dirty = true; // force recalculate next normal frame
BuildGammaTable( 1.8f, 0.0f, 2.0f, 2.5f );
if( ref.initialized )
ref.dllFuncs.R_GammaChanged( true );
return;
}
if( dirty || FBitSet( v_texgamma.flags|v_lightgamma.flags|v_brightness.flags|v_gamma.flags, FCVAR_CHANGED ))
{
V_ValidateGammaCvars();
dirty = false;
BuildGammaTable( v_gamma.value, v_brightness.value, v_texgamma.value, v_lightgamma.value );
// force refdll to recalculate lightmaps
notify_refdll = true;
// unfortunately, recalculating textures isn't possible yet
ClearBits( v_texgamma.flags, FCVAR_CHANGED );
ClearBits( v_lightgamma.flags, FCVAR_CHANGED );
ClearBits( v_brightness.flags, FCVAR_CHANGED );
ClearBits( v_gamma.flags, FCVAR_CHANGED );
}
if( notify_refdll && ref.initialized )
ref.dllFuncs.R_GammaChanged( false );
}
void V_Init( void )
{
Cvar_RegisterVariable( &v_texgamma );
Cvar_RegisterVariable( &v_lightgamma );
Cvar_RegisterVariable( &v_brightness );
Cvar_RegisterVariable( &v_gamma );
Cvar_RegisterVariable( &v_direct );
// force gamma init
SetBits( v_gamma.flags, FCVAR_CHANGED );
V_CheckGamma();
}
byte TextureToGamma( byte b )
{
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
return b;
return texgammatable[b];
}
byte LightToTexGamma( byte b )
{
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
return b;
// 255 << 2 is 1020, impossible to overflow
return lightgammatable[b << 2] >> 2;
}
uint LightToTexGammaEx( uint b )
{
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
return b;
if( unlikely( b > ARRAYSIZE( lightgammatable )))
return 0;
return lightgammatable[b];
}
uint ScreenGammaTable( uint b )
{
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
return b;
if( unlikely( b > ARRAYSIZE( screengammatable )))
return 0;
return screengammatable[b];
}
uint LinearGammaTable( uint b )
{
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
return b;
if( unlikely( b > ARRAYSIZE( lineargammatable )))
return 0;
return lineargammatable[b];
}
#if XASH_ENGINE_TESTS
#include "tests.h"
typedef struct precomputed_gamma_tables_s
{
float gamma;
float brightness;
float texgamma;
float lightgamma;
byte texgammatable[256];
int lightgammatable[1024];
int lineargammatable[1024];
int screengammatable[1024];
} precomputed_gamma_tables_t;
// put at the end of the file, to not confuse Qt Creator's parser
precomputed_gamma_tables_t *Test_GetGammaTables( int i );
static void Test_PrecomputedGammaTables( void )
{
precomputed_gamma_tables_t *data;
int i = 0;
while(( data = Test_GetGammaTables( i )))
{
int j;
BuildGammaTable( data->gamma, data->brightness, data->texgamma, data->lightgamma );
for( j = 0; j < 1024; j++ )
{
if( j < 256 )
{
TASSERT_EQi( texgammatable[j], data->texgammatable[j] );
}
TASSERT_EQi( lightgammatable[j], data->lightgammatable[j] );
TASSERT_EQi( lineargammatable[j], data->lineargammatable[j] );
TASSERT_EQi( screengammatable[j], data->screengammatable[j] );
}
i++;
}
}
void Test_RunGamma( void )
{
TRUN( Test_PrecomputedGammaTables() );
}
precomputed_gamma_tables_t *Test_GetGammaTables( int i )
{
static precomputed_gamma_tables_t precomputed_data[] = {
{
.gamma = 2.5,
.brightness = 0.0,
.texgamma = 2.0,
.lightgamma = 2.5,
.texgammatable = {
0, 3, 5, 7, 9, 10, 12, 14, 15, 17, 19, 20, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 142, 143, 144, 145, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 165, 166, 167, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 177, 178, 179, 180, 180, 181, 182, 183, 184, 185,
186, 186, 187, 188, 189, 190, 191, 192, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 224, 224, 225, 226, 227, 228, 229,
229, 230, 231, 232, 233, 233, 234, 235, 236, 237, 238, 238, 239, 240, 241, 242, 242, 243, 244, 245, 246, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, 255
},
.lightgammatable = {
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331,
332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 343, 343, 344, 345, 346, 347, 348, 349, 350, 351, 353, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 376, 376, 377, 379, 379, 380, 381, 382, 383,
384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435,
436, 437, 438, 439, 440, 441, 442, 443, 444, 446, 446, 447, 449, 449, 450, 451, 452, 453, 455, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 468, 469, 470, 470, 472, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487,
488, 489, 490, 491, 493, 493, 494, 495, 496, 498, 498, 499, 500, 502, 502, 503, 504, 505, 507, 508, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 520, 521, 521, 522, 523, 524, 525, 526, 527, 528, 530, 530, 531, 532, 533, 534, 536, 536, 537, 538, 539,
540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 552, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 564, 564, 565, 566, 567, 568, 570, 571, 571, 572, 573, 574, 576, 576, 577, 578, 579, 580, 581, 583, 583, 584, 585, 586, 587, 588, 590, 591, 591,
593, 593, 594, 596, 596, 597, 598, 600, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 611, 611, 612, 613, 615, 615, 616, 618, 618, 620, 621, 621, 622, 624, 625, 626, 627, 627, 628, 629, 630, 632, 633, 633, 634, 635, 636, 638, 638, 639, 641, 642, 643, 643,
644, 645, 646, 648, 648, 650, 651, 651, 652, 654, 655, 656, 656, 658, 658, 660, 660, 662, 662, 664, 664, 665, 666, 668, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 682, 682, 683, 684, 685, 686, 687, 688, 690, 690, 691, 692, 693, 695, 696,
696, 697, 698, 699, 700, 701, 702, 703, 705, 706, 706, 707, 708, 709, 710, 711, 712, 713, 715, 716, 716, 717, 718, 719, 721, 721, 722, 724, 724, 725, 727, 727, 728, 729, 730, 731, 733, 733, 734, 735, 736, 737, 738, 740, 740, 741, 743, 744, 744, 745, 747, 747,
748, 749, 750, 752, 753, 753, 755, 755, 757, 757, 758, 759, 760, 761, 762, 764, 764, 766, 766, 767, 769, 770, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 784, 785, 786, 788, 789, 790, 791, 792, 792, 794, 794, 796, 796, 797, 799, 800,
801, 801, 802, 803, 804, 805, 806, 807, 809, 810, 810, 811, 813, 813, 815, 815, 816, 817, 819, 819, 820, 822, 823, 823, 824, 825, 826, 827, 829, 829, 830, 832, 832, 833, 835, 835, 837, 837, 839, 840, 840, 841, 842, 843, 844, 845, 847, 847, 849, 849, 850, 851,
852, 854, 854, 856, 856, 857, 859, 859, 860, 861, 862, 864, 864, 865, 867, 867, 868, 870, 870, 872, 872, 874, 875, 875, 876, 877, 879, 880, 881, 881, 882, 883, 885, 885, 886, 887, 888, 890, 891, 891, 893, 893, 894, 895, 897, 898, 899, 900, 901, 902, 902, 903,
904, 905, 907, 907, 908, 910, 910, 911, 912, 914, 914, 915, 917, 918, 919, 920, 921, 922, 922, 923, 925, 925, 926, 927, 928, 930, 931, 932, 932, 933, 935, 936, 936, 937, 939, 940, 940, 942, 942, 944, 944, 946, 947, 948, 949, 949, 950, 952, 952, 953, 955, 956,
957, 958, 959, 959, 960, 962, 962, 964, 965, 965, 967, 967, 969, 970, 971, 972, 973, 973, 975, 975, 976, 977, 978, 979, 980, 982, 982, 984, 984, 986, 986, 988, 988, 990, 991, 992, 993, 993, 994, 995, 996, 998, 999, 999, 1000, 1002, 1002, 1004, 1005, 1005,
1006, 1007, 1008, 1010, 1011, 1011, 1013, 1014, 1015, 1016, 1017, 1018, 1018, 1019, 1020, 1021, 1023
},
.lineargammatable = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 25, 25,
25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 43, 43, 43, 44, 44, 44, 45, 45, 46, 46, 46,
47, 47, 48, 48, 48, 49, 49, 50, 50, 50, 51, 51, 52, 52, 52, 53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76,
77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 92, 93, 94, 94, 95, 95, 96, 97, 97, 98, 99, 99, 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, 110, 111, 111, 112,
113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 119, 120, 121, 122, 122, 123, 124, 124, 125, 126, 126, 127, 128, 129, 129, 130, 131, 132, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 140, 141, 142, 143, 144, 144, 145, 146, 147, 147, 148, 149, 150,
151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 164, 164, 165, 166, 167, 168, 169, 169, 170, 171, 172, 173, 174, 175, 176, 176, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
247, 248, 249, 250, 251, 252, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 282, 283, 284, 285, 286, 287, 289, 290, 291, 292, 293, 294, 296, 297, 298, 299, 300, 302, 303, 304, 305,
306, 308, 309, 310, 311, 312, 314, 315, 316, 317, 319, 320, 321, 322, 324, 325, 326, 327, 329, 330, 331, 333, 334, 335, 336, 338, 339, 340, 342, 343, 344, 345, 347, 348, 349, 351, 352, 353, 355, 356, 357, 359, 360, 361, 363, 364, 365, 367, 368, 369, 371, 372,
373, 375, 376, 378, 379, 380, 382, 383, 384, 386, 387, 389, 390, 391, 393, 394, 396, 397, 399, 400, 401, 403, 404, 406, 407, 409, 410, 411, 413, 414, 416, 417, 419, 420, 422, 423, 425, 426, 428, 429, 431, 432, 434, 435, 437, 438, 440, 441, 443, 444, 446, 447,
449, 450, 452, 453, 455, 456, 458, 459, 461, 462, 464, 466, 467, 469, 470, 472, 473, 475, 477, 478, 480, 481, 483, 485, 486, 488, 489, 491, 493, 494, 496, 497, 499, 501, 502, 504, 506, 507, 509, 511, 512, 514, 515, 517, 519, 520, 522, 524, 525, 527, 529, 531,
532, 534, 536, 537, 539, 541, 542, 544, 546, 548, 549, 551, 553, 554, 556, 558, 560, 561, 563, 565, 567, 568, 570, 572, 574, 575, 577, 579, 581, 583, 584, 586, 588, 590, 592, 593, 595, 597, 599, 601, 602, 604, 606, 608, 610, 612, 613, 615, 617, 619, 621, 623,
625, 626, 628, 630, 632, 634, 636, 638, 639, 641, 643, 645, 647, 649, 651, 653, 655, 657, 659, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724,
726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 753, 755, 757, 759, 761, 763, 765, 767, 769, 771, 773, 776, 778, 780, 782, 784, 786, 788, 791, 793, 795, 797, 799, 801, 803, 806, 808, 810, 812, 814, 816, 819, 821, 823, 825, 827, 830, 832, 834,
836, 839, 841, 843, 845, 847, 850, 852, 854, 856, 859, 861, 863, 865, 868, 870, 872, 874, 877, 879, 881, 884, 886, 888, 890, 893, 895, 897, 900, 902, 904, 907, 909, 911, 914, 916, 918, 921, 923, 925, 928, 930, 932, 935, 937, 940, 942, 944, 947, 949, 952, 954,
956, 959, 961, 964, 966, 968, 971, 973, 976, 978, 981, 983, 985, 988, 990, 993, 995, 998, 1000, 1003, 1005, 1008, 1010, 1013, 1015, 1018, 1020, 1023
},
.screengammatable = {
0, 63, 84, 99, 111, 121, 130, 139, 146, 154, 160, 166, 172, 178, 183, 188, 193, 198, 203, 207, 212, 216, 220, 224, 228, 231, 235, 239, 242, 245, 249, 252, 255, 259, 262, 265, 268, 271, 274, 276, 279, 282, 285, 287, 290, 293, 295, 298, 300, 303, 305, 308,
310, 313, 315, 317, 320, 322, 324, 326, 328, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 369, 370, 372, 374, 376, 378, 379, 381, 383, 385, 386, 388, 390, 392, 393, 395, 397, 398, 400, 401, 403, 405, 406, 408,
409, 411, 413, 414, 416, 417, 419, 420, 422, 423, 425, 426, 428, 429, 431, 432, 434, 435, 436, 438, 439, 441, 442, 444, 445, 446, 448, 449, 450, 452, 453, 455, 456, 457, 459, 460, 461, 463, 464, 465, 466, 468, 469, 470, 472, 473, 474, 475, 477, 478, 479, 480,
482, 483, 484, 485, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 499, 500, 501, 502, 503, 504, 505, 507, 508, 509, 510, 511, 512, 513, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539,
540, 541, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 585, 586, 587, 588, 589, 590,
591, 592, 593, 594, 595, 595, 596, 597, 598, 599, 600, 601, 602, 603, 603, 604, 605, 606, 607, 608, 609, 610, 610, 611, 612, 613, 614, 615, 616, 616, 617, 618, 619, 620, 621, 622, 622, 623, 624, 625, 626, 627, 627, 628, 629, 630, 631, 632, 632, 633, 634, 635,
636, 637, 637, 638, 639, 640, 641, 641, 642, 643, 644, 645, 645, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, 656, 657, 658, 659, 659, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, 669, 670, 671, 672, 672, 673, 674, 675, 675,
676, 677, 678, 678, 679, 680, 681, 681, 682, 683, 684, 684, 685, 686, 686, 687, 688, 689, 689, 690, 691, 692, 692, 693, 694, 694, 695, 696, 697, 697, 698, 699, 699, 700, 701, 701, 702, 703, 704, 704, 705, 706, 706, 707, 708, 708, 709, 710, 711, 711, 712, 713,
713, 714, 715, 715, 716, 717, 717, 718, 719, 719, 720, 721, 721, 722, 723, 723, 724, 725, 725, 726, 727, 727, 728, 729, 729, 730, 731, 731, 732, 733, 733, 734, 735, 735, 736, 737, 737, 738, 739, 739, 740, 741, 741, 742, 743, 743, 744, 745, 745, 746, 746, 747,
748, 748, 749, 750, 750, 751, 752, 752, 753, 753, 754, 755, 755, 756, 757, 757, 758, 758, 759, 760, 760, 761, 762, 762, 763, 763, 764, 765, 765, 766, 767, 767, 768, 768, 769, 770, 770, 771, 771, 772, 773, 773, 774, 774, 775, 776, 776, 777, 778, 778, 779, 779,
780, 781, 781, 782, 782, 783, 784, 784, 785, 785, 786, 786, 787, 788, 788, 789, 789, 790, 791, 791, 792, 792, 793, 794, 794, 795, 795, 796, 796, 797, 798, 798, 799, 799, 800, 801, 801, 802, 802, 803, 803, 804, 805, 805, 806, 806, 807, 807, 808, 809, 809, 810,
810, 811, 811, 812, 813, 813, 814, 814, 815, 815, 816, 816, 817, 818, 818, 819, 819, 820, 820, 821, 821, 822, 823, 823, 824, 824, 825, 825, 826, 826, 827, 828, 828, 829, 829, 830, 830, 831, 831, 832, 832, 833, 834, 834, 835, 835, 836, 836, 837, 837, 838, 838,
839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 844, 845, 845, 846, 846, 847, 848, 848, 849, 849, 850, 850, 851, 851, 852, 852, 853, 853, 854, 854, 855, 855, 856, 856, 857, 857, 858, 859, 859, 860, 860, 861, 861, 862, 862, 863, 863, 864, 864, 865, 865, 866,
866, 867, 867, 868, 868, 869, 869, 870, 870, 871, 871, 872, 872, 873, 873, 874, 874, 875, 875, 876, 876, 877, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 890, 891, 891, 892,
892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 897, 898, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903, 904, 904, 904, 905, 905, 906, 906, 907, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 912, 913, 913, 914, 914, 915, 915, 915, 916, 916, 917,
917, 918, 918, 919, 919, 920, 920, 921, 921, 922, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 927, 928, 928, 929, 929, 929, 930, 930, 931, 931, 932, 932, 933, 933, 934, 934, 935, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 940, 941,
941, 942, 942, 943, 943, 944, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 949, 949, 950, 950, 951, 951, 952, 952, 953, 953, 953, 954, 954, 955, 955, 956, 956, 957, 957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 961, 962, 962, 963, 963, 964, 964,
964, 965, 965, 966, 966, 967, 967, 968, 968, 968, 969, 969, 970, 970, 971, 971, 971, 972, 972, 973, 973, 974, 974, 974, 975, 975, 976, 976, 977, 977, 977, 978, 978, 979, 979, 980, 980, 980, 981, 981, 982, 982, 983, 983, 983, 984, 984, 985, 985, 986, 986, 986,
987, 987, 988, 988, 988, 989, 989, 990, 990, 991, 991, 991, 992, 992, 993, 993, 993, 994, 994, 995, 995, 996, 996, 996, 997, 997, 998, 998, 998, 999, 999, 1000, 1000, 1001, 1001, 1001, 1002, 1002, 1003, 1003, 1003, 1004, 1004, 1005, 1005, 1005, 1006, 1006,
1007, 1007, 1008, 1008, 1008, 1009, 1009, 1010, 1010, 1010, 1011, 1011, 1012, 1012, 1012, 1013, 1013, 1014, 1014, 1014, 1015, 1015, 1016, 1016, 1016, 1017, 1017, 1018, 1018, 1018, 1019, 1019, 1020, 1020, 1020, 1021, 1021, 1022, 1022, 1023
},
}, {
.gamma = 2.2,
.brightness = 1.0,
.texgamma = 2.2,
.lightgamma = 2.4,
.texgammatable = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
},
.lightgammatable = {
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 45, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67, 69, 70, 71, 72, 74, 75, 76,
78, 79, 80, 81, 83, 84, 85, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 116, 117, 118, 120, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 147, 148, 149,
151, 152, 153, 155, 156, 157, 159, 160, 162, 163, 164, 166, 167, 168, 170, 171, 173, 174, 175, 177, 178, 179, 181, 182, 184, 185, 186, 188, 189, 191, 192, 193, 195, 196, 198, 199, 200, 202, 203, 204, 206, 207, 209, 210, 211, 213, 214, 216, 217, 219, 220, 221,
223, 224, 226, 227, 228, 230, 231, 233, 234, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 250, 251, 252, 254, 255, 257, 258, 260, 261, 262, 264, 265, 267, 268, 270, 271, 272, 274, 275, 277, 278, 280, 281, 282, 284, 285, 287, 288, 290, 291, 293, 294, 295,
297, 298, 300, 301, 303, 304, 306, 307, 308, 310, 311, 313, 314, 316, 317, 319, 320, 321, 323, 324, 326, 327, 329, 330, 332, 333, 335, 336, 337, 339, 340, 342, 343, 345, 346, 348, 349, 351, 352, 354, 355, 356, 358, 359, 361, 362, 364, 365, 367, 368, 370, 371,
373, 374, 376, 377, 378, 380, 381, 383, 384, 386, 387, 389, 390, 392, 393, 395, 396, 397, 398, 398, 399, 399, 400, 401, 401, 402, 402, 403, 403, 404, 404, 405, 406, 406, 407, 407, 408, 408, 409, 410, 410, 411, 411, 412, 413, 413, 414, 414, 415, 416, 416, 417,
417, 418, 419, 419, 420, 420, 421, 422, 422, 423, 423, 424, 425, 425, 426, 427, 427, 428, 428, 429, 430, 430, 431, 432, 432, 433, 433, 434, 435, 435, 436, 437, 437, 438, 439, 439, 440, 441, 441, 442, 443, 443, 444, 445, 445, 446, 447, 447, 448, 449, 449, 450,
451, 451, 452, 453, 453, 454, 455, 455, 456, 457, 457, 458, 459, 459, 460, 461, 461, 462, 463, 464, 464, 465, 466, 466, 467, 468, 468, 469, 470, 471, 471, 472, 473, 473, 474, 475, 476, 476, 477, 478, 478, 479, 480, 481, 481, 482, 483, 483, 484, 485, 486, 486,
487, 488, 489, 489, 490, 491, 492, 492, 493, 494, 495, 495, 496, 497, 498, 498, 499, 500, 501, 501, 502, 503, 504, 504, 505, 506, 507, 507, 508, 509, 510, 510, 511, 512, 513, 513, 514, 515, 516, 517, 517, 518, 519, 520, 520, 521, 522, 523, 524, 524, 525, 526,
527, 527, 528, 529, 530, 531, 531, 532, 533, 534, 535, 535, 536, 537, 538, 538, 539, 540, 541, 542, 542, 543, 544, 545, 546, 546, 547, 548, 549, 550, 550, 551, 552, 553, 554, 555, 555, 556, 557, 558, 559, 559, 560, 561, 562, 563, 564, 564, 565, 566, 567, 568,
568, 569, 570, 571, 572, 573, 573, 574, 575, 576, 577, 578, 578, 579, 580, 581, 582, 583, 583, 584, 585, 586, 587, 588, 588, 589, 590, 591, 592, 593, 593, 594, 595, 596, 597, 598, 599, 599, 600, 601, 602, 603, 604, 605, 605, 606, 607, 608, 609, 610, 611, 611,
612, 613, 614, 615, 616, 617, 617, 618, 619, 620, 621, 622, 623, 623, 624, 625, 626, 627, 628, 629, 629, 630, 631, 632, 633, 634, 635, 636, 636, 637, 638, 639, 640, 641, 642, 643, 643, 644, 645, 646, 647, 648, 649, 650, 651, 651, 652, 653, 654, 655, 656, 657,
658, 658, 659, 660, 661, 662, 663, 664, 665, 666, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 703,
704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 749, 750, 751,
752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 795, 796, 797, 798, 799, 800,
801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850,
851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 900,
901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952,
953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1023
},
.lineargammatable = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36,
36, 36, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 42, 42, 42, 43, 43, 44, 44, 44, 45, 45, 46, 46, 46, 47, 47, 48, 48, 48, 49, 49, 50, 50, 51, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 61, 62, 62, 63,
63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 93, 93, 94, 94, 95, 96, 96, 97, 97, 98, 99,
99, 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, 110, 111, 111, 112, 113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 119, 120, 121, 121, 122, 123, 123, 124, 125, 126, 126, 127, 128, 128, 129, 130, 131, 131, 132, 133, 133,
134, 135, 136, 136, 137, 138, 139, 139, 140, 141, 142, 142, 143, 144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 163, 164, 165, 166, 167, 167, 168, 169, 170, 171, 172, 172, 173, 174,
175, 176, 177, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
222, 223, 224, 225, 226, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
274, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 288, 289, 290, 291, 292, 293, 294, 295, 296, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 310, 311, 312, 313, 315, 316, 317, 318, 319, 320, 322, 323, 324, 325, 326, 328, 329, 330, 331, 332,
333, 335, 336, 337, 338, 339, 341, 342, 343, 344, 346, 347, 348, 349, 350, 352, 353, 354, 355, 357, 358, 359, 360, 362, 363, 364, 365, 367, 368, 369, 370, 372, 373, 374, 375, 377, 378, 379, 381, 382, 383, 384, 386, 387, 388, 390, 391, 392, 393, 395, 396, 397,
399, 400, 401, 403, 404, 405, 407, 408, 409, 411, 412, 413, 415, 416, 417, 419, 420, 421, 423, 424, 426, 427, 428, 430, 431, 432, 434, 435, 437, 438, 439, 441, 442, 443, 445, 446, 448, 449, 450, 452, 453, 455, 456, 458, 459, 460, 462, 463, 465, 466, 468, 469,
470, 472, 473, 475, 476, 478, 479, 481, 482, 483, 485, 486, 488, 489, 491, 492, 494, 495, 497, 498, 500, 501, 503, 504, 506, 507, 509, 510, 512, 513, 515, 516, 518, 519, 521, 522, 524, 525, 527, 528, 530, 532, 533, 535, 536, 538, 539, 541, 542, 544, 545, 547,
549, 550, 552, 553, 555, 556, 558, 560, 561, 563, 564, 566, 568, 569, 571, 572, 574, 576, 577, 579, 580, 582, 584, 585, 587, 589, 590, 592, 593, 595, 597, 598, 600, 602, 603, 605, 607, 608, 610, 612, 613, 615, 617, 618, 620, 622, 623, 625, 627, 628, 630, 632,
633, 635, 637, 639, 640, 642, 644, 645, 647, 649, 650, 652, 654, 656, 657, 659, 661, 663, 664, 666, 668, 670, 671, 673, 675, 677, 678, 680, 682, 684, 685, 687, 689, 691, 692, 694, 696, 698, 700, 701, 703, 705, 707, 709, 710, 712, 714, 716, 718, 719, 721, 723,
725, 727, 729, 730, 732, 734, 736, 738, 740, 741, 743, 745, 747, 749, 751, 753, 754, 756, 758, 760, 762, 764, 766, 767, 769, 771, 773, 775, 777, 779, 781, 783, 785, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 809, 811, 813, 815, 817, 819, 821,
823, 825, 827, 829, 831, 833, 835, 837, 839, 841, 843, 845, 847, 849, 851, 853, 855, 857, 859, 861, 863, 865, 867, 869, 871, 873, 875, 877, 879, 881, 883, 885, 887, 889, 891, 893, 895, 897, 899, 901, 903, 905, 907, 910, 912, 914, 916, 918, 920, 922, 924, 926,
928, 930, 932, 934, 937, 939, 941, 943, 945, 947, 949, 951, 953, 956, 958, 960, 962, 964, 966, 968, 970, 973, 975, 977, 979, 981, 983, 985, 988, 990, 992, 994, 996, 998, 1001, 1003, 1005, 1007, 1009, 1012, 1014, 1016, 1018, 1020, 1023
},
.screengammatable = {
0, 43, 60, 72, 82, 91, 98, 106, 112, 118, 124, 130, 135, 140, 145, 150, 154, 158, 163, 167, 171, 174, 178, 182, 185, 189, 192, 196, 199, 202, 205, 208, 211, 214, 217, 220, 223, 226, 228, 231, 234, 237, 239, 242, 244, 247, 249, 252, 254, 257, 259, 261,
264, 266, 268, 270, 273, 275, 277, 279, 281, 283, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 311, 313, 315, 317, 319, 321, 323, 324, 326, 328, 330, 331, 333, 335, 337, 338, 340, 342, 343, 345, 347, 348, 350, 352, 353, 355, 357, 358, 360,
361, 363, 365, 366, 368, 369, 371, 372, 374, 375, 377, 378, 380, 381, 383, 384, 386, 387, 389, 390, 392, 393, 394, 396, 397, 399, 400, 401, 403, 404, 406, 407, 408, 410, 411, 412, 414, 415, 416, 418, 419, 420, 422, 423, 424, 426, 427, 428, 430, 431, 432, 433,
435, 436, 437, 438, 440, 441, 442, 443, 445, 446, 447, 448, 450, 451, 452, 453, 454, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 477, 478, 479, 480, 481, 482, 483, 484, 486, 487, 488, 489, 490, 491, 492, 493, 494,
495, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 545, 546, 547,
548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 583, 584, 585, 586, 587, 588, 589, 590, 591, 591, 592, 593, 594, 595,
596, 597, 598, 598, 599, 600, 601, 602, 603, 604, 604, 605, 606, 607, 608, 609, 609, 610, 611, 612, 613, 614, 615, 615, 616, 617, 618, 619, 620, 620, 621, 622, 623, 624, 624, 625, 626, 627, 628, 629, 629, 630, 631, 632, 633, 633, 634, 635, 636, 637, 637, 638,
639, 640, 641, 641, 642, 643, 644, 645, 645, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, 656, 657, 658, 659, 659, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, 669, 670, 671, 672, 672, 673, 674, 675, 675, 676, 677, 678, 678,
679, 680, 681, 681, 682, 683, 684, 684, 685, 686, 686, 687, 688, 689, 689, 690, 691, 692, 692, 693, 694, 694, 695, 696, 697, 697, 698, 699, 700, 700, 701, 702, 702, 703, 704, 705, 705, 706, 707, 707, 708, 709, 709, 710, 711, 712, 712, 713, 714, 714, 715, 716,
716, 717, 718, 719, 719, 720, 721, 721, 722, 723, 723, 724, 725, 725, 726, 727, 728, 728, 729, 730, 730, 731, 732, 732, 733, 734, 734, 735, 736, 736, 737, 738, 738, 739, 740, 740, 741, 742, 742, 743, 744, 744, 745, 746, 746, 747, 748, 748, 749, 750, 750, 751,
752, 752, 753, 754, 754, 755, 756, 756, 757, 758, 758, 759, 759, 760, 761, 761, 762, 763, 763, 764, 765, 765, 766, 767, 767, 768, 769, 769, 770, 770, 771, 772, 772, 773, 774, 774, 775, 776, 776, 777, 777, 778, 779, 779, 780, 781, 781, 782, 782, 783, 784, 784,
785, 786, 786, 787, 787, 788, 789, 789, 790, 791, 791, 792, 792, 793, 794, 794, 795, 795, 796, 797, 797, 798, 799, 799, 800, 800, 801, 802, 802, 803, 803, 804, 805, 805, 806, 806, 807, 808, 808, 809, 809, 810, 811, 811, 812, 812, 813, 814, 814, 815, 815, 816,
817, 817, 818, 818, 819, 820, 820, 821, 821, 822, 823, 823, 824, 824, 825, 825, 826, 827, 827, 828, 828, 829, 830, 830, 831, 831, 832, 833, 833, 834, 834, 835, 835, 836, 837, 837, 838, 838, 839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 845, 845, 846, 846,
847, 847, 848, 849, 849, 850, 850, 851, 851, 852, 853, 853, 854, 854, 855, 855, 856, 857, 857, 858, 858, 859, 859, 860, 860, 861, 862, 862, 863, 863, 864, 864, 865, 865, 866, 867, 867, 868, 868, 869, 869, 870, 870, 871, 872, 872, 873, 873, 874, 874, 875, 875,
876, 876, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 891, 891, 892, 892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 898, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903,
904, 904, 905, 905, 906, 906, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 912, 913, 913, 914, 914, 915, 915, 916, 916, 917, 917, 918, 918, 919, 920, 920, 921, 921, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 927, 928, 928, 929, 929, 930, 930,
931, 931, 932, 932, 933, 933, 934, 934, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 941, 941, 942, 942, 943, 943, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 949, 950, 950, 951, 951, 952, 952, 953, 953, 954, 954, 955, 955, 956, 956,
957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 962, 962, 963, 963, 964, 964, 965, 965, 966, 966, 967, 967, 968, 968, 969, 969, 969, 970, 970, 971, 971, 972, 972, 973, 973, 974, 974, 975, 975, 976, 976, 977, 977, 978, 978, 979, 979, 980, 980, 981, 981, 982,
982, 982, 983, 983, 984, 984, 985, 985, 986, 986, 987, 987, 988, 988, 989, 989, 990, 990, 991, 991, 991, 992, 992, 993, 993, 994, 994, 995, 995, 996, 996, 997, 997, 998, 998, 999, 999, 999, 1000, 1000, 1001, 1001, 1002, 1002, 1003, 1003, 1004, 1004, 1005,
1005, 1006, 1006, 1006, 1007, 1007, 1008, 1008, 1009, 1009, 1010, 1010, 1011, 1011, 1012, 1012, 1012, 1013, 1013, 1014, 1014, 1015, 1015, 1016, 1016, 1017, 1017, 1017, 1018, 1018, 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, 1023
},
}
};
if( i < 0 || i >= ARRAYSIZE( precomputed_data ))
return NULL;
return &precomputed_data[i];
}
#endif

View File

@@ -172,8 +172,6 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
{ {
if( newstate == oldstate ) if( newstate == oldstate )
return; return;
if( m_ignore.value )
return;
// since SetCursorType controls cursor visibility // since SetCursorType controls cursor visibility
// execute it first, and then check mouse grab state // execute it first, and then check mouse grab state
@@ -194,6 +192,10 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
#endif #endif
} }
// don't leave the user without cursor if they enabled m_ignore
if( m_ignore.value )
return;
if( oldstate == key_game ) if( oldstate == key_game )
{ {
IN_DeactivateMouse(); IN_DeactivateMouse();

View File

@@ -18,6 +18,31 @@ CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BS
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" ); static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" ); static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
// there is no need to expose whole host and cl structs into the renderer
// but we still need to update timings accurately as possible
// this looks horrible but the only other option would be passing four
// time pointers and then it's looks even worse with dereferences everywhere
#define STATIC_OFFSET_CHECK( s1, s2, field, base, msg ) \
STATIC_ASSERT( offsetof( s1, field ) == offsetof( s2, field ) - offsetof( s2, base ), msg )
#define REF_CLIENT_CHECK( field ) \
STATIC_OFFSET_CHECK( ref_client_t, client_t, field, time, "broken ref_client_t offset" ); \
STATIC_ASSERT_( szchk_##__LINE__, sizeof(((ref_client_t *)0)->field ) == sizeof( cl.field ), "broken ref_client_t size" )
#define REF_HOST_CHECK( field ) \
STATIC_OFFSET_CHECK( ref_host_t, host_parm_t, field, realtime, "broken ref_client_t offset" ); \
STATIC_ASSERT_( szchk_##__LINE__, sizeof(((ref_host_t *)0)->field ) == sizeof( host.field ), "broken ref_client_t size" )
REF_CLIENT_CHECK( time );
REF_CLIENT_CHECK( oldtime );
REF_CLIENT_CHECK( viewentity );
REF_CLIENT_CHECK( playernum );
REF_CLIENT_CHECK( maxclients );
REF_CLIENT_CHECK( models );
REF_CLIENT_CHECK( paused );
REF_CLIENT_CHECK( simorg );
REF_HOST_CHECK( realtime );
REF_HOST_CHECK( frametime );
REF_HOST_CHECK( features );
void R_GetTextureParms( int *w, int *h, int texnum ) void R_GetTextureParms( int *w, int *h, int texnum )
{ {
if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum ); if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum );
@@ -42,18 +67,8 @@ void GAME_EXPORT GL_FreeImage( const char *name )
ref.dllFuncs.GL_FreeTexture( texnum ); ref.dllFuncs.GL_FreeTexture( texnum );
} }
void R_UpdateRefState( void )
{
refState.time = cl.time;
refState.oldtime = cl.oldtime;
refState.realtime = host.realtime;
refState.frametime = host.frametime;
}
void GL_RenderFrame( const ref_viewpass_t *rvp ) void GL_RenderFrame( const ref_viewpass_t *rvp )
{ {
R_UpdateRefState();
VectorCopy( rvp->vieworigin, refState.vieworg ); VectorCopy( rvp->vieworigin, refState.vieworg );
VectorCopy( rvp->viewangles, refState.viewangles ); VectorCopy( rvp->viewangles, refState.viewangles );
@@ -65,11 +80,6 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
return CL_RenderGetParm( parm, arg, false ); // prevent recursion return CL_RenderGetParm( parm, arg, false ); // prevent recursion
} }
static world_static_t *pfnGetWorld( void )
{
return &world;
}
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e ) static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
{ {
clgame.dllFuncs.pfnStudioEvent( event, e ); clgame.dllFuncs.pfnStudioEvent( event, e );
@@ -99,16 +109,6 @@ static void *pfnMod_Extradata( int type, model_t *m )
return NULL; return NULL;
} }
static void pfnGetPredictedOrigin( vec3_t v )
{
VectorCopy( cl.simorg, v );
}
static color24 *pfnCL_GetPaletteColor( int color ) // clgame.palette[color]
{
return &clgame.palette[color];
}
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
{ {
if( width ) *width = clgame.scrInfo.iWidth; if( width ) *width = clgame.scrInfo.iWidth;
@@ -158,11 +158,6 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
0; 0;
} }
static poolhandle_t pfnImage_GetPool( void )
{
return host.imagepool;
}
static const bpc_desc_t *pfnImage_GetPFDesc( int idx ) static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
{ {
return &PFDesc[idx]; return &PFDesc[idx];
@@ -183,25 +178,6 @@ static screenfade_t *pfnRefGetScreenFade( void )
return &clgame.fade; return &clgame.fade;
} }
/*
===============
R_DoResetGamma
gamma will be reset for
some type of screenshots
===============
*/
static qboolean R_DoResetGamma( void )
{
switch( cls.scrshot_action )
{
case scrshot_envshot:
case scrshot_skyshot:
return true;
default:
return false;
}
}
static qboolean R_Init_Video_( const int type ) static qboolean R_Init_Video_( const int type )
{ {
host.apply_opengl_config = true; host.apply_opengl_config = true;
@@ -246,16 +222,12 @@ static ref_api_t gEngfuncs =
Con_DrawString, Con_DrawString,
CL_DrawCenterPrint, CL_DrawCenterPrint,
CL_GetLocalPlayer,
CL_GetViewModel,
CL_GetEntityByIndex,
R_BeamGetEntity, R_BeamGetEntity,
CL_GetWaterEntity, CL_GetWaterEntity,
CL_AddVisibleEntity, CL_AddVisibleEntity,
Mod_SampleSizeForFace, Mod_SampleSizeForFace,
Mod_BoxVisible, Mod_BoxVisible,
pfnGetWorld,
Mod_PointInLeaf, Mod_PointInLeaf,
Mod_CreatePolygonsForHull, Mod_CreatePolygonsForHull,
@@ -272,12 +244,9 @@ static ref_api_t gEngfuncs =
Mod_ForName, Mod_ForName,
pfnMod_Extradata, pfnMod_Extradata,
CL_ModelHandle,
CL_EntitySetRemapColors,
CL_GetRemapInfoForEntity, CL_GetRemapInfoForEntity,
CL_AllocRemapInfo,
CL_FreeRemapInfo,
CL_UpdateRemapInfo,
CL_ExtraUpdate, CL_ExtraUpdate,
Host_Error, Host_Error,
@@ -285,9 +254,6 @@ static ref_api_t gEngfuncs =
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,
pfnRefGetScreenFade, pfnRefGetScreenFade,
CL_TextMessageGet,
pfnGetPredictedOrigin,
pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo, pfnCL_GetScreenInfo,
pfnSetLocalLightLevel, pfnSetLocalLightLevel,
Sys_CheckParm, Sys_CheckParm,
@@ -321,9 +287,11 @@ static ref_api_t gEngfuncs =
SW_LockBuffer, SW_LockBuffer,
SW_UnlockBuffer, SW_UnlockBuffer,
BuildGammaTable,
LightToTexGamma, LightToTexGamma,
R_DoResetGamma, LightToTexGammaEx,
TextureToGamma,
ScreenGammaTable,
LinearGammaTable,
CL_GetLightStyle, CL_GetLightStyle,
CL_GetDynamicLight, CL_GetDynamicLight,
@@ -337,7 +305,6 @@ static ref_api_t gEngfuncs =
PM_CL_TraceLine, PM_CL_TraceLine,
CL_VisTraceLine, CL_VisTraceLine,
CL_TraceLine, CL_TraceLine,
pfnGetMoveVars,
Image_AddCmdFlags, Image_AddCmdFlags,
Image_SetForceFlags, Image_SetForceFlags,
@@ -349,7 +316,6 @@ static ref_api_t gEngfuncs =
FS_CopyImage, FS_CopyImage,
FS_FreeImage, FS_FreeImage,
Image_SetMDLPointer, Image_SetMDLPointer,
pfnImage_GetPool,
pfnImage_GetPFDesc, pfnImage_GetPFDesc,
pfnDrawNormalTriangles, pfnDrawNormalTriangles,
@@ -431,7 +397,7 @@ static qboolean R_LoadProgs( const char *name )
// make local copy of engfuncs to prevent overwrite it with user dll // make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs )); memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState )) if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
{ {
COM_FreeLibrary( ref.hInstance ); COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" ); Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
@@ -569,6 +535,9 @@ static void R_CollectRendererNames( void )
#if XASH_REF_GL4ES_ENABLED #if XASH_REF_GL4ES_ENABLED
"gl4es", "gl4es",
#endif #endif
#if XASH_REF_GLES3COMPAT_ENABLED
"gles3compat",
#endif
#if XASH_REF_SOFT_ENABLED #if XASH_REF_SOFT_ENABLED
"soft", "soft",
#endif #endif
@@ -589,6 +558,9 @@ static void R_CollectRendererNames( void )
#if XASH_REF_GL4ES_ENABLED #if XASH_REF_GL4ES_ENABLED
"GL4ES", "GL4ES",
#endif #endif
#if XASH_REF_GLES3COMPAT_ENABLED
"GLES3 (gl2_shim)"
#endif
#if XASH_REF_SOFT_ENABLED #if XASH_REF_SOFT_ENABLED
"Software", "Software",
#endif #endif

View File

@@ -52,7 +52,6 @@ extern convar_t gl_clear;
qboolean R_Init( void ); qboolean R_Init( void );
void R_Shutdown( void ); void R_Shutdown( void );
void R_UpdateRefState( void );
extern triangleapi_t gTriApi; extern triangleapi_t gTriApi;

View File

@@ -1,6 +1,7 @@
/* /*
s_dsp.c - digital signal processing algorithms for audio FX s_dsp.c - digital signal processing algorithms for audio FX
Copyright (C) 2009 Uncle Mike Copyright (C) 2009 Uncle Mike
Copyright (C) 2016-2024 Alibek Omarov
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -333,7 +334,7 @@ DLY_MovePointer
Checks overflow and moves pointer Checks overflow and moves pointer
============ ============
*/ */
_inline void DLY_MovePointer( dly_t *dly ) static void DLY_MovePointer( dly_t *dly )
{ {
if( ++dly->idelayinput >= dly->cdelaysamplesmax ) if( ++dly->idelayinput >= dly->cdelaysamplesmax )
dly->idelayinput = 0; dly->idelayinput = 0;
@@ -806,13 +807,9 @@ DSP_Process
(xash dsp interface) (xash dsp interface)
=========== ===========
*/ */
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount ) void DSP_Process( portable_samplepair_t *pbfront, int sampleCount )
{ {
if( dsp_off.value ) if( dsp_off.value || !sampleCount )
return;
// don't process DSP while in menu
if( cls.key_dest == key_menu || !sampleCount )
return; return;
// preset is already installed by CheckNewDspPresets // preset is already installed by CheckNewDspPresets
@@ -833,7 +830,7 @@ DSP_ClearState
*/ */
void DSP_ClearState( void ) void DSP_ClearState( void )
{ {
Cvar_SetValue( "room_type", 0.0f ); Cvar_DirectSet( &room_type, "0" );
SX_ReloadRoomFX(); SX_ReloadRoomFX();
} }
@@ -892,15 +889,15 @@ void CheckNewDspPresets( void )
cur = ptable + idsp_room; cur = ptable + idsp_room;
Cvar_SetValue( "room_lp", cur->room_lp ); Cvar_DirectSetValue( &sxmod_lowpass, cur->room_lp );
Cvar_SetValue( "room_mod", cur->room_mod ); Cvar_DirectSetValue( &sxmod_mod, cur->room_mod );
Cvar_SetValue( "room_size", cur->room_size ); Cvar_DirectSetValue( &sxrvb_size, cur->room_size );
Cvar_SetValue( "room_refl", cur->room_refl ); Cvar_DirectSetValue( &sxrvb_feedback, cur->room_refl );
Cvar_SetValue( "room_rvblp", cur->room_rvblp ); Cvar_DirectSetValue( &sxrvb_lp, cur->room_rvblp );
Cvar_SetValue( "room_delay", cur->room_delay ); Cvar_DirectSetValue( &sxdly_delay, cur->room_delay );
Cvar_SetValue( "room_feedback", cur->room_feedback ); Cvar_DirectSetValue( &sxdly_feedback, cur->room_feedback );
Cvar_SetValue( "room_dlylp", cur->room_dlylp ); Cvar_DirectSetValue( &sxdly_lp, cur->room_dlylp );
Cvar_SetValue( "room_left", cur->room_left ); Cvar_DirectSetValue( &sxste_delay, cur->room_left );
} }
room_typeprev = idsp_room; room_typeprev = idsp_room;
@@ -929,7 +926,7 @@ static void SX_Profiling_f( void )
if( Cmd_Argc() > 1 ) if( Cmd_Argc() > 1 )
{ {
Cvar_SetValue( "room_type", Q_atof( Cmd_Argv( 1 ))); Cvar_DirectSetValue( &room_type, Q_atof( Cmd_Argv( 1 )));
SX_ReloadRoomFX(); SX_ReloadRoomFX();
CheckNewDspPresets(); // we just need idsp_room immediately, for message below CheckNewDspPresets(); // we just need idsp_room immediately, for message below
} }
@@ -939,7 +936,7 @@ static void SX_Profiling_f( void )
start = Sys_DoubleTime(); start = Sys_DoubleTime();
for( calls = 10000; calls; calls-- ) for( calls = 10000; calls; calls-- )
{ {
DSP_Process( idsp_room, testbuffer, 512 ); DSP_Process( testbuffer, 512 );
} }
end = Sys_DoubleTime(); end = Sys_DoubleTime();
@@ -947,7 +944,7 @@ static void SX_Profiling_f( void )
if( Cmd_Argc() > 1 ) if( Cmd_Argc() > 1 )
{ {
Cvar_SetValue( "room_type", oldroom ); Cvar_DirectSetValue( &room_type, oldroom );
SX_ReloadRoomFX(); SX_ReloadRoomFX();
CheckNewDspPresets(); CheckNewDspPresets();
} }

View File

@@ -648,20 +648,6 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
// Init client entity mouth movement vars // Init client entity mouth movement vars
SND_InitMouth( ent, chan ); SND_InitMouth( ent, chan );
for( ch_idx = NUM_AMBIENTS, check = channels + NUM_AMBIENTS; ch_idx < MAX_DYNAMIC_CHANNELS; ch_idx++, check++)
{
if( check == target_chan ) continue;
if( check->sfx == sfx && !check->pMixer.sample )
{
// skip up to 0.1 seconds of audio
int skip = COM_RandomLong( 0, (long)( 0.1f * check->sfx->cache->rate ));
S_SetSampleStart( check, sfx->cache, skip );
break;
}
}
} }
/* /*

View File

@@ -999,7 +999,8 @@ void MIX_PaintChannels( int endtime )
MIX_UpsampleAllPaintbuffers( end, count ); MIX_UpsampleAllPaintbuffers( end, count );
// process all sounds with DSP // process all sounds with DSP
DSP_Process( idsp_room, MIX_GetPFrontFromIPaint( IROOMBUFFER ), count ); if( cls.key_dest != key_menu )
DSP_Process( MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
// add music or soundtrack from movie (no dsp) // add music or soundtrack from movie (no dsp)
MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() ); MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() );

View File

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

View File

@@ -16,204 +16,6 @@ GNU General Public License for more details.
#include "common.h" #include "common.h"
#include "sound.h" #include "sound.h"
// hardcoded macros to test for zero crossing
#define ZERO_X_8( b ) (( b ) < 2 && ( b ) > -2 )
#define ZERO_X_16( b ) (( b ) < 512 && ( b ) > -512 )
//-----------------------------------------------------------------------------
// Purpose: Search backward for a zero crossing starting at sample
// Input : sample - starting point
// Output : position of zero crossing
//-----------------------------------------------------------------------------
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample )
{
if( pWaveData == NULL )
return sample;
if( pWaveData->type == WF_PCMDATA )
{
int sampleSize;
sampleSize = pWaveData->width * pWaveData->channels;
// this can never be zero -- other functions divide by this.
// This should never happen, but avoid crashing
if( sampleSize <= 0 ) sampleSize = 1;
if( pWaveData->width == 1 )
{
signed char *pData = (signed char *)(pWaveData->buffer + sample * sampleSize);
qboolean zero = false;
if( pWaveData->channels == 1 )
{
while( sample > 0 && !zero )
{
if( ZERO_X_8( *pData ))
{
zero = true;
}
else
{
sample--;
pData--;
}
}
}
else
{
while( sample > 0 && !zero )
{
if( ZERO_X_8( *pData ) && ZERO_X_8( pData[1] ))
{
zero = true;
}
else
{
sample--;
pData--;
}
}
}
}
else
{
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
qboolean zero = false;
if( pWaveData->channels == 1 )
{
while( sample > 0 && !zero )
{
if( ZERO_X_16(*pData ))
{
zero = true;
}
else
{
pData--;
sample--;
}
}
}
else
{
while( sample > 0 && !zero )
{
if( ZERO_X_16( *pData ) && ZERO_X_16( pData[1] ))
{
zero = true;
}
else
{
sample--;
pData--;
}
}
}
}
}
return sample;
}
//-----------------------------------------------------------------------------
// Purpose: Search forward for a zero crossing
// Input : sample - starting point
// Output : position of found zero crossing
//-----------------------------------------------------------------------------
int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample )
{
if( pWaveData == NULL )
return sample;
if( pWaveData->type == WF_PCMDATA )
{
int sampleSize;
sampleSize = pWaveData->width * pWaveData->channels;
// this can never be zero -- other functions divide by this.
// This should never happen, but avoid crashing
if( sampleSize <= 0 ) sampleSize = 1;
if( pWaveData->width == 1 ) // 8-bit
{
signed char *pData = (signed char *)(pWaveData->buffer + sample * sampleSize);
qboolean zero = false;
if( pWaveData->channels == 1 )
{
while( sample < pWaveData->samples && !zero )
{
if( ZERO_X_8( *pData ))
{
zero = true;
}
else
{
sample++;
pData++;
}
}
}
else
{
while( sample < pWaveData->samples && !zero )
{
if( ZERO_X_8( *pData ) && ZERO_X_8( pData[1] ))
{
zero = true;
}
else
{
sample++;
pData++;
}
}
}
}
else
{
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
qboolean zero = false;
if( pWaveData->channels == 1 )
{
while( sample > 0 && !zero )
{
if( ZERO_X_16( *pData ))
{
zero = true;
}
else
{
pData++;
sample++;
}
}
}
else
{
while( sample > 0 && !zero )
{
if( ZERO_X_16( *pData ) && ZERO_X_16( pData[1] ))
{
zero = true;
}
else
{
sample++;
pData++;
}
}
}
}
}
return sample;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: wrap the position wrt looping // Purpose: wrap the position wrt looping
// Input : samplePosition - absolute position // Input : samplePosition - absolute position
@@ -279,28 +81,3 @@ int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int s
return sampleCount; return sampleCount;
} }
// move the current position to newPosition
void S_SetSampleStart( channel_t *pChan, wavdata_t *pSource, int newPosition )
{
if( pSource )
newPosition = S_ZeroCrossingAfter( pSource, newPosition );
pChan->pMixer.sample = newPosition;
}
// end playback at newEndPosition
void S_SetSampleEnd( channel_t *pChan, wavdata_t *pSource, int newEndPosition )
{
// forced end of zero means play the whole sample
if( !newEndPosition ) newEndPosition = 1;
if( pSource )
newEndPosition = S_ZeroCrossingBefore( pSource, newEndPosition );
// past current position? limit.
if( newEndPosition < pChan->pMixer.sample )
newEndPosition = pChan->pMixer.sample;
pChan->pMixer.forcedEndSample = newEndPosition;
}

View File

@@ -18,10 +18,126 @@ GNU General Public License for more details.
#include "const.h" #include "const.h"
#include <ctype.h> #include <ctype.h>
#define TRIM_SCAN_MAX 255
#define TRIM_SAMPLES_BELOW_8 2
#define TRIM_SAMPLES_BELOW_16 512 // 65k * 2 / 256
#define CVOXFILESENTENCEMAX 4096
static int cszrawsentences = 0; static int cszrawsentences = 0;
static char *rgpszrawsentence[CVOXFILESENTENCEMAX]; static char *rgpszrawsentence[CVOXFILESENTENCEMAX];
static const char *voxperiod = "_period", *voxcomma = "_comma"; static const char *voxperiod = "_period", *voxcomma = "_comma";
static qboolean S_ShouldTrimSample8( const int8_t *buf, int channels )
{
if( abs( buf[0] ) > TRIM_SAMPLES_BELOW_8 )
return false;
if( channels >= 2 && abs( buf[1] ) > TRIM_SAMPLES_BELOW_8 )
return false;
return true;
}
static qboolean S_ShouldTrimSample16( const int16_t *buf, int channels )
{
if( abs( buf[0] ) > TRIM_SAMPLES_BELOW_16 )
return false;
if( channels >= 2 && abs( buf[1] ) > TRIM_SAMPLES_BELOW_16 )
return false;
return true;
}
static int S_TrimStart( const wavdata_t *wav, int start )
{
size_t channels = wav->channels, width = wav->width, i;
if( wav->type != WF_PCMDATA )
return start;
if( width == 1 )
{
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * start];
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
{
if( !S_ShouldTrimSample8( data, wav->channels ))
break;
start += channels;
data += channels;
}
}
else if( width == 2 )
{
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * start];
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
{
if( !S_ShouldTrimSample16( data, wav->channels ))
break;
start += channels;
data += channels;
}
}
return start;
}
static int S_TrimEnd( const wavdata_t *wav, int end )
{
size_t channels = wav->channels, width = wav->width, i;
if( wav->type != WF_PCMDATA )
return end;
if( width == 1 )
{
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * end];
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
{
if( !S_ShouldTrimSample8( data, wav->channels ))
break;
end -= channels;
data -= channels;
}
}
else if( width == 2 )
{
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * end];
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
{
if( !S_ShouldTrimSample16( data, wav->channels ))
break;
end -= channels;
data -= channels;
}
}
return end;
}
static void S_TrimStartEndTimes( channel_t *ch, wavdata_t *wav, int start, int end )
{
ch->pMixer.sample = start = S_TrimStart( wav, start );
// don't overrun the buffer while trimming end
if( end == 0 )
end = wav->samples - wav->channels;
if( end < start )
end = start;
ch->pMixer.forcedEndSample = S_TrimEnd( wav, end );
}
// return number of samples mixed // return number of samples mixed
int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset ) int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset )
{ {
@@ -78,11 +194,7 @@ void VOX_LoadWord( channel_t *ch )
if( end <= start ) end = 0; if( end <= start ) end = 0;
if( start ) S_TrimStartEndTimes( ch, data, start * 0.01f * samples, end * 0.01f * samples );
S_SetSampleStart( ch, data, start * 0.01f * samples );
if( end )
S_SetSampleEnd( ch, data, end * 0.01f * samples );
} }
void VOX_FreeWord( channel_t *ch ) void VOX_FreeWord( channel_t *ch )

View File

@@ -255,8 +255,7 @@ void S_InitSounds( void );
void SX_Init( void ); void SX_Init( void );
void SX_Free( void ); void SX_Free( void );
void CheckNewDspPresets( void ); void CheckNewDspPresets( void );
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount ); void DSP_Process( portable_samplepair_t *pbfront, int sampleCount );
float DSP_GetGain( int idsp );
void DSP_ClearState( void ); void DSP_ClearState( void );
qboolean S_Init( void ); qboolean S_Init( void );
@@ -305,8 +304,6 @@ int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample );
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample ); int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample );
int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean use_loop ); int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean use_loop );
int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount, qboolean use_loop ); int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount, qboolean use_loop );
void S_SetSampleStart( channel_t *pChan, wavdata_t *pSource, int newPosition );
void S_SetSampleEnd( channel_t *pChan, wavdata_t *pSource, int newEndPosition );
// //
// s_vox.c // s_vox.c

View File

@@ -22,8 +22,6 @@ GNU General Public License for more details.
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" ); static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" ); static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
static CVAR_DEFINE( vid_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
static CVAR_DEFINE( vid_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" ); static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" );
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" ); static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" ); static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
@@ -36,19 +34,6 @@ CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window positi
glwstate_t glw_state; glwstate_t glw_state;
/*
=================
VID_StartupGamma
=================
*/
void VID_StartupGamma( void )
{
BuildGammaTable( vid_gamma.value, vid_brightness.value );
Con_Reportf( "VID_StartupGamma: gamma %g brightness %g\n", vid_gamma.value, vid_brightness.value );
ClearBits( vid_brightness.flags, FCVAR_CHANGED );
ClearBits( vid_gamma.flags, FCVAR_CHANGED );
}
/* /*
================= =================
VID_InitDefaultResolution VID_InitDefaultResolution
@@ -224,8 +209,6 @@ void VID_Init( void )
Cvar_RegisterVariable( &vid_scale ); Cvar_RegisterVariable( &vid_scale );
Cvar_RegisterVariable( &vid_fullscreen ); Cvar_RegisterVariable( &vid_fullscreen );
Cvar_RegisterVariable( &vid_maximized ); Cvar_RegisterVariable( &vid_maximized );
Cvar_RegisterVariable( &vid_brightness );
Cvar_RegisterVariable( &vid_gamma );
Cvar_RegisterVariable( &window_xpos ); Cvar_RegisterVariable( &window_xpos );
Cvar_RegisterVariable( &window_ypos ); Cvar_RegisterVariable( &window_ypos );
@@ -233,5 +216,6 @@ void VID_Init( void )
// but supported mode list is filled by backends, so numbers are not portable any more // but supported mode list is filled by backends, so numbers are not portable any more
Cmd_AddRestrictedCommand( "vid_setmode", VID_Mode_f, "display video mode" ); Cmd_AddRestrictedCommand( "vid_setmode", VID_Mode_f, "display video mode" );
V_Init(); // init gamma
R_Init(); // init renderer R_Init(); // init renderer
} }

View File

@@ -46,6 +46,5 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximiz
void VID_SetDisplayTransform( int *render_w, int *render_h ); void VID_SetDisplayTransform( int *render_w, int *render_h );
void VID_CheckChanges( void ); void VID_CheckChanges( void );
const char *VID_GetModeString( int vid_mode ); const char *VID_GetModeString( int vid_mode );
void VID_StartupGamma( void );
#endif // VID_COMMON #endif // VID_COMMON

View File

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

View File

@@ -302,8 +302,12 @@ typedef struct host_parm_s
int argc; int argc;
char **argv; char **argv;
// ==== shared through RefAPI's ref_host_t
double realtime; // host.curtime double realtime; // host.curtime
double frametime; // time between engine frames double frametime; // time between engine frames
uint features; // custom features that enables by mod-maker request
// ==== shared through RefAPI's ref_host_t
double realframetime; // for some system events, e.g. console animations double realframetime; // for some system events, e.g. console animations
uint framecount; // global framecount uint framecount; // global framecount
@@ -344,8 +348,6 @@ typedef struct host_parm_s
poolhandle_t imagepool; // imagelib mempool poolhandle_t imagepool; // imagelib mempool
poolhandle_t soundpool; // soundlib mempool poolhandle_t soundpool; // soundlib mempool
uint features; // custom features that enables by mod-maker request
// for IN_MouseMove() easy access // for IN_MouseMove() easy access
int window_center_x; int window_center_x;
int window_center_y; int window_center_y;
@@ -422,8 +424,8 @@ void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
// zone.c // zone.c
// //
void Memory_Init( void ); void Memory_Init( void );
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ); void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ); void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline ); poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline ); void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline ); void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
@@ -552,7 +554,7 @@ qboolean Host_IsLocalGame( void );
qboolean Host_IsLocalClient( void ); qboolean Host_IsLocalClient( void );
void Host_ShutdownServer( void ); void Host_ShutdownServer( void );
void Host_Error( const char *error, ... ) _format( 1 ); void Host_Error( const char *error, ... ) _format( 1 );
void Host_PrintEngineFeatures( void ); void Host_ValidateEngineFeatures( uint32_t features );
void Host_Frame( float time ); void Host_Frame( float time );
void Host_InitDecals( void ); void Host_InitDecals( void );
void Host_Credits( void ); void Host_Credits( void );
@@ -793,7 +795,7 @@ void VID_Init( void );
void UI_SetActiveMenu( qboolean fActive ); void UI_SetActiveMenu( qboolean fActive );
void UI_ShowConnectionWarning( void ); void UI_ShowConnectionWarning( void );
void Cmd_Null_f( void ); void Cmd_Null_f( void );
void Rcon_Print( const char *pMsg ); void Rcon_Print( host_redirect_t *rd, const char *pMsg );
qboolean COM_ParseVector( char **pfile, float *v, size_t size ); qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles ); void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename ); int COM_FileSize( const char *filename );
@@ -810,8 +812,13 @@ void S_StopBackgroundTrack( void );
void S_StopAllSounds( qboolean ambient ); void S_StopAllSounds( qboolean ambient );
// gamma routines // gamma routines
void BuildGammaTable( float gamma, float brightness );
byte LightToTexGamma( byte b ); byte LightToTexGamma( byte b );
byte TextureToGamma( byte );
uint LightToTexGammaEx( uint );
uint ScreenGammaTable( uint );
uint LinearGammaTable( uint );
void V_Init( void );
void V_CheckGamma( void );
// //
// identification.c // identification.c

View File

@@ -320,7 +320,9 @@ void Sys_RestoreCrashHandler( void )
#elif XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX #elif XASH_FREEBSD || XASH_NETBSD || XASH_OPENBSD || XASH_ANDROID || XASH_LINUX
// Posix signal handler // Posix signal handler
#ifndef XASH_OPENBSD
#include <ucontext.h> #include <ucontext.h>
#endif
#include <signal.h> #include <signal.h>
#include <sys/mman.h> #include <sys/mman.h>
#include "library.h" #include "library.h"
@@ -488,7 +490,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
#ifdef XASH_SDL #ifdef XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif #endif
MSGBOX( message ); Platform_MessageBox( "Xash Error", message, false );
// log saved, now we can try to save configs and close log correctly, it may crash // log saved, now we can try to save configs and close log correctly, it may crash
if( host.type == HOST_NORMAL ) if( host.type == HOST_NORMAL )

View File

@@ -563,6 +563,27 @@ void Cvar_RegisterVariable( convar_t *var )
#endif #endif
} }
static qboolean Cvar_CanSet( const convar_t *cv )
{
if( FBitSet( cv->flags, FCVAR_READ_ONLY ))
{
Con_Printf( "%s is read-only.\n", cv->name );
return false;
}
if( FBitSet( cv->flags, FCVAR_CHEAT ) && !host.allow_cheats )
{
Con_Printf( "%s is cheat protected.\n", cv->name );
return false;
}
// just tell user about deferred changes
if( FBitSet( cv->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
Con_Printf( "%s will be changed upon restarting.\n", cv->name );
return true;
}
/* /*
============ ============
Cvar_Set2 Cvar_Set2
@@ -632,22 +653,9 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
force = true; force = true;
if( !force ) if( !force )
{ {
if( FBitSet( var->flags, FCVAR_READ_ONLY )) if( !Cvar_CanSet( var ))
{
Con_Printf( "%s is read-only.\n", var->name );
return var; return var;
}
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
{
Con_Printf( "%s is cheat protected.\n", var->name );
return var;
}
// just tell user about deferred changes
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
Con_Printf( "%s will be changed upon restarting.\n", var->name );
} }
pszValue = Cvar_ValidateString( var, value ); pszValue = Cvar_ValidateString( var, value );
@@ -694,21 +702,8 @@ void Cvar_DirectSet( convar_t *var, const char *value )
return; // how this possible? return; // how this possible?
} }
if( FBitSet( var->flags, FCVAR_READ_ONLY )) if( !Cvar_CanSet( var ))
{
Con_Printf( "%s is read-only.\n", var->name );
return; return;
}
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
{
Con_Printf( "%s is cheat protected.\n", var->name );
return;
}
// just tell user about deferred changes
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
Con_Printf( "%s will be changed upon restarting.\n", var->name );
// check value // check value
if( !value ) if( !value )
@@ -741,6 +736,24 @@ void Cvar_DirectSet( convar_t *var, const char *value )
Cvar_Changed( var ); Cvar_Changed( var );
} }
/*
============
Cvar_DirectSetValue
functionally is the same as Cvar_SetValue but for direct cvar access
============
*/
void Cvar_DirectSetValue( convar_t *var, float value )
{
char val[32];
if( fabs( value - (int)value ) < 0.000001 )
Q_snprintf( val, sizeof( val ), "%d", (int)value );
else Q_snprintf( val, sizeof( val ), "%f", value );
Cvar_DirectSet( var, val );
}
/* /*
============ ============
Cvar_FullSet Cvar_FullSet
@@ -1136,8 +1149,6 @@ As Cvar_Set, but also flags it as glconfig
*/ */
void Cvar_SetGL_f( void ) void Cvar_SetGL_f( void )
{ {
convar_t *var;
if( Cmd_Argc() != 3 ) if( Cmd_Argc() != 3 )
{ {
Con_Printf( S_USAGE "setgl <variable> <value>\n" ); Con_Printf( S_USAGE "setgl <variable> <value>\n" );

View File

@@ -66,6 +66,7 @@ convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, c
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback ); void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
void Cvar_FullSet( const char *var_name, const char *value, int flags ); void Cvar_FullSet( const char *var_name, const char *value, int flags );
void Cvar_DirectSet( convar_t *var, const char *value ); void Cvar_DirectSet( convar_t *var, const char *value );
void Cvar_DirectSetValue( convar_t *var, float value );
void Cvar_Set( const char *var_name, const char *value ); void Cvar_Set( const char *var_name, const char *value );
void Cvar_SetValue( const char *var_name, float value ); void Cvar_SetValue( const char *var_name, float value );
const char *Cvar_BuildAutoDescription( const char *szName, int flags ); const char *Cvar_BuildAutoDescription( const char *szName, int flags );

View File

@@ -247,4 +247,14 @@ void CL_HudMessage( const char *pMessage )
} }
byte TextureToGamma( byte b )
{
return b;
}
byte LightToTexGamma( byte b )
{
return b;
}
#endif // XASH_DEDICATED #endif // XASH_DEDICATED

View File

@@ -1,78 +0,0 @@
/*
gamma.c - gamma routines
Copyright (C) 2011 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "xash3d_mathlib.h"
#include "enginefeatures.h"
//-----------------------------------------------------------------------------
// Gamma conversion support
//-----------------------------------------------------------------------------
static byte lightgammatable[256];
static int lineargammatable[1024];
static int screengammatable[1024];
void BuildGammaTable( float lightgamma, float brightness )
{
int i, inf;
float f, g, g1, g3;
lightgamma = bound( 1.8f, lightgamma, 3.0f );
brightness = bound( 0.0f, brightness, 10.0f );
if( brightness <= 0.0f )
g3 = 0.125f;
else if( brightness > 1.0f )
g3 = 0.05f;
else g3 = 0.125f - (brightness * brightness) * 0.075f;
g = 1.0f / lightgamma;
g1 = GAMMA * g;
for( i = 0; i < 256; i++ )
{
f = pow( i / 255.f, GAMMA );
// scale up
if( brightness > 1.0f )
f = f * brightness;
// shift up
if( f <= g3 ) f = (f / g3) * 0.125f;
else f = 0.125f + ((f - g3) / (1.0f - g3)) * 0.875f;
// convert linear space to desired gamma space
inf = (int)( 255.0f * pow( f, g ));
lightgammatable[i] = bound( 0, inf, 255 );
}
for( i = 0; i < 1024; i++ )
{
// convert from screen gamma space to linear space
lineargammatable[i] = 1023 * pow( i / 1023.0f, g1 );
// convert from linear gamma space to screen space
screengammatable[i] = 1023 * pow( i / 1023.0f, 1.0f / g1 );
}
}
byte LightToTexGamma( byte b )
{
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
return b;
else
return lightgammatable[b];
}

View File

@@ -52,7 +52,7 @@ struct tests_stats_s tests_stats;
#endif #endif
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" ); CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" ); CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" );
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" ); CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" ); static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" );
@@ -62,6 +62,7 @@ CVAR_DEFINE_AUTO( host_limitlocal, "0", 0, "apply cl_cmdrate and rate to loopbac
CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" ); CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" ); static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" ); static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
static CVAR_DEFINE_AUTO( host_sleeptime_debug, "0", 0, "print sleeps between frames" );
CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" ); CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
void Sys_PrintUsage( void ) void Sys_PrintUsage( void )
@@ -139,7 +140,7 @@ void Sys_PrintUsage( void )
O("-sdl_joy_old_api ","use SDL legacy joystick API") O("-sdl_joy_old_api ","use SDL legacy joystick API")
O("-sdl_renderer <n>","use alternative SDL_Renderer for software") O("-sdl_renderer <n>","use alternative SDL_Renderer for software")
#endif // XASH_SDL #endif // XASH_SDL
#if XASH_ANDROID #if XASH_ANDROID && !XASH_SDL
O("-nativeegl ","use native egl implementation. Use if screen does not update or black") O("-nativeegl ","use native egl implementation. Use if screen does not update or black")
#endif // XASH_ANDROID #endif // XASH_ANDROID
#if XASH_DOS #if XASH_DOS
@@ -189,22 +190,66 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures Host_PrintEngineFeatures
================ ================
*/ */
void Host_PrintEngineFeatures( void ) static void Host_PrintEngineFeatures( int features )
{ {
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD )) struct
Con_Reportf( "^3EXT:^7 big world support enabled\n" ); {
uint32_t mask;
const char *msg;
} features_str[] =
{
{ ENGINE_WRITE_LARGE_COORD, "Big World Support" },
{ ENGINE_QUAKE_COMPATIBLE, "Quake Compatibility" },
{ ENGINE_LOAD_DELUXEDATA, "Deluxemap Support" },
{ ENGINE_PHYSICS_PUSHER_EXT, "Improved MOVETYPE_PUSH" },
{ ENGINE_LARGE_LIGHTMAPS, "Large Lightmaps" },
{ ENGINE_COMPENSATE_QUAKE_BUG, "Stupid Quake Bug Compensation" },
{ ENGINE_IMPROVED_LINETRACE, "Improved Trace Line" },
{ ENGINE_COMPUTE_STUDIO_LERP, "Studio MOVETYPE_STEP Lerping" },
{ ENGINE_LINEAR_GAMMA_SPACE, "Linear Gamma Space" },
{ ENGINE_STEP_POSHISTORY_LERP, "MOVETYPE_STEP Position History Based Lerping" },
};
int i;
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA )) for( i = 0; i < ARRAYSIZE( features_str ); i++ )
Con_Reportf( "^3EXT:^7 deluxemap support enabled\n" ); {
if( FBitSet( features, features_str[i].mask ))
Con_Reportf( "^3EXT:^7 %s is enabled\n", features_str[i].msg );
}
}
if( FBitSet( host.features, ENGINE_PHYSICS_PUSHER_EXT )) /*
Con_Reportf( "^3EXT:^7 Improved MOVETYPE_PUSH is used\n" ); ==============
Host_ValidateEngineFeatures
if( FBitSet( host.features, ENGINE_LARGE_LIGHTMAPS )) validate features bits and set host.features
Con_Reportf( "^3EXT:^7 Large lightmaps enabled\n" ); ==============
*/
void Host_ValidateEngineFeatures( uint32_t features )
{
uint32_t mask = ENGINE_FEATURES_MASK;
if( FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG )) #if !HOST_DEDICATED
Con_Reportf( "^3EXT:^7 Compensate quake bug enabled\n" ); if( !Host_IsDedicated( ) && cls.legacymode )
mask = ENGINE_LEGACY_FEATURES_MASK;
#endif
// don't allow unsupported bits
features &= mask;
// force bits for some games
if( !Q_stricmp( GI->gamefolder, "cstrike" ) || !Q_stricmp( GI->gamefolder, "czero" ))
SetBits( features, ENGINE_STEP_POSHISTORY_LERP );
// print requested first
Host_PrintEngineFeatures( features );
// now warn about incompatible bits
if( FBitSet( features, ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ) == ( ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ))
Con_Printf( S_WARN "%s: incompatible ENGINE_STEP_POSHISTORY_LERP and ENGINE_COMPUTE_STUDIO_LERP are enabled!\n", __func__ );
// finally set global variable
host.features = features;
} }
/* /*
@@ -618,6 +663,84 @@ double Host_CalcFPS( void )
return fps; return fps;
} }
static qboolean Host_Autosleep( double dt, double scale )
{
double targetframetime, fps;
int sleep;
fps = Host_CalcFPS();
if( fps <= 0 )
return true;
// limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS );
if( Host_IsDedicated( ))
targetframetime = ( 1.0 / ( fps + 1.0 ));
else targetframetime = ( 1.0 / fps );
sleep = Host_CalcSleep();
if( sleep == 0 ) // no sleeps between frames, much simpler code
{
if( dt < targetframetime * scale )
return false;
}
else
{
static double timewindow; // allocate a time window for sleeps
static int counter; // for debug
static double realsleeptime;
const double sleeptime = sleep * 0.001;
if( dt < targetframetime * scale )
{
// if we have allocated time window, try to sleep
if( timewindow > realsleeptime )
{
// Sys_Sleep isn't guaranteed to sleep an exact amount of milliseconds
// so we measure the real sleep time and use it to decrease the window
double t1 = Sys_DoubleTime(), t2;
Sys_Sleep( sleep ); // in msec!
t2 = Sys_DoubleTime();
realsleeptime = t2 - t1;
timewindow -= realsleeptime;
if( host_sleeptime_debug.value )
{
counter++;
Con_NPrintf( counter, "%d: %.4f %.4f", counter, timewindow, realsleeptime );
}
}
return false;
}
// if we exhausted this time window, allocate a new one after new frame
if( timewindow <= realsleeptime )
{
double targetsleeptime = targetframetime - host.pureframetime * 2;
if( targetsleeptime > 0 )
timewindow = targetsleeptime;
else timewindow = 0;
realsleeptime = sleeptime; // reset in case CPU was too busy
if( host_sleeptime_debug.value )
{
counter = 0;
Con_NPrintf( 0, "tgt = %.4f, pft = %.4f, wnd = %.4f", targetframetime, host.pureframetime, timewindow );
}
}
}
return true;
}
/* /*
=================== ===================
Host_FilterTime Host_FilterTime
@@ -628,55 +751,15 @@ Returns false if the time is too short to run a frame
qboolean Host_FilterTime( float time ) qboolean Host_FilterTime( float time )
{ {
static double oldtime; static double oldtime;
double fps, scale = sys_timescale.value; double dt;
double scale = sys_timescale.value;
host.realtime += time * scale; host.realtime += time * scale;
fps = Host_CalcFPS(); dt = host.realtime - oldtime;
// clamp the fps in multiplayer games // clamp the fps in multiplayer games
if( fps != 0.0 ) if( !Host_Autosleep( dt, scale ))
{ return false;
static int sleeps;
double targetframetime;
int sleeptime = Host_CalcSleep();
// limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS );
if( Host_IsDedicated( ))
targetframetime = ( 1.0 / ( fps + 1.0 ));
else targetframetime = ( 1.0 / fps );
if(( host.realtime - oldtime ) < targetframetime * scale )
{
if( sleeptime > 0 && sleeps > 0 )
{
Sys_Sleep( sleeptime );
sleeps--;
}
return false;
}
if( sleeptime > 0 && sleeps <= 0 )
{
if( host.status == HOST_FRAME )
{
// give few sleeps this frame with small margin
double targetsleeptime = targetframetime - host.pureframetime * 2;
// don't sleep if we can't keep up with the framerate
if( targetsleeptime > 0 )
sleeps = targetsleeptime / ( sleeptime * 0.001 );
else sleeps = 0;
}
else
{
// always sleep at least once in minimized/nofocus state
sleeps = 1;
}
}
}
host.frametime = host.realtime - oldtime; host.frametime = host.realtime - oldtime;
host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME ); host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
@@ -756,7 +839,7 @@ void GAME_EXPORT Host_Error( const char *error, ... )
Key_SetKeyDest( key_console ); Key_SetKeyDest( key_console );
Con_Printf( "Host_Error: %s", hosterror1 ); Con_Printf( "Host_Error: %s", hosterror1 );
} }
else MSGBOX2( hosterror1 ); else Platform_MessageBox( "Host Error", hosterror1, true );
} }
// host is shutting down. don't invoke infinite loop // host is shutting down. don't invoke infinite loop
@@ -871,7 +954,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
int developer = DEFAULT_DEV; int developer = DEFAULT_DEV;
const char *baseDir; const char *baseDir;
char ticrate[16]; char ticrate[16];
int len; int len, i;
// some commands may turn engine into infinite loop, // some commands may turn engine into infinite loop,
// e.g. xash.exe +game xash -game xash // e.g. xash.exe +game xash -game xash
@@ -946,7 +1029,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
progname++; progname++;
Q_strncpy( SI.exeName, progname, sizeof( SI.exeName )); Q_strncpy( SI.exeName, progname, sizeof( SI.exeName ));
Q_strncpy( SI.basedirName, progname, sizeof( SI.exeName )); Q_strncpy( SI.basedirName, progname, sizeof( SI.basedirName ));
if( Host_IsDedicated() ) if( Host_IsDedicated() )
{ {
@@ -1118,12 +1201,25 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
FS_LoadGameInfo( NULL ); FS_LoadGameInfo( NULL );
Cvar_PostFSInit(); Cvar_PostFSInit();
if( FS_FileExists( va( "%s.rc", SI.basedirName ), false ))
Q_strncpy( SI.rcName, SI.basedirName, sizeof( SI.rcName )); // e.g. valve.rc
else Q_strncpy( SI.rcName, SI.exeName, sizeof( SI.rcName )); // e.g. quake.rc
Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder )); Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));
for( i = 0; i < 3; i++ )
{
const char *rcName;
switch( i )
{
case 0: rcName = SI.basedirName; break; // e.g. valve.rc
case 1: rcName = SI.exeName; break; // e.g. quake.rc
case 2: rcName = host.gamefolder; break; // e.g. game.rc (ran from default launcher)
}
if( FS_FileExists( va( "%s.rc", rcName ), false ))
{
Q_strncpy( SI.rcName, rcName, sizeof( SI.rcName ));
break;
}
}
Image_CheckPaletteQ1 (); Image_CheckPaletteQ1 ();
Host_InitDecals (); // reload decals Host_InitDecals (); // reload decals
@@ -1181,6 +1277,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cvar_RegisterVariable( &host_maxfps ); Cvar_RegisterVariable( &host_maxfps );
Cvar_RegisterVariable( &host_framerate ); Cvar_RegisterVariable( &host_framerate );
Cvar_RegisterVariable( &host_sleeptime ); Cvar_RegisterVariable( &host_sleeptime );
Cvar_RegisterVariable( &host_sleeptime_debug );
Cvar_RegisterVariable( &host_gameloaded ); Cvar_RegisterVariable( &host_gameloaded );
Cvar_RegisterVariable( &host_clientloaded ); Cvar_RegisterVariable( &host_clientloaded );
Cvar_RegisterVariable( &host_limitlocal ); Cvar_RegisterVariable( &host_limitlocal );
@@ -1297,6 +1394,8 @@ Host_Shutdown
*/ */
void EXPORT Host_Shutdown( void ) void EXPORT Host_Shutdown( void )
{ {
qboolean error = host.status == HOST_ERR_FATAL;
if( host.shutdown_issued ) return; if( host.shutdown_issued ) return;
host.shutdown_issued = true; host.shutdown_issued = true;
@@ -1304,7 +1403,7 @@ void EXPORT Host_Shutdown( void )
if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg )); if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
#if !XASH_DEDICATED #if !XASH_DEDICATED
if( host.type == HOST_NORMAL ) if( host.type == HOST_NORMAL && !error )
Host_WriteConfig(); Host_WriteConfig();
#endif #endif

View File

@@ -57,6 +57,8 @@ void COM_NewGame( char const *pMapName )
GameState->landmarkName[0] = 0; GameState->landmarkName[0] = 0;
GameState->loadGame = false; GameState->loadGame = false;
GameState->newGame = true; GameState->newGame = true;
SV_ShutdownGame(); // exit from current game
} }
void COM_LoadLevel( char const *pMapName, qboolean background ) void COM_LoadLevel( char const *pMapName, qboolean background )
@@ -74,6 +76,8 @@ void COM_LoadLevel( char const *pMapName, qboolean background )
GameState->landmarkName[0] = 0; GameState->landmarkName[0] = 0;
GameState->loadGame = false; GameState->loadGame = false;
GameState->newGame = false; GameState->newGame = false;
SV_ShutdownGame(); // exit from current game
} }
void COM_LoadGame( char const *pMapName ) void COM_LoadGame( char const *pMapName )

View File

@@ -87,6 +87,12 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer
return false; return false;
} }
if( header->levelCount == 0 )
{
Con_DPrintf( S_ERROR "%s: file has no mip levels\n", __FUNCTION__ );
return false;
}
if( header->pixelDepth > 1 ) if( header->pixelDepth > 1 )
{ {
Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth ); Con_DPrintf( S_ERROR "%s: unsupported KTX2 pixelDepth %d\n", __FUNCTION__, header->pixelDepth );

View File

@@ -287,16 +287,15 @@ void Image_SetPalette( const byte *pal, uint *d_table )
uint uirgba; // TODO: palette looks byte-swapped on big-endian uint uirgba; // TODO: palette looks byte-swapped on big-endian
int i; int i;
// setup palette // setup palette
switch( image.d_rendermode ) switch( image.d_rendermode )
{ {
case LUMP_NORMAL: case LUMP_NORMAL:
for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
{ {
rgba[0] = pal[i*3+0]; rgba[0] = TextureToGamma( pal[i*3+0] );
rgba[1] = pal[i*3+1]; rgba[1] = TextureToGamma( pal[i*3+1] );
rgba[2] = pal[i*3+2]; rgba[2] = TextureToGamma( pal[i*3+2] );
rgba[3] = 0xFF; rgba[3] = 0xFF;
memcpy( &uirgba, rgba, sizeof( uirgba )); memcpy( &uirgba, rgba, sizeof( uirgba ));
d_table[i] = uirgba; d_table[i] = uirgba;

View File

@@ -13,17 +13,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifdef SINGLE_BINARY #if XASH_ENABLE_MAIN
#if XASH_SDLMAIN
#include "build.h" #include <SDL.h>
#include "common.h"
#ifdef XASH_SDLMAIN
#include "SDL.h"
#endif #endif
#if XASH_EMSCRIPTEN #if XASH_EMSCRIPTEN
#include <emscripten.h> #include <emscripten.h>
#endif #endif
#include "build.h"
#include "common.h"
#define E_GAME "XASH3D_GAME" // default env dir to start from #define E_GAME "XASH3D_GAME" // default env dir to start from
#ifndef XASH_GAMEDIR #ifndef XASH_GAMEDIR
@@ -47,40 +45,35 @@ static void Sys_ChangeGame( const char *progname )
exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) ); exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) );
} }
_inline int Sys_Start( void ) static int Sys_Start( void )
{ {
int ret;
const char *game = getenv( E_GAME ); const char *game = getenv( E_GAME );
if( !game ) if( !game )
game = XASH_GAMEDIR; game = XASH_GAMEDIR;
Q_strncpy( szGameDir, game, sizeof( szGameDir )); Q_strncpy( szGameDir, game, sizeof( szGameDir ));
#if XASH_EMSCRIPTEN #if XASH_EMSCRIPTEN
#ifdef EMSCRIPTEN_LIB_FS #ifdef EMSCRIPTEN_LIB_FS
// For some unknown reason emscripten refusing to load libraries later // For some unknown reason emscripten refusing to load libraries later
COM_LoadLibrary("menu", 0 ); COM_LoadLibrary( "menu", 0 );
COM_LoadLibrary("server", 0 ); COM_LoadLibrary( "server", 0 );
COM_LoadLibrary("client", 0 ); COM_LoadLibrary( "client", 0 );
#endif #endif
#if XASH_DEDICATED #if XASH_DEDICATED
// NodeJS support for debug // NodeJS support for debug
EM_ASM(try{ EM_ASM(try {
FS.mkdir('/xash'); FS.mkdir( '/xash' );
FS.mount(NODEFS, { root: '.'}, '/xash' ); FS.mount( NODEFS, { root: '.'}, '/xash' );
FS.chdir('/xash'); FS.chdir( '/xash' );
}catch(e){};); } catch( e ) { };);
#endif #endif
#elif XASH_IOS #elif XASH_IOS
{ IOS_LaunchDialog();
void IOS_LaunchDialog( void );
IOS_LaunchDialog();
}
#endif #endif
ret = Host_Main( szArgc, szArgv, game, 0, Sys_ChangeGame ); return Host_Main( szArgc, szArgv, game, 0, Sys_ChangeGame );
return ret;
} }
int main( int argc, char **argv ) int main( int argc, char **argv )
@@ -94,4 +87,4 @@ int main( int argc, char **argv )
#endif // XASH_PSVITA #endif // XASH_PSVITA
return Sys_Start(); return Sys_Start();
} }
#endif // SINGLE_BINARY #endif // XASH_ENABLE_MAIN

View File

@@ -50,7 +50,7 @@ static net_gai_state_t NET_GetMasterHostByName( master_t *m )
if( res == NET_EAI_OK ) if( res == NET_EAI_OK )
return res; return res;
m->adr.type = NA_UNUSED; m->adr.type = 0;
if( res == NET_EAI_NONAME ) if( res == NET_EAI_NONAME )
Con_Reportf( "Can't resolve adr: %s\n", m->address ); Con_Reportf( "Can't resolve adr: %s\n", m->address );
@@ -266,7 +266,7 @@ static void NET_AddMaster( const char *addr, qboolean save )
master->sent = false; master->sent = false;
master->save = save; master->save = save;
master->next = NULL; master->next = NULL;
master->adr.type = NA_UNUSED; master->adr.type = 0;
// link in // link in
if( last ) if( last )
@@ -322,7 +322,7 @@ static void NET_ListMasters_f( void )
for( i = 1, list = ml.list; list; i++, list = list->next ) for( i = 1, list = ml.list; list; i++, list = list->next )
{ {
Msg( "%d\t%s", i, list->address ); Msg( "%d\t%s", i, list->address );
if( list->adr.type != NA_UNUSED ) if( list->adr.type != 0 )
Msg( "\t%s\n", NET_AdrToString( list->adr )); Msg( "\t%s\n", NET_AdrToString( list->adr ));
else Msg( "\n" ); else Msg( "\n" );
} }

View File

@@ -980,7 +980,7 @@ Mod_SampleSizeForFace
return the current lightmap resolution per face return the current lightmap resolution per face
================== ==================
*/ */
int Mod_SampleSizeForFace( msurface_t *surf ) int Mod_SampleSizeForFace( const msurface_t *surf )
{ {
if( !surf || !surf->texinfo ) if( !surf || !surf->texinfo )
return LM_SAMPLE_SIZE; return LM_SAMPLE_SIZE;
@@ -2998,6 +2998,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
if( isworld ) if( isworld )
{ {
world.version = bmod->version;
#if !XASH_DEDICATED #if !XASH_DEDICATED
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc) Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer

View File

@@ -113,6 +113,8 @@ typedef struct world_static_s
// tree visualization stuff // tree visualization stuff
int recursion_level; int recursion_level;
int max_recursion; int max_recursion;
uint32_t version; // BSP version
} world_static_t; } world_static_t;
#ifndef REF_DLL #ifndef REF_DLL
@@ -155,7 +157,7 @@ int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize ); int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize ); int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node ); mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
int Mod_SampleSizeForFace( msurface_t *surf ); int Mod_SampleSizeForFace( const msurface_t *surf );
byte *Mod_GetPVSForPoint( const vec3_t p ); byte *Mod_GetPVSForPoint( const vec3_t p );
void Mod_UnloadBrushModel( model_t *mod ); void Mod_UnloadBrushModel( model_t *mod );
void Mod_PrintWorldStats_f( void ); void Mod_PrintWorldStats_f( void );

View File

@@ -111,6 +111,7 @@ void Mod_FreeModel( model_t *mod )
if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) ) if( mod->type == mod_brush && FBitSet( mod->flags, MODEL_WORLD ) )
{ {
world.version = 0;
world.shadowdata = NULL; world.shadowdata = NULL;
world.deluxedata = NULL; world.deluxedata = NULL;
} }

View File

@@ -1087,7 +1087,6 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
delta_info_t *dt = NULL; delta_info_t *dt = NULL;
delta_t *pField; delta_t *pField;
int i, countBits; int i, countBits;
int numChanges = 0;
countBits = MAX_ENTITY_BITS + 2; countBits = MAX_ENTITY_BITS + 2;
@@ -1121,7 +1120,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
if( !Delta_CompareField( pField, from, to, timebase )) if( !Delta_CompareField( pField, from, to, timebase ))
{ {
// strings are handled difference // strings are handled differently
if( FBitSet( pField->flags, DT_STRING )) if( FBitSet( pField->flags, DT_STRING ))
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8; countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
else countBits += pField->bits; else countBits += pField->bits;

View File

@@ -32,7 +32,6 @@ static const struct in6_addr in6addr_any;
#define NET_USE_FRAGMENTS #define NET_USE_FRAGMENTS
#define PORT_ANY -1
#define MAX_LOOPBACK 4 #define MAX_LOOPBACK 4
#define MASK_LOOPBACK (MAX_LOOPBACK - 1) #define MASK_LOOPBACK (MAX_LOOPBACK - 1)
@@ -132,7 +131,7 @@ static CVAR_DEFINE_AUTO( net6_address, "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "c
NET_ErrorString NET_ErrorString
==================== ====================
*/ */
char *NET_ErrorString( void ) static char *NET_ErrorString( void )
{ {
#if XASH_WIN32 #if XASH_WIN32
int err = WSANOTINITIALISED; int err = WSANOTINITIALISED;
@@ -226,34 +225,17 @@ _inline qboolean NET_IsSocketValid( int socket )
void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr ) void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr )
{ {
#if XASH_LITTLE_ENDIAN
memcpy( ip6, adr->ip6, sizeof( adr->ip6 )); memcpy( ip6, adr->ip6, sizeof( adr->ip6 ));
#elif XASH_BIG_ENDIAN
memcpy( ip6, adr->ip6_0, sizeof( adr->ip6_0 ));
memcpy( ip6 + sizeof( adr->ip6_0 ), adr->ip6_2, sizeof( adr->ip6_2 ));
#endif
} }
void NET_IP6BytesToNetadr( netadr_t *adr, const uint8_t *ip6 ) void NET_IP6BytesToNetadr( netadr_t *adr, const uint8_t *ip6 )
{ {
#if XASH_LITTLE_ENDIAN
memcpy( adr->ip6, ip6, sizeof( adr->ip6 )); memcpy( adr->ip6, ip6, sizeof( adr->ip6 ));
#elif XASH_BIG_ENDIAN
memcpy( adr->ip6_0, ip6, sizeof( adr->ip6_0 ));
memcpy( adr->ip6_2, ip6 + sizeof( adr->ip6_0 ), sizeof( adr->ip6_2 ));
#endif
} }
_inline int NET_NetadrIP6Compare( const netadr_t *a, const netadr_t *b ) static int NET_NetadrIP6Compare( const netadr_t *a, const netadr_t *b )
{ {
#if XASH_LITTLE_ENDIAN
return memcmp( a->ip6, b->ip6, sizeof( a->ip6 )); return memcmp( a->ip6, b->ip6, sizeof( a->ip6 ));
#elif XASH_BIG_ENDIAN
int ret = memcmp( a->ip6_0, b->ip6_0, sizeof( a->ip6_0 ));
if( !ret )
return memcmp( a->ip6_2, b->ip6_2, sizeof( a->ip6_2 ));
return ret;
#endif
} }
/* /*
@@ -2200,6 +2182,8 @@ HTTP downloader
================================================= =================================================
*/ */
#define MAX_HTTP_BUFFER_SIZE (BIT( 13 ))
typedef struct httpserver_s typedef struct httpserver_s
{ {
char host[256]; char host[256];
@@ -2240,7 +2224,7 @@ typedef struct httpfile_s
qboolean process; qboolean process;
// query or response // query or response
char buf[BUFSIZ+1]; char buf[MAX_HTTP_BUFFER_SIZE+1];
int header_size, query_length, bytes_sent; int header_size, query_length, bytes_sent;
} httpfile_t; } httpfile_t;
@@ -2385,18 +2369,18 @@ process incoming data
*/ */
static qboolean HTTP_ProcessStream( httpfile_t *curfile ) static qboolean HTTP_ProcessStream( httpfile_t *curfile )
{ {
char buf[BUFSIZ+1]; char buf[sizeof( curfile->buf )];
char *begin = 0; char *begin = 0;
int res; int res;
if( curfile->header_size >= BUFSIZ ) if( curfile->header_size >= sizeof( buf ))
{ {
Con_Reportf( S_ERROR "Header to big\n"); Con_Reportf( S_ERROR "Header too big, the size is %s\n", curfile->header_size );
HTTP_FreeFile( curfile, true ); HTTP_FreeFile( curfile, true );
return false; return false;
} }
while( ( res = recv( curfile->socket, buf, BUFSIZ - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data while( ( res = recv( curfile->socket, buf, sizeof( buf ) - curfile->header_size, 0 )) > 0) // if we got there, we are receiving data
{ {
curfile->blocktime = 0; curfile->blocktime = 0;
@@ -2409,7 +2393,7 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
if( begin ) // Got full header if( begin ) // Got full header
{ {
int cutheadersize = begin - curfile->buf + 4; // after that begin of data int cutheadersize = begin - curfile->buf + 4; // after that begin of data
char *length; char *content_length_line;
Con_Reportf( "HTTP: Got response!\n" ); Con_Reportf( "HTTP: Got response!\n" );
@@ -2428,10 +2412,13 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
} }
// print size // print size
length = Q_stristr( curfile->buf, "Content-Length: " ); content_length_line = Q_stristr( curfile->buf, "Content-Length: " );
if( length ) if( content_length_line )
{ {
int size = Q_atoi( length += 16 ); int size;
content_length_line += sizeof( "Content-Length: " ) - 1;
size = Q_atoi( content_length_line );
Con_Reportf( "HTTP: File size is %d\n", size ); Con_Reportf( "HTTP: File size is %d\n", size );
@@ -2873,6 +2860,10 @@ static void HTTP_AddCustomServer_f( void )
{ {
HTTP_AddCustomServer( Cmd_Argv( 1 )); HTTP_AddCustomServer( Cmd_Argv( 1 ));
} }
else
{
Con_Printf( S_USAGE "http_addcustomserver <url>\n" );
}
} }
/* /*

View File

@@ -305,6 +305,14 @@ extern const char *clc_strings[clc_lastmsg+1];
#define MAX_LEGACY_EDICTS (1 << MAX_LEGACY_ENTITY_BITS) // 4096 edicts #define MAX_LEGACY_EDICTS (1 << MAX_LEGACY_ENTITY_BITS) // 4096 edicts
#define MIN_LEGACY_EDICTS 30 #define MIN_LEGACY_EDICTS 30
// legacy engine features that can be implemented through currently supported features
#define ENGINE_LEGACY_FEATURES_MASK \
( ENGINE_WRITE_LARGE_COORD \
| ENGINE_LOAD_DELUXEDATA \
| ENGINE_LARGE_LIGHTMAPS \
| ENGINE_COMPENSATE_QUAKE_BUG \
| ENGINE_COMPUTE_STUDIO_LERP )
// Master Server protocol // Master Server protocol
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" // TODO: implement IP filter #define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" // TODO: implement IP filter

View File

@@ -152,7 +152,7 @@ stream_t *FS_OpenStream( const char *filename )
string path, loadname; string path, loadname;
qboolean anyformat = true; qboolean anyformat = true;
const streamfmt_t *format; const streamfmt_t *format;
stream_t *stream; stream_t *stream = NULL;
Sound_Reset(); // clear old streaminfo Sound_Reset(); // clear old streaminfo
Q_strncpy( loadname, filename, sizeof( loadname )); Q_strncpy( loadname, filename, sizeof( loadname ));
@@ -188,9 +188,18 @@ stream_t *FS_OpenStream( const char *filename )
} }
} }
Con_Reportf( "FS_OpenStream: couldn't open \"%s\"\n", loadname ); // compatibility with original Xash3D, try media/ folder
if( Q_strncmp( filename, "media/", sizeof( "media/" ) - 1 ))
{
Q_snprintf( loadname, sizeof( loadname ), "media/%s", filename );
stream = FS_OpenStream( loadname );
}
else
{
Con_Reportf( "%s: couldn't open \"%s\" or \"%s\"\n", __func__, filename + 6, filename );
}
return NULL; return stream;
} }
/* /*

View File

@@ -402,7 +402,7 @@ void Sys_Warn( const char *format, ... )
Msg( "Sys_Warn: %s\n", text ); Msg( "Sys_Warn: %s\n", text );
if( !Host_IsDedicated() ) // dedicated server should not hang on messagebox if( !Host_IsDedicated() ) // dedicated server should not hang on messagebox
MSGBOX(text); Platform_MessageBox( "Xash Warning", text, false );
} }
/* /*
@@ -446,8 +446,8 @@ void Sys_Error( const char *error, ... )
#if XASH_WIN32 #if XASH_WIN32
Wcon_ShowConsole( false ); Wcon_ShowConsole( false );
#endif #endif
MSGBOX( text );
Sys_Print( text ); Sys_Print( text );
Platform_MessageBox( "Xash Error", text, false );
} }
else else
{ {
@@ -562,7 +562,7 @@ void Sys_Print( const char *pMsg )
Sys_PrintLog( pMsg ); Sys_PrintLog( pMsg );
Rcon_Print( pMsg ); Rcon_Print( &host.rd, pMsg );
} }
/* /*

View File

@@ -30,9 +30,6 @@ extern "C" {
#include "crtlib.h" #include "crtlib.h"
#include "platform/platform.h" #include "platform/platform.h"
#define MSGBOX( x ) Platform_MessageBox( "Xash Error", (x), false )
#define MSGBOX2( x ) Platform_MessageBox( "Host Error", (x), true )
#define MSGBOX3( x ) Platform_MessageBox( "Host Recursive Error", (x), true )
#define ASSERT( exp ) if(!( exp )) Sys_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define ASSERT( exp ) if(!( exp )) Sys_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
/* /*

View File

@@ -38,6 +38,7 @@ void Test_RunCvar( void );
void Test_RunCon( void ); void Test_RunCon( void );
void Test_RunVOX( void ); void Test_RunVOX( void );
void Test_RunIPFilter( void ); void Test_RunIPFilter( void );
void Test_RunGamma( void );
#define TEST_LIST_0 \ #define TEST_LIST_0 \
Test_RunLibCommon(); \ Test_RunLibCommon(); \
@@ -47,7 +48,8 @@ void Test_RunIPFilter( void );
Test_RunIPFilter(); Test_RunIPFilter();
#define TEST_LIST_0_CLIENT \ #define TEST_LIST_0_CLIENT \
Test_RunCon(); Test_RunCon(); \
Test_RunGamma();
#define TEST_LIST_1 \ #define TEST_LIST_1 \
Test_RunImagelib(); Test_RunImagelib();

View File

@@ -632,12 +632,14 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
else else
{ {
const char* PATH = getenv("PATH"); const char* PATH = getenv("PATH");
const char* begin;
size_t argv0_length;
if (!PATH) if (!PATH)
break; break;
size_t argv0_length = strlen(argv[0]); argv0_length = strlen(argv[0]);
const char* begin = PATH; begin = PATH;
while (1) while (1)
{ {
const char* separator = strchr(begin, ':'); const char* separator = strchr(begin, ':');

View File

@@ -143,7 +143,7 @@ typedef struct ui_enginefuncs_s
void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc
// engine memory manager // engine memory manager
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 );
// collect info from engine // collect info from engine

View File

@@ -86,7 +86,7 @@ typedef struct server_physics_api_s
const byte *(*pfnGetTextureData)( unsigned int texnum ); const byte *(*pfnGetTextureData)( unsigned int texnum );
// 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 );
// trace & contents // trace & contents

View File

@@ -32,10 +32,9 @@ struct jnimethods_s
JNIEnv *env; JNIEnv *env;
jobject activity; jobject activity;
jclass actcls; jclass actcls;
jmethodID getID; jmethodID loadAndroidID;
jmethodID saveID; jmethodID getAndroidID;
jmethodID loadID; jmethodID saveAndroidID;
jmethodID getKeyboardHeight;
} jni; } jni;
void Android_Init( void ) void Android_Init( void )
@@ -43,10 +42,9 @@ void Android_Init( void )
jni.env = (JNIEnv *)SDL_AndroidGetJNIEnv(); jni.env = (JNIEnv *)SDL_AndroidGetJNIEnv();
jni.activity = (jobject)SDL_AndroidGetActivity(); jni.activity = (jobject)SDL_AndroidGetActivity();
jni.actcls = (*jni.env)->GetObjectClass( jni.env, jni.activity ); jni.actcls = (*jni.env)->GetObjectClass( jni.env, jni.activity );
jni.loadID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "loadAndroidID", "()Ljava/lang/String;" ); jni.loadAndroidID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "loadAndroidID", "()Ljava/lang/String;" );
jni.getID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "getAndroidID", "()Ljava/lang/String;" ); jni.getAndroidID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "getAndroidID", "()Ljava/lang/String;" );
jni.saveID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "saveAndroidID", "(Ljava/lang/String;)V" ); jni.saveAndroidID = (*jni.env)->GetMethodID( jni.env, jni.actcls, "saveAndroidID", "(Ljava/lang/String;)V" );
jni.getKeyboardHeight = (*jni.env)->GetMethodID( jni.env, jni.actcls, "getKeyboardHeight", "()I" );
SDL_SetHint( SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight" ); SDL_SetHint( SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight" );
SDL_SetHint( SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1" ); SDL_SetHint( SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1" );
@@ -95,7 +93,7 @@ const char *Android_GetAndroidID( void )
if( COM_CheckString( id ) ) return id; if( COM_CheckString( id ) ) return id;
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getID ); resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAndroidID );
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL ); resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
Q_strncpy( id, resultCStr, sizeof( id ) ); Q_strncpy( id, resultCStr, sizeof( id ) );
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr ); (*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
@@ -114,7 +112,7 @@ const char *Android_LoadID( void )
jstring resultJNIStr; jstring resultJNIStr;
const char *resultCStr; const char *resultCStr;
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.loadID ); resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.loadAndroidID );
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL ); resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
Q_strncpy( id, resultCStr, sizeof( id ) ); Q_strncpy( id, resultCStr, sizeof( id ) );
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr ); (*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
@@ -129,7 +127,7 @@ Android_SaveID
*/ */
void Android_SaveID( const char *id ) void Android_SaveID( const char *id )
{ {
(*jni.env)->CallVoidMethod( jni.env, jni.activity, jni.saveID, (*jni.env)->NewStringUTF( jni.env, id ) ); (*jni.env)->CallVoidMethod( jni.env, jni.activity, jni.saveAndroidID, (*jni.env)->NewStringUTF( jni.env, id ) );
} }
/* /*
@@ -144,14 +142,4 @@ void Platform_ShellExecute( const char *path, const char *parms )
#endif #endif
} }
/*
========================
Android_GetKeyboardHeight
========================
*/
int Android_GetKeyboardHeight( void )
{
return (*jni.env)->CallIntMethod( jni.env, jni.activity, jni.getKeyboardHeight );
}
#endif // XASH_DEDICATED #endif // XASH_DEDICATED

View File

@@ -48,8 +48,6 @@ qboolean R_Init_Video( const int type )
{ {
qboolean retval; qboolean retval;
VID_StartupGamma();
if( type != REF_SOFTWARE ) if( type != REF_SOFTWARE )
return false; /// glide??? return false; /// glide???

View File

@@ -13,11 +13,33 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <signal.h>
#include <ucontext.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#include "platform/platform.h" #include "platform/platform.h"
#include <sys/types.h>
#if defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 30)
// 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).
#include <sys/syscall.h>
static pid_t gettid( void )
{
return syscall( SYS_gettid );
}
#endif
static void *g_hsystemd; static void *g_hsystemd;
static int (*g_pfn_sd_notify)( int unset_environment, const char *state ); static int (*g_pfn_sd_notify)( int unset_environment, const char *state );
@@ -103,3 +125,44 @@ void Linux_Shutdown( void )
g_hsystemd = NULL; g_hsystemd = NULL;
} }
} }
static void Linux_TimerHandler( int sig, siginfo_t *si, void *uc )
{
timer_t *tidp = si->si_value.sival_ptr;
int overrun = timer_getoverrun( *tidp );
Con_Printf( "Frame too long (overrun %d)!\n", overrun );
}
#define DEBUG_TIMER_SIGNAL SIGRTMIN
void Linux_SetTimer( float tm )
{
static timer_t timerid;
if( !timerid && tm )
{
struct sigevent sev = { 0 };
struct sigaction sa = { 0 };
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = Linux_TimerHandler;
sigaction( DEBUG_TIMER_SIGNAL, &sa, NULL );
// this path availiable in POSIX, but may signal wrong thread...
// sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_notify = SIGEV_THREAD_ID;
sev._sigev_un._tid = gettid();
sev.sigev_signo = DEBUG_TIMER_SIGNAL;
sev.sigev_value.sival_ptr = &timerid;
timer_create( CLOCK_REALTIME, &sev, &timerid );
}
if( timerid )
{
struct itimerspec its = {0};
its.it_value.tv_sec = tm;
its.it_value.tv_nsec = 1000000000ULL * fmod( tm, 1.0f );
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
timer_settime( timerid, 0, &its, NULL );
}
}

View File

@@ -51,8 +51,6 @@ qboolean R_Init_Video( const int type )
string fbdev = DEFAULT_FBDEV; string fbdev = DEFAULT_FBDEV;
fb.fd = -1; fb.fd = -1;
VID_StartupGamma();
if( type != REF_SOFTWARE ) if( type != REF_SOFTWARE )
return false; return false;

View File

@@ -40,6 +40,7 @@ void Platform_SetStatus( const char *status );
// legacy iOS port functions // legacy iOS port functions
#if TARGET_OS_IOS #if TARGET_OS_IOS
const char *IOS_GetDocsDir( void ); const char *IOS_GetDocsDir( void );
void IOS_LaunchDialog( void );
#endif // TARGET_OS_IOS #endif // TARGET_OS_IOS
#if XASH_WIN32 || XASH_LINUX #if XASH_WIN32 || XASH_LINUX
@@ -63,7 +64,6 @@ const char *Android_LoadID( void );
void Android_SaveID( const char *id ); void Android_SaveID( const char *id );
void Android_Init( void ); void Android_Init( void );
void *Android_GetNativeObject( const char *name ); void *Android_GetNativeObject( const char *name );
int Android_GetKeyboardHeight( void );
#endif #endif
#if XASH_WIN32 #if XASH_WIN32
@@ -92,6 +92,7 @@ void DOS_Shutdown( void );
#if XASH_LINUX #if XASH_LINUX
void Linux_Init( void ); void Linux_Init( void );
void Linux_Shutdown( void ); void Linux_Shutdown( void );
void Linux_SetTimer( float time );
#endif #endif
static inline void Platform_Init( void ) static inline void Platform_Init( void )
@@ -182,6 +183,13 @@ void Platform_SetClipboardText( const char *buffer );
#define SDL_VERSION_ATLEAST( x, y, z ) 0 #define SDL_VERSION_ATLEAST( x, y, z ) 0
#endif #endif
static void Platform_SetTimer( float time )
{
#if XASH_LINUX
Linux_SetTimer( time );
#endif
}
/* /*
============================================================================== ==============================================================================

View File

@@ -654,9 +654,9 @@ static void VID_SetWindowIcon( SDL_Window *hWnd )
{ {
rgbdata_t *icon = NULL; rgbdata_t *icon = NULL;
char iconpath[MAX_STRING]; char iconpath[MAX_STRING];
#if XASH_WIN32 // ICO support only for Win32
const char *localIcoPath; const char *localIcoPath;
#if XASH_WIN32 // ICO support only for Win32
if(( localIcoPath = FS_GetDiskPath( GI->iconpath, true ))) if(( localIcoPath = FS_GetDiskPath( GI->iconpath, true )))
{ {
HICON ico = (HICON)LoadImage( NULL, localIcoPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE ); HICON ico = (HICON)LoadImage( NULL, localIcoPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE );
@@ -843,13 +843,10 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
return false; return false;
GL_SetupAttributes(); // re-choose attributes GL_SetupAttributes(); // re-choose attributes
} }
VID_StartupGamma();
} }
if( !GL_UpdateContext( )) if( !GL_UpdateContext( ))
return false; return false;
} }
#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) #else // SDL_VERSION_ATLEAST( 2, 0, 0 )

View File

@@ -28,13 +28,22 @@ GNU General Public License for more details.
#include "r_efx.h" #include "r_efx.h"
#include "com_image.h" #include "com_image.h"
#include "filesystem.h" #include "filesystem.h"
#include "common/protocol.h"
// RefAPI changelog: // RefAPI changelog:
// 1. Initial release // 1. Initial release
// 2. FS functions are removed, instead we have full fs_api_t // 2. FS functions are removed, instead we have full fs_api_t
// 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib // 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib
// 4. R_StudioEstimateFrame now has time argument // 4. R_StudioEstimateFrame now has time argument
#define REF_API_VERSION 4 // 5. Removed GetSomethingByIndex calls, renderers are supposed to cache pointer values
// Removed previously unused calls
// Simplified remapping calls
// GetRefAPI is now expected to return REF_API_VERSION
// 6. Removed timing from ref_globals_t.
// Renderers are supposed to migrate to ref_client_t/ref_host_t using PARM_GET_CLIENT_PTR and PARM_GET_HOST_PTR
// Removed functions to get internal engine structions. Use PARM_GET_*_PTR instead.
// 7. Gamma fixes.
#define REF_API_VERSION 7
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP) #define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
@@ -90,11 +99,6 @@ typedef struct ref_globals_s
{ {
qboolean developer; qboolean developer;
float time; // cl.time
float oldtime; // cl.oldtime
double realtime; // host.realtime
double frametime; // host.frametime
// viewport width and height // viewport width and height
int width; int width;
int height; int height;
@@ -116,6 +120,26 @@ typedef struct ref_globals_s
int desktopBitsPixel; int desktopBitsPixel;
} ref_globals_t; } ref_globals_t;
typedef struct ref_client_s
{
double time;
double oldtime;
int viewentity;
int playernum;
int maxclients;
int nummodels;
model_t *models[MAX_MODELS+1];
qboolean paused;
vec3_t simorg;
} ref_client_t;
typedef struct ref_host_s
{
double realtime;
double frametime;
int features;
} ref_host_t;
enum enum
{ {
GL_KEEP_UNIT = -1, GL_KEEP_UNIT = -1,
@@ -247,16 +271,18 @@ typedef enum
PARM_DEV_OVERVIEW = -1, PARM_DEV_OVERVIEW = -1,
PARM_THIRDPERSON = -2, PARM_THIRDPERSON = -2,
PARM_QUAKE_COMPATIBLE = -3, PARM_QUAKE_COMPATIBLE = -3,
PARM_PLAYER_INDEX = -4, // cl.playernum + 1 PARM_GET_CLIENT_PTR = -4, // ref_client_t
PARM_VIEWENT_INDEX = -5, // cl.viewentity PARM_GET_HOST_PTR = -5, // ref_host_t
PARM_CONNSTATE = -6, // cls.state PARM_CONNSTATE = -6, // cls.state
PARM_PLAYING_DEMO = -7, // cls.demoplayback PARM_PLAYING_DEMO = -7, // cls.demoplayback
PARM_WATER_LEVEL = -8, // cl.local.water_level PARM_WATER_LEVEL = -8, // cl.local.water_level
PARM_MAX_CLIENTS = -9, // cl.maxclients PARM_GET_WORLD_PTR = -9, // world
PARM_LOCAL_HEALTH = -10, // cl.local.health PARM_LOCAL_HEALTH = -10, // cl.local.health
PARM_LOCAL_GAME = -11, PARM_LOCAL_GAME = -11,
PARM_NUMENTITIES = -12, // local game only PARM_NUMENTITIES = -12, // local game only
PARM_NUMMODELS = -13, // cl.nummodels PARM_GET_MOVEVARS_PTR = -13, // clgame.movevars
PARM_GET_PALETTE_PTR = -14, // clgame.palette
PARM_GET_VIEWENT_PTR = -15, // clgame.viewent
} ref_parm_e; } ref_parm_e;
typedef struct ref_api_s typedef struct ref_api_s
@@ -299,17 +325,13 @@ typedef struct ref_api_s
void (*CL_DrawCenterPrint)( void ); void (*CL_DrawCenterPrint)( void );
// entity management // entity management
struct cl_entity_s *(*GetLocalPlayer)( void );
struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*GetEntityByIndex)( int idx );
struct cl_entity_s *(*R_BeamGetEntity)( int index ); struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p ); struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType ); qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
// brushes // brushes
int (*Mod_SampleSizeForFace)( struct msurface_s *surf ); int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits ); qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
struct world_static_s *(*GetWorld)( void ); // returns &world
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node ); mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
void (*Mod_CreatePolygonsForHull)( int hullnum ); void (*Mod_CreatePolygonsForHull)( int hullnum );
@@ -329,13 +351,10 @@ typedef struct ref_api_s
// model management // model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC ); model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model ); void *(*Mod_Extradata)( int type, model_t *model );
struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle
// remap // remap
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e ); struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
void (*CL_AllocRemapInfo)( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
void (*CL_FreeRemapInfo)( struct remap_info_s *info );
void (*CL_UpdateRemapInfo)( cl_entity_t *entity, int topcolor, int bottomcolor );
// utils // utils
void (*CL_ExtraUpdate)( void ); void (*CL_ExtraUpdate)( void );
@@ -344,9 +363,6 @@ typedef struct ref_api_s
float (*COM_RandomFloat)( float rmin, float rmax ); float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax ); int (*COM_RandomLong)( int rmin, int rmax );
struct screenfade_s *(*GetScreenFade)( void ); struct screenfade_s *(*GetScreenFade)( void );
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
void (*GetPredictedOrigin)( vec3_t v );
color24 *(*CL_GetPaletteColor)(int color); // clgame.palette[color]
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
void (*SetLocalLightLevel)( int level ); // cl.local.light_level void (*SetLocalLightLevel)( int level ); // cl.local.light_level
int (*Sys_CheckParm)( const char *flag ); int (*Sys_CheckParm)( const char *flag );
@@ -362,8 +378,8 @@ typedef struct ref_api_s
// memory // memory
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline ); poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline ); void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void (*_Mem_Free)( void *data, const char *filename, int fileline ); void (*_Mem_Free)( void *data, const char *filename, int fileline );
// library management // library management
@@ -389,9 +405,11 @@ typedef struct ref_api_s
void (*SW_UnlockBuffer)( void ); void (*SW_UnlockBuffer)( void );
// gamma // gamma
void (*BuildGammaTable)( float lightgamma, float brightness ); byte (*LightToTexGamma)( byte ); // software gamma support
byte (*LightToTexGamma)( byte color ); // software gamma support uint (*LightToTexGammaEx)( uint ); // software gamma support
qboolean (*R_DoResetGamma)( void ); byte (*TextureToGamma)( byte );
uint (*ScreenGammaTable)( uint );
uint (*LinearGammaTable)( uint );
// renderapi // renderapi
lightstyle_t* (*GetLightStyle)( int number ); lightstyle_t* (*GetLightStyle)( int number );
@@ -407,7 +425,6 @@ typedef struct ref_api_s
struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe ); struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe );
struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags ); struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags );
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags ); struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
struct movevars_s *(*pfnGetMoveVars)( void );
// imagelib // imagelib
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported
@@ -420,7 +437,6 @@ typedef struct ref_api_s
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in ); rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
void (*FS_FreeImage)( rgbdata_t *pack ); void (*FS_FreeImage)( rgbdata_t *pack );
void (*Image_SetMDLPointer)( byte *p ); void (*Image_SetMDLPointer)( byte *p );
poolhandle_t (*Image_GetPool)( void );
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx ); const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
// client exports // client exports
@@ -449,6 +465,8 @@ typedef struct ref_interface_s
void (*GL_InitExtensions)( void ); void (*GL_InitExtensions)( void );
void (*GL_ClearExtensions)( void ); void (*GL_ClearExtensions)( void );
// scene rendering
void (*R_GammaChanged)( qboolean do_reset_gamma );
void (*R_BeginFrame)( qboolean clearScene ); void (*R_BeginFrame)( qboolean clearScene );
void (*R_RenderScene)( void ); void (*R_RenderScene)( void );
void (*R_EndFrame)( void ); void (*R_EndFrame)( void );
@@ -463,7 +481,8 @@ typedef struct ref_interface_s
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type ); qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam ); void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
void (*R_ProcessEntData)( qboolean allocate ); void (*R_ProcessEntData)( qboolean allocate, cl_entity_t *entities, unsigned int max_entities );
void (*R_Flush)( unsigned int flush_flags );
// debug // debug
void (*R_ShowTextures)( void ); void (*R_ShowTextures)( void );
@@ -636,6 +655,8 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t*
#define ENGINE_SHARED_CVAR_LIST( f ) \ #define ENGINE_SHARED_CVAR_LIST( f ) \
ENGINE_SHARED_CVAR_NAME( f, vid_gamma, gamma ) \ ENGINE_SHARED_CVAR_NAME( f, vid_gamma, gamma ) \
ENGINE_SHARED_CVAR_NAME( f, vid_brightness, brightness ) \ ENGINE_SHARED_CVAR_NAME( f, vid_brightness, brightness ) \
ENGINE_SHARED_CVAR_NAME( f, v_lightgamma, lightgamma ) \
ENGINE_SHARED_CVAR_NAME( f, v_direct, direct ) \
ENGINE_SHARED_CVAR( f, r_showtextures ) \ ENGINE_SHARED_CVAR( f, r_showtextures ) \
ENGINE_SHARED_CVAR( f, r_speeds ) \ ENGINE_SHARED_CVAR( f, r_speeds ) \
ENGINE_SHARED_CVAR( f, r_fullbright ) \ ENGINE_SHARED_CVAR( f, r_fullbright ) \
@@ -657,7 +678,6 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t*
ENGINE_SHARED_CVAR( f, r_sprite_lighting ) \ ENGINE_SHARED_CVAR( f, r_sprite_lighting ) \
ENGINE_SHARED_CVAR( f, r_drawviewmodel ) \ ENGINE_SHARED_CVAR( f, r_drawviewmodel ) \
ENGINE_SHARED_CVAR( f, r_glowshellfreq ) \ ENGINE_SHARED_CVAR( f, r_glowshellfreq ) \
ENGINE_SHARED_CVAR( f, r_lighting_modulate ) \
#define DECLARE_ENGINE_SHARED_CVAR_LIST() \ #define DECLARE_ENGINE_SHARED_CVAR_LIST() \
ENGINE_SHARED_CVAR_LIST( DECLARE_ENGINE_SHARED_CVAR ) ENGINE_SHARED_CVAR_LIST( DECLARE_ENGINE_SHARED_CVAR )

View File

@@ -472,6 +472,8 @@ extern convar_t sv_userinfo_penalty_multiplier;
extern convar_t sv_userinfo_penalty_attempts; extern convar_t sv_userinfo_penalty_attempts;
extern convar_t sv_fullupdate_penalty_time; extern convar_t sv_fullupdate_penalty_time;
extern convar_t sv_log_outofband; extern convar_t sv_log_outofband;
extern convar_t sv_allow_autoaim;
extern convar_t sv_aim;
//=========================================================== //===========================================================
// //
@@ -562,7 +564,7 @@ qboolean SV_IsPlayerIndex( int idx );
int SV_CalcPing( sv_client_t *cl ); int SV_CalcPing( sv_client_t *cl );
void SV_InitClientMove( void ); void SV_InitClientMove( void );
void SV_UpdateServerInfo( void ); void SV_UpdateServerInfo( void );
void SV_EndRedirect( void ); void SV_EndRedirect( host_redirect_t *rd );
void SV_RejectConnection( netadr_t from, const char *fmt, ... ) _format( 2 ); void SV_RejectConnection( netadr_t from, const char *fmt, ... ) _format( 2 );
void SV_GetPlayerCount( int *clients, int *bots ); void SV_GetPlayerCount( int *clients, int *bots );

View File

@@ -639,7 +639,7 @@ void SV_DropClient( sv_client_t *cl, qboolean crash )
cl->frames = NULL; cl->frames = NULL;
if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address )) if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address ))
SV_EndRedirect(); SV_EndRedirect( &host.rd );
// throw away any residual garbage in the channel. // throw away any residual garbage in the channel.
Netchan_Clear( &cl->netchan ); Netchan_Clear( &cl->netchan );
@@ -676,22 +676,19 @@ SVC COMMAND REDIRECT
============================================================================== ==============================================================================
*/ */
void SV_BeginRedirect( netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush)) static void SV_BeginRedirect( host_redirect_t *rd, netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush))
{ {
if( !target || !buffer || !buffersize || !flush ) rd->target = target;
return; rd->buffer = buffer;
rd->buffersize = buffersize;
host.rd.target = target; rd->flush = flush;
host.rd.buffer = buffer; rd->address = adr;
host.rd.buffersize = buffersize; rd->buffer[0] = 0;
host.rd.flush = flush; if( rd->lines == 0 )
host.rd.address = adr; rd->lines = -1;
host.rd.buffer[0] = 0;
if( host.rd.lines == 0 )
host.rd.lines = -1;
} }
void SV_FlushRedirect( netadr_t adr, int dest, char *buf ) static void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
{ {
if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT )) if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT ))
return; return;
@@ -712,18 +709,18 @@ void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
} }
} }
void SV_EndRedirect( void ) void SV_EndRedirect( host_redirect_t *rd )
{ {
if( host.rd.lines > 0 ) if( rd->lines > 0 )
return; return;
if( host.rd.flush ) if( rd->flush )
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer ); rd->flush( rd->address, rd->target, rd->buffer );
host.rd.target = 0; rd->target = RD_NONE;
host.rd.buffer = NULL; rd->buffer = NULL;
host.rd.buffersize = 0; rd->buffersize = 0;
host.rd.flush = NULL; rd->flush = NULL;
} }
/* /*
@@ -733,24 +730,26 @@ Rcon_Print
Print message to rcon buffer and send to rcon redirect target Print message to rcon buffer and send to rcon redirect target
================ ================
*/ */
void Rcon_Print( const char *pMsg ) void Rcon_Print( host_redirect_t *rd, const char *pMsg )
{ {
if( host.rd.target && host.rd.lines && host.rd.flush && host.rd.buffer ) size_t len;
if( !rd->target || !rd->lines || !rd->flush || !rd->buffer )
return;
len = Q_strncat( rd->buffer, pMsg, rd->buffersize );
if( len && rd->buffer[len - 1] == '\n' )
{ {
size_t len = Q_strncat( host.rd.buffer, pMsg, host.rd.buffersize ); rd->flush( rd->address, rd->target, rd->buffer );
if( len && host.rd.buffer[len-1] == '\n' ) if( rd->lines > 0 )
{ rd->lines--;
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
if( host.rd.lines > 0 ) rd->buffer[0] = 0;
host.rd.lines--;
host.rd.buffer[0] = 0; if( !rd->lines )
Msg( "End of redirection!\n" );
if( !host.rd.lines )
Msg( "End of redirection!\n" );
}
} }
} }
@@ -1090,7 +1089,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
if( Rcon_Validate( )) if( Rcon_Validate( ))
{ {
SV_BeginRedirect( from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect ); SV_BeginRedirect( &host.rd, from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );
remaining[0] = 0; remaining[0] = 0;
for( i = 2; i < Cmd_Argc(); i++ ) for( i = 2; i < Cmd_Argc(); i++ )
@@ -1101,7 +1100,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
} }
Cmd_ExecuteString( remaining ); Cmd_ExecuteString( remaining );
SV_EndRedirect(); SV_EndRedirect( &host.rd );
} }
else Con_Printf( S_ERROR "Bad rcon_password.\n" ); else Con_Printf( S_ERROR "Bad rcon_password.\n" );
} }
@@ -1772,6 +1771,9 @@ static qboolean SV_ShouldUpdateUserinfo( sv_client_t *cl )
if( FBitSet( cl->flags, FCL_FAKECLIENT )) if( FBitSet( cl->flags, FCL_FAKECLIENT ))
return allow; return allow;
if( Host_IsLocalGame( ))
return allow;
// start from 1 second // start from 1 second
if( !cl->userinfo_penalty ) if( !cl->userinfo_penalty )
cl->userinfo_penalty = sv_userinfo_penalty_time.value; cl->userinfo_penalty = sv_userinfo_penalty_time.value;

View File

@@ -2385,7 +2385,9 @@ static void GAME_EXPORT pfnGetAimVector( edict_t* ent, float speed, float *rgflR
// try all possible entities // try all possible entities
VectorCopy( svgame.globals->v_forward, bestdir ); VectorCopy( svgame.globals->v_forward, bestdir );
bestdist = Cvar_VariableValue( "sv_aim" ); if( sv_allow_autoaim.value )
bestdist = sv_aim.value;
else bestdist = 0;
check = EDICT_NUM( 1 ); // start at first client check = EDICT_NUM( 1 ); // start at first client
for( i = 1; i < svgame.numEntities; i++, check++ ) for( i = 1; i < svgame.numEntities; i++, check++ )
@@ -4523,7 +4525,7 @@ static qboolean GAME_EXPORT pfnVoice_GetClientListening( int iReceiver, int iSen
iReceiver -= 1; iReceiver -= 1;
iSender -= 1; iSender -= 1;
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender > svs.maxclients ) if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender >= svs.maxclients )
return false; return false;
return (FBitSet( svs.clients[iSender].listeners, BIT( iReceiver )) != 0 ); return (FBitSet( svs.clients[iSender].listeners, BIT( iReceiver )) != 0 );
@@ -4540,7 +4542,7 @@ static qboolean GAME_EXPORT pfnVoice_SetClientListening( int iReceiver, int iSen
iReceiver -= 1; iReceiver -= 1;
iSender -= 1; iSender -= 1;
if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender > svs.maxclients ) if( iReceiver < 0 || iReceiver >= svs.maxclients || iSender < 0 || iSender >= svs.maxclients )
return false; return false;
if( bListen ) SetBits( svs.clients[iSender].listeners, BIT( iReceiver )); if( bListen ) SetBits( svs.clients[iSender].listeners, BIT( iReceiver ));
@@ -4965,12 +4967,6 @@ static qboolean SV_ParseEdict( char **pfile, edict_t *ent )
pkvd[i].szValue = copystring( temp ); pkvd[i].szValue = copystring( temp );
} }
#endif #endif
if( !Q_strcmp( pkvd[i].szKeyName, "light" ))
{
Mem_Free( pkvd[i].szKeyName );
pkvd[i].szKeyName = copystring( "light_level" );
}
if( !pkvd[i].fHandled ) if( !pkvd[i].fHandled )
{ {
pkvd[i].szClassName = classname; pkvd[i].szClassName = classname;

View File

@@ -23,6 +23,7 @@ CVAR_DEFINE_AUTO( sv_lan, "0", 0, "server is a lan server ( no heartbeat, no aut
CVAR_DEFINE_AUTO( sv_lan_rate, "20000.0", 0, "rate for lan server" ); CVAR_DEFINE_AUTO( sv_lan_rate, "20000.0", 0, "rate for lan server" );
CVAR_DEFINE_AUTO( sv_nat, "0", 0, "enable NAT bypass for this server" ); CVAR_DEFINE_AUTO( sv_nat, "0", 0, "enable NAT bypass for this server" );
CVAR_DEFINE_AUTO( sv_aim, "1", FCVAR_ARCHIVE|FCVAR_SERVER, "auto aiming option" ); CVAR_DEFINE_AUTO( sv_aim, "1", FCVAR_ARCHIVE|FCVAR_SERVER, "auto aiming option" );
CVAR_DEFINE_AUTO( sv_allow_autoaim, "0", FCVAR_ARCHIVE|FCVAR_SERVER, "auto aiming option (for HL25 compatibility)" );
CVAR_DEFINE_AUTO( sv_unlag, "1", 0, "allow lag compensation on server-side" ); CVAR_DEFINE_AUTO( sv_unlag, "1", 0, "allow lag compensation on server-side" );
CVAR_DEFINE_AUTO( sv_maxunlag, "0.5", 0, "max latency value which can be interpolated (by default ping should not exceed 500 units)" ); CVAR_DEFINE_AUTO( sv_maxunlag, "0.5", 0, "max latency value which can be interpolated (by default ping should not exceed 500 units)" );
CVAR_DEFINE_AUTO( sv_unlagpush, "0.0", 0, "interpolation bias for unlag time" ); CVAR_DEFINE_AUTO( sv_unlagpush, "0.0", 0, "interpolation bias for unlag time" );
@@ -128,7 +129,6 @@ CVAR_DEFINE( public_server, "public", "0", 0, "change server type from private t
CVAR_DEFINE_AUTO( sv_novis, "0", 0, "force to ignore server visibility" ); // disable server culling entities by vis CVAR_DEFINE_AUTO( sv_novis, "0", 0, "force to ignore server visibility" ); // disable server culling entities by vis
CVAR_DEFINE( sv_pausable, "pausable", "1", FCVAR_SERVER, "allow players to pause or not" ); CVAR_DEFINE( sv_pausable, "pausable", "1", FCVAR_SERVER, "allow players to pause or not" );
static CVAR_DEFINE_AUTO( timeout, "125", FCVAR_SERVER, "connection timeout" ); // seconds without any message static CVAR_DEFINE_AUTO( timeout, "125", FCVAR_SERVER, "connection timeout" ); // seconds without any message
CVAR_DEFINE( sv_lighting_modulate, "r_lighting_modulate", "0.6", FCVAR_ARCHIVE, "lightstyles modulate scale" );
CVAR_DEFINE( sv_maxclients, "maxplayers", "1", FCVAR_LATCH, "server max capacity" ); CVAR_DEFINE( sv_maxclients, "maxplayers", "1", FCVAR_LATCH, "server max capacity" );
CVAR_DEFINE_AUTO( sv_check_errors, "0", FCVAR_ARCHIVE, "check edicts for errors" ); CVAR_DEFINE_AUTO( sv_check_errors, "0", FCVAR_ARCHIVE, "check edicts for errors" );
CVAR_DEFINE_AUTO( sv_reconnect_limit, "3", FCVAR_ARCHIVE, "max reconnect attempts" ); // minimum seconds between connect messages CVAR_DEFINE_AUTO( sv_reconnect_limit, "3", FCVAR_ARCHIVE, "max reconnect attempts" ); // minimum seconds between connect messages
@@ -885,6 +885,7 @@ void SV_Init( void )
Cvar_RegisterVariable( &sv_fps ); Cvar_RegisterVariable( &sv_fps );
Cvar_RegisterVariable( &showtriggers ); Cvar_RegisterVariable( &showtriggers );
Cvar_RegisterVariable( &sv_aim ); Cvar_RegisterVariable( &sv_aim );
Cvar_RegisterVariable( &sv_allow_autoaim );
Cvar_RegisterVariable( &deathmatch ); Cvar_RegisterVariable( &deathmatch );
Cvar_RegisterVariable( &coop ); Cvar_RegisterVariable( &coop );
Cvar_RegisterVariable( &teamplay ); Cvar_RegisterVariable( &teamplay );
@@ -917,7 +918,6 @@ void SV_Init( void )
Cvar_RegisterVariable( &sv_maxclients ); Cvar_RegisterVariable( &sv_maxclients );
Cvar_RegisterVariable( &sv_check_errors ); Cvar_RegisterVariable( &sv_check_errors );
Cvar_RegisterVariable( &public_server ); Cvar_RegisterVariable( &public_server );
Cvar_RegisterVariable( &sv_lighting_modulate );
Cvar_RegisterVariable( &sv_reconnect_limit ); Cvar_RegisterVariable( &sv_reconnect_limit );
Cvar_RegisterVariable( &sv_failuretime ); Cvar_RegisterVariable( &sv_failuretime );
Cvar_RegisterVariable( &sv_unlag ); Cvar_RegisterVariable( &sv_unlag );
@@ -1101,7 +1101,7 @@ void SV_Shutdown( const char *finalmsg )
Con_Printf( "%s", finalmsg ); Con_Printf( "%s", finalmsg );
// rcon will be disconnected // rcon will be disconnected
SV_EndRedirect(); SV_EndRedirect( &host.rd );
if( svs.clients ) if( svs.clients )
SV_FinalMessage( finalmsg, false ); SV_FinalMessage( finalmsg, false );

View File

@@ -1784,7 +1784,7 @@ static void SV_RunLightStyles( void )
lightstyle_t *ls; lightstyle_t *ls;
float scale; float scale;
scale = sv_lighting_modulate.value; scale = 1.0f;
// run lightstyles animation // run lightstyles animation
for( i = 0, ls = sv.lightstyles; i < MAX_LIGHTSTYLES; i++, ls++ ) for( i = 0, ls = sv.lightstyles; i < MAX_LIGHTSTYLES; i++, ls++ )
@@ -2139,18 +2139,18 @@ qboolean SV_InitPhysicsAPI( void )
if( svgame.physFuncs.SV_CheckFeatures != NULL ) if( svgame.physFuncs.SV_CheckFeatures != NULL )
{ {
// grab common engine features (it will be shared across the network) // grab common engine features (it will be shared across the network)
host.features = svgame.physFuncs.SV_CheckFeatures(); Host_ValidateEngineFeatures( svgame.physFuncs.SV_CheckFeatures( ));
Host_PrintEngineFeatures ();
} }
return true; return true;
} }
// make sure what physic functions is cleared // make sure what physic functions is cleared
memset( &svgame.physFuncs, 0, sizeof( svgame.physFuncs )); memset( &svgame.physFuncs, 0, sizeof( svgame.physFuncs ));
Host_ValidateEngineFeatures( 0 );
return false; // just tell user about problems return false; // just tell user about problems
} }
// physic interface is missed // physic interface is missed
Host_ValidateEngineFeatures( 0 );
return true; return true;
} }

View File

@@ -36,7 +36,7 @@ static void SV_SourceQuery_Details( netadr_t from )
{ {
sizebuf_t buf; sizebuf_t buf;
char answer[2048]; char answer[2048];
int i, bot_count, client_count; int bot_count, client_count;
int is_private = 0; int is_private = 0;
SV_GetPlayerCount( &client_count, &bot_count ); SV_GetPlayerCount( &client_count, &bot_count );

View File

@@ -984,7 +984,10 @@ static void ParseSaveTables( SAVERESTOREDATA *pSaveData, SAVE_HEADER *pHeader, i
InitEntityTable( pSaveData, pSaveData->tableCount ); InitEntityTable( pSaveData, pSaveData->tableCount );
for( i = 0; i < pSaveData->tableCount; i++ ) for( i = 0; i < pSaveData->tableCount; i++ )
{
svgame.dllFuncs.pfnSaveReadFields( pSaveData, "ETABLE", &pSaveData->pTable[i], gEntityTable, ARRAYSIZE( gEntityTable )); svgame.dllFuncs.pfnSaveReadFields( pSaveData, "ETABLE", &pSaveData->pTable[i], gEntityTable, ARRAYSIZE( gEntityTable ));
pSaveData->pTable[i].pent = NULL;
}
pSaveData->pBaseData = pSaveData->pCurrentData; pSaveData->pBaseData = pSaveData->pCurrentData;
pSaveData->size = 0; pSaveData->size = 0;

View File

@@ -1475,7 +1475,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
float ds, dt, s, t; float ds, dt, s, t;
int sample_size; int sample_size;
msurface_t *surf; msurface_t *surf;
mtexinfo_t *tex;
mextrasurf_t *info; mextrasurf_t *info;
color24 *lm; color24 *lm;
vec3_t mid; vec3_t mid;
@@ -1510,7 +1509,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
{ {
int smax, tmax; int smax, tmax;
tex = surf->texinfo;
info = surf->info; info = surf->info;
if( FBitSet( surf->flags, SURF_DRAWTILED )) if( FBitSet( surf->flags, SURF_DRAWTILED ))

View File

@@ -37,8 +37,6 @@ def options(opt):
def configure(conf): def configure(conf):
# check for dedicated server build # check for dedicated server build
if conf.options.DEDICATED: if conf.options.DEDICATED:
if conf.env.DEST_OS == 'linux':
conf.check_cc(lib='rt')
conf.define('XASH_DEDICATED', 1) conf.define('XASH_DEDICATED', 1)
elif conf.env.DEST_OS == 'dos': elif conf.env.DEST_OS == 'dos':
conf.options.STATIC = True conf.options.STATIC = True
@@ -49,14 +47,14 @@ def configure(conf):
# re-enable undefined reference errors # re-enable undefined reference errors
conf.env.CXXFLAGS += ['-Wl,--no-undefined'] conf.env.CXXFLAGS += ['-Wl,--no-undefined']
conf.env.CFLAGS += ['-Wl,--no-undefined'] conf.env.CFLAGS += ['-Wl,--no-undefined']
# allow the SDL2 sanity check to complete properly by linking in libstdc++ and lm normally # allow the SDL2 sanity check to complete properly by linking in lm normally
conf.env.LDFLAGS += ['-lstdc++', '-lm'] conf.env.LDFLAGS += ['-lm']
conf.load('sdl2') conf.load('sdl2')
if not conf.env.HAVE_SDL2: if not conf.env.HAVE_SDL2:
conf.fatal('SDL2 not availiable! Install switch-sdl2!') conf.fatal('SDL2 not availiable! Install switch-sdl2!')
conf.define('XASH_SDL', 2) conf.define('XASH_SDL', 2)
# then remove them to avoid them getting linked to shared objects # then remove them to avoid them getting linked to shared objects
conf.env.LDFLAGS.remove('-lstdc++') conf.env.LIB_SDL2.remove('stdc++') # remove libstdc++ linking from SDL2, we link it later
conf.env.LDFLAGS.remove('-lm') conf.env.LDFLAGS.remove('-lm')
elif conf.env.DEST_OS == 'psvita': elif conf.env.DEST_OS == 'psvita':
# allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file # allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file
@@ -73,12 +71,9 @@ def configure(conf):
# unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support # unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support
# conf.define('XASH_FBDEV', 1) # conf.define('XASH_FBDEV', 1)
conf.check_cc( lib = 'asound' ) conf.check_cc( lib = 'asound' )
conf.check_cc( lib = 'rt' )
elif conf.options.SDL12: elif conf.options.SDL12:
conf.define('XASH_SDL', 12) conf.define('XASH_SDL', 12)
conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' ) conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' )
if conf.env.DEST_OS == 'linux':
conf.check_cc( lib='rt' )
conf.env.HAVE_SDL2 = True conf.env.HAVE_SDL2 = True
else: else:
conf.load('sdl2') conf.load('sdl2')
@@ -97,6 +92,9 @@ def configure(conf):
if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE: if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE:
conf.check_pthreads() conf.check_pthreads()
if conf.env.DEST_OS == 'linux':
conf.check_cc(lib='rt')
if hasattr(conf.options, 'DLLEMU'): if hasattr(conf.options, 'DLLEMU'):
conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU) conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU)
@@ -112,7 +110,7 @@ def configure(conf):
conf.define_cond('XASH_ENGINE_TESTS', conf.env.ENGINE_TESTS) conf.define_cond('XASH_ENGINE_TESTS', conf.env.ENGINE_TESTS)
conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING) conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING)
conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP) conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP)
conf.define_cond('SINGLE_BINARY', conf.env.SINGLE_BINARY) conf.define_cond('XASH_ENABLE_MAIN', conf.env.DISABLE_LAUNCHER)
conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE) conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE)
conf.define_cond('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT) conf.define_cond('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT)
conf.define_cond('XASH_64BIT', conf.env.DEST_SIZEOF_VOID_P != 4) conf.define_cond('XASH_64BIT', conf.env.DEST_SIZEOF_VOID_P != 4)
@@ -189,7 +187,7 @@ def build(bld):
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting # HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
# we can't do this right away because std::filesystem will complain about not having pathconf(), # we can't do this right away because std::filesystem will complain about not having pathconf(),
# which we have defined in sys_nswitch.c # which we have defined in sys_nswitch.c
bld.env.LDFLAGS += ['-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm'] bld.env.LDFLAGS += ['-v', '-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
if bld.env.DEST_OS == 'psvita': if bld.env.DEST_OS == 'psvita':
libs += [ 'VRTLD' ] libs += [ 'VRTLD' ]
@@ -239,7 +237,7 @@ def build(bld):
app_name = 'xash3d-fwgs' app_name = 'xash3d-fwgs'
) )
else: else:
if bld.env.SINGLE_BINARY: if bld.env.DISABLE_LAUNCHER:
install_path = bld.env.BINDIR install_path = bld.env.BINDIR
program = 'cxxprogram' if is_cxx_link else 'cprogram' program = 'cxxprogram' if is_cxx_link else 'cprogram'
if bld.env.STATIC: if bld.env.STATIC:

View File

@@ -233,6 +233,13 @@ public:
return FS_FileTime( p, false ); return FS_FileTime( p, false );
} }
long int GetFileModificationTime( const char *path )
{
// TODO: properly reverse-engineer this
FixupPath( p, path );
return FS_FileTime( p, false );
}
void FileTimeToString( char *p, int size, long int time ) override void FileTimeToString( char *p, int size, long int time ) override
{ {
const time_t curtime = time; const time_t curtime = time;

View File

@@ -40,8 +40,7 @@ public:
virtual ~IBaseInterface() {} virtual ~IBaseInterface() {}
}; };
class IVFileSystem009 : public IBaseInterface class IVFileSystem009 : public IBaseInterface {
{
public: public:
virtual void Mount() = 0; /* linkage=_ZN11IFileSystem5MountEv */ virtual void Mount() = 0; /* linkage=_ZN11IFileSystem5MountEv */
@@ -148,6 +147,8 @@ public:
virtual FileHandle_t OpenFromCacheForRead(const char *, const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20OpenFromCacheForReadEPKcS1_S1_ */ virtual FileHandle_t OpenFromCacheForRead(const char *, const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20OpenFromCacheForReadEPKcS1_S1_ */
virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */ virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */
virtual long int GetFileModificationTime(const char *) = 0; /* linkage=_ZN11IFileSystem23GetFileModificationTimeEPKc */
}; };
#endif // VFILESYSTEM009_H #endif // VFILESYSTEM009_H

325
filesystem/android.c Normal file
View File

@@ -0,0 +1,325 @@
/*
android.c - android support for filesystem
Copyright (C) 2022 Velaron
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 "port.h"
#if XASH_ANDROID
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stddef.h>
#include STDINT_H
#include "filesystem_internal.h"
#include "crtlib.h"
#include "xash3d_mathlib.h"
#include "common/com_strings.h"
#include <jni.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <time.h>
struct android_assets_s
{
string package_name;
qboolean engine;
AAssetManager *asset_manager;
AAssetDir *dir;
};
struct jni_methods_s
{
JNIEnv *env;
jobject activity;
jclass activity_class;
jmethodID getPackageName;
jmethodID getCallingPackage;
jmethodID getAssetsList;
jmethodID getAssets;
} jni;
static void Android_GetAssetManager( android_assets_t *assets )
{
jobject assetManager;
assetManager = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAssets, assets->engine );
if( assetManager )
assets->asset_manager = AAssetManager_fromJava( jni.env, assetManager );
else if( assets->engine )
Con_Reportf( S_WARN "Couldn't add engine assets!" );
}
static const char *Android_GetPackageName( qboolean engine )
{
static string pkg;
jstring resultJNIStr;
const char *resultCStr;
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, engine ? jni.getPackageName : jni.getCallingPackage );
if( !resultJNIStr )
return NULL;
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
Q_strncpy( pkg, resultCStr, sizeof( pkg ));
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
return pkg;
}
static void Android_ListDirectory( stringlist_t *list, const char *path, qboolean engine )
{
jstring JStr = (*jni.env)->NewStringUTF( jni.env, path );
jobjectArray JNIArray = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAssetsList, engine, JStr );
int JNIArraySize = (*jni.env)->GetArrayLength( jni.env, JNIArray );
for( int i = 0; i < JNIArraySize; i++ )
{
jstring JNIStr = (*jni.env)->GetObjectArrayElement( jni.env, JNIArray, i );
const char *CStr = (*jni.env)->GetStringUTFChars( jni.env, JNIStr, NULL );
stringlistappend( list, (char *)CStr );
(*jni.env)->ReleaseStringUTFChars( jni.env, JNIStr, CStr );
}
}
static void FS_CloseAndroidAssets( android_assets_t *assets )
{
if( assets->dir )
AAssetDir_close( assets->dir );
Mem_Free( assets );
}
static android_assets_t *FS_LoadAndroidAssets( qboolean engine )
{
android_assets_t *assets = Mem_Calloc( fs_mempool, sizeof( *assets ));
assets->engine = engine;
Android_GetAssetManager( assets );
if( !assets->asset_manager )
{
FS_CloseAndroidAssets( assets );
return NULL;
}
assets->dir = AAssetManager_openDir( assets->asset_manager, "" );
if( !assets->dir )
{
FS_CloseAndroidAssets( assets );
return NULL;
}
return assets;
}
static int FS_FileTime_AndroidAssets( searchpath_t *search, const char *filename )
{
static time_t time;
if( !time )
{
struct tm file_tm;
strptime( __DATE__ " "__TIME__, "%b %d %Y %H:%M:%S", &file_tm );
time = mktime( &file_tm );
}
return time;
}
static int FS_FindFile_AndroidAssets( struct searchpath_s *search, const char *path, char *fixedname, size_t len )
{
AAsset *assets = AAssetManager_open( search->assets->asset_manager, path, AASSET_MODE_UNKNOWN );
if( assets )
{
AAsset_close( assets );
Q_strncpy( fixedname, path, len );
return 0;
}
return -1;
}
static void FS_PrintInfo_AndroidAssets( searchpath_t *search, char *dst, size_t size )
{
Q_snprintf( dst, size, "%s", search->assets->package_name );
}
static void FS_Close_AndroidAssets( searchpath_t *search )
{
FS_CloseAndroidAssets( search->assets );
}
static void FS_Search_AndroidAssets( searchpath_t *search, stringlist_t *list, const char *pattern, int caseinsensitive )
{
string temp;
stringlist_t dirlist;
const char *slash, *backslash, *colon, *separator;
int basepathlength, dirlistindex, resultlistindex;
char *basepath;
slash = Q_strrchr( pattern, '/' );
backslash = Q_strrchr( pattern, '\\' );
colon = Q_strrchr( pattern, ':' );
separator = Q_max( slash, backslash );
separator = Q_max( separator, colon );
basepathlength = separator ? (separator + 1 - pattern) : 0;
basepath = Mem_Calloc( fs_mempool, basepathlength + 1 );
if( basepathlength )
memcpy( basepath, pattern, basepathlength );
basepath[basepathlength] = '\0';
stringlistinit( &dirlist );
Android_ListDirectory( &dirlist, basepath, search->assets->engine );
Q_strncpy( temp, basepath, sizeof( temp ));
for( dirlistindex = 0; dirlistindex < dirlist.numstrings; dirlistindex++ )
{
Q_strncpy( &temp[basepathlength], dirlist.strings[dirlistindex], sizeof( temp ) - basepathlength );
if( matchpattern( temp, (char *)pattern, true ))
{
for( resultlistindex = 0; resultlistindex < list->numstrings; resultlistindex++ )
{
if( !Q_strcmp( list->strings[resultlistindex], temp ))
break;
}
if( resultlistindex == list->numstrings )
stringlistappend( list, temp );
}
}
stringlistfreecontents( &dirlist );
Mem_Free( basepath );
}
static file_t *FS_OpenFile_AndroidAssets( searchpath_t *search, const char *filename, const char *mode, int pack_ind )
{
file_t *file = Mem_Calloc( fs_mempool, sizeof( *file ));
AAsset *assets = AAssetManager_open( search->assets->asset_manager, filename, AASSET_MODE_RANDOM );
file->handle = AAsset_openFileDescriptor( assets, &file->offset, &file->real_length );
file->position = 0;
file->ungetc = EOF;
AAsset_close( assets );
return file;
}
static byte *FS_LoadAndroidAssetsFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *filesize )
{
byte *buf;
off_t size;
AAsset *asset;
if( filesize ) *filesize = 0;
asset = AAssetManager_open( search->assets->asset_manager, path, AASSET_MODE_RANDOM );
if( !asset )
return NULL;
size = AAsset_getLength( asset );
buf = (byte *)Mem_Malloc( fs_mempool, size + 1 );
buf[size] = '\0';
if( AAsset_read( asset, buf, size ) < 0 )
{
Mem_Free( buf );
AAsset_close( asset );
return NULL;
}
AAsset_close( asset );
if( filesize ) *filesize = size;
return buf;
}
searchpath_t *FS_AddAndroidAssets_Fullpath( const char *path, int flags )
{
searchpath_t *search;
android_assets_t *assets = NULL;
qboolean engine = true;
if( FBitSet( flags, FS_STATIC_PATH | FS_CUSTOM_PATH ))
return NULL;
if( FBitSet( flags, FS_GAMEDIR_PATH ) && Q_stricmp( GI->basedir, GI->gamefolder ))
engine = false;
assets = FS_LoadAndroidAssets( engine );
if( !assets )
{
Con_Reportf( S_ERROR "%s: unable to load Android assets \"%s\"\n", __FUNCTION__, Android_GetPackageName( engine ));
return NULL;
}
Q_strncpy( assets->package_name, Android_GetPackageName( engine ), sizeof( assets->package_name ));
search = Mem_Calloc( fs_mempool, sizeof( *search ));
Q_strncpy( search->filename, assets->package_name, sizeof( search->filename ));
search->assets = assets;
search->type = SEARCHPATH_ANDROID_ASSETS;
SetBits( search->flags, FS_NOWRITE_PATH | FS_CUSTOM_PATH );
search->pfnPrintInfo = FS_PrintInfo_AndroidAssets;
search->pfnClose = FS_Close_AndroidAssets;
search->pfnOpenFile = FS_OpenFile_AndroidAssets;
search->pfnFileTime = FS_FileTime_AndroidAssets;
search->pfnFindFile = FS_FindFile_AndroidAssets;
search->pfnSearch = FS_Search_AndroidAssets;
search->pfnLoadFile = FS_LoadAndroidAssetsFile;
Con_Reportf( "Adding Android assets: %s\n", assets->package_name );
return search;
}
void FS_InitAndroid( void )
{
jmethodID getContext;
jni.env = (JNIEnv *)Sys_GetNativeObject( "JNIEnv" );
jni.activity_class = Sys_GetNativeObject( "ActivityClass" );
getContext = (*jni.env)->GetStaticMethodID( jni.env, jni.activity_class, "getContext", "()Landroid/content/Context;" );
jni.activity = (*jni.env)->CallStaticObjectMethod( jni.env, jni.activity_class, getContext );
jni.getPackageName = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getPackageName", "()Ljava/lang/String;" );
jni.getCallingPackage = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getCallingPackage", "()Ljava/lang/String;" );
jni.getAssetsList = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssetsList", "(ZLjava/lang/String;)[Ljava/lang/String;" );
jni.getAssets = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssets", "(Z)Landroid/content/res/AssetManager;" );
}
#endif // XASH_ANDROID

View File

@@ -449,7 +449,6 @@ static void FS_Search_DIR( searchpath_t *search, stringlist_t *list, const char
static int FS_FileTime_DIR( searchpath_t *search, const char *filename ) static int FS_FileTime_DIR( searchpath_t *search, const char *filename )
{ {
int time;
char path[MAX_SYSPATH]; char path[MAX_SYSPATH];
Q_snprintf( path, sizeof( path ), "%s%s", search->filename, filename ); Q_snprintf( path, sizeof( path ), "%s%s", search->filename, filename );

View File

@@ -34,6 +34,7 @@ GNU General Public License for more details.
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "port.h" #include "port.h"
#include "defaults.h"
#include "const.h" #include "const.h"
#include "crtlib.h" #include "crtlib.h"
#include "crclib.h" #include "crclib.h"
@@ -71,8 +72,10 @@ const fs_archive_t g_archives[] =
static const fs_archive_t g_directory_archive = static const fs_archive_t g_directory_archive =
{ NULL, SEARCHPATH_PLAIN, FS_AddDir_Fullpath, false }; { NULL, SEARCHPATH_PLAIN, FS_AddDir_Fullpath, false };
// static const fs_archive_t g_android_archive = #ifdef XASH_ANDROID
// { NULL, SEARCHPATH_ANDROID, FS_AddAndroid_Fullpath, false, false }; static const fs_archive_t g_android_archive =
{ NULL, SEARCHPATH_ANDROID_ASSETS, FS_AddAndroidAssets_Fullpath, false };
#endif
#ifdef XASH_REDUCE_FD #ifdef XASH_REDUCE_FD
static file_t *fs_last_readfile; static file_t *fs_last_readfile;
@@ -154,7 +157,7 @@ void stringlistfreecontents( stringlist_t *list )
list->strings = NULL; list->strings = NULL;
} }
void stringlistappend( stringlist_t *list, char *text ) void stringlistappend( stringlist_t *list, const char *text )
{ {
size_t textlen; size_t textlen;
@@ -403,6 +406,10 @@ void FS_AddGameDirectory( const char *dir, uint flags )
stringlistfreecontents( &list ); stringlistfreecontents( &list );
#ifdef XASH_ANDROID
FS_AddArchive_Fullpath( &g_android_archive, dir, flags );
#endif
// add the directory to the search path // add the directory to the search path
// (unpacked files have the priority over packed files) // (unpacked files have the priority over packed files)
search = FS_AddArchive_Fullpath( &g_directory_archive, dir, flags ); search = FS_AddArchive_Fullpath( &g_directory_archive, dir, flags );
@@ -596,7 +603,7 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
} }
if( GameInfo->noskills ) if( GameInfo->noskills )
FS_Printf( f, "noskills\t\t\"%i\"\n", GameInfo->nomodels ); FS_Printf( f, "noskills\t\t\"%i\"\n", GameInfo->noskills );
#define SAVE_AGED_COUNT 2 // the default count of quick and auto saves #define SAVE_AGED_COUNT 2 // the default count of quick and auto saves
if( GameInfo->quicksave_aged_count != SAVE_AGED_COUNT ) if( GameInfo->quicksave_aged_count != SAVE_AGED_COUNT )
@@ -606,6 +613,13 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
FS_Printf( f, "autosave_aged_count\t\t%d\n", GameInfo->autosave_aged_count ); FS_Printf( f, "autosave_aged_count\t\t%d\n", GameInfo->autosave_aged_count );
#undef SAVE_AGED_COUNT #undef SAVE_AGED_COUNT
// HL25 compatibility
if( GameInfo->animated_title )
FS_Printf( f, "animated_title\t\t%i\n", GameInfo->animated_title );
if( GameInfo->hd_background )
FS_Printf( f, "hd_background\t\t%i\n", GameInfo->hd_background );
// always expose our extensions :) // always expose our extensions :)
FS_Printf( f, "internal_vgui_support\t\t%s\n", GameInfo->internal_vgui_support ? "1" : "0" ); FS_Printf( f, "internal_vgui_support\t\t%s\n", GameInfo->internal_vgui_support ? "1" : "0" );
FS_Printf( f, "render_picbutton_text\t\t%s\n", GameInfo->render_picbutton_text ? "1" : "0" ); FS_Printf( f, "render_picbutton_text\t\t%s\n", GameInfo->render_picbutton_text ? "1" : "0" );
@@ -638,7 +652,7 @@ void FS_InitGameInfo( gameinfo_t *GameInfo, const char *gamedir )
Q_strncpy( GameInfo->sp_entity, "info_player_start", sizeof( GameInfo->sp_entity )); Q_strncpy( GameInfo->sp_entity, "info_player_start", sizeof( GameInfo->sp_entity ));
Q_strncpy( GameInfo->mp_entity, "info_player_deathmatch", sizeof( GameInfo->mp_entity )); Q_strncpy( GameInfo->mp_entity, "info_player_deathmatch", sizeof( GameInfo->mp_entity ));
GameInfo->max_edicts = 900; // default value if not specified GameInfo->max_edicts = DEFAULT_MAX_EDICTS; // default value if not specified
GameInfo->max_tents = 500; GameInfo->max_tents = 500;
GameInfo->max_beams = 128; GameInfo->max_beams = 128;
GameInfo->max_particles = 4096; GameInfo->max_particles = 4096;
@@ -783,6 +797,17 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
pfile = COM_ParseFile( pfile, token, sizeof( token )); pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->max_edicts = bound( MIN_EDICTS, Q_atoi( token ), MAX_EDICTS ); GameInfo->max_edicts = bound( MIN_EDICTS, Q_atoi( token ), MAX_EDICTS );
} }
// valid for both
else if( !Q_stricmp( token, "hd_background" ))
{
pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->hd_background = Q_atoi( token ) ? true : false;
}
else if( !Q_stricmp( token, "animated_title" ))
{
pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->animated_title = Q_atoi( token ) ? true : false;
}
// only for gameinfo // only for gameinfo
else if( isGameInfo ) else if( isGameInfo )
{ {
@@ -1053,29 +1078,39 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
roGameInfoTime = FS_SysFileTime( gameinfo_ro ); roGameInfoTime = FS_SysFileTime( gameinfo_ro );
rwGameInfoTime = FS_SysFileTime( gameinfo_path ); rwGameInfoTime = FS_SysFileTime( gameinfo_path );
// if rodir's liblist.gam newer than rwdir's gameinfo.txt, then convert it
if( roLibListTime > rwGameInfoTime ) if( roLibListTime > rwGameInfoTime )
{ {
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro ); haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
} }
// if rodir's gameinfo.txt newer than rwdir's gameinfo.txt, just copy the file
else if( roGameInfoTime > rwGameInfoTime ) else if( roGameInfoTime > rwGameInfoTime )
{ {
fs_offset_t len; file_t *ro, *rw;
char *afile_ro = (char *)FS_LoadDirectFile( gameinfo_ro, &len ); fs_offset_t ro_size;
if( afile_ro ) // read & write as binary to copy the exact file
{ ro = FS_SysOpen( gameinfo_ro, "rb" );
Con_DPrintf( "Copy rodir %s to rwdir %s\n", gameinfo_ro, gameinfo_path ); rw = FS_SysOpen( gameinfo_path, "wb" );
haveUpdate = true;
FS_WriteFile( gameinfo_path, afile_ro, len ); FS_Seek( ro, 0, SEEK_END );
Mem_Free( afile_ro ); ro_size = FS_Tell( ro );
} FS_Seek( ro, 0, SEEK_SET );
FS_FileCopy( rw, ro, ro_size );
FS_Close( rw );
FS_Close( ro );
haveUpdate = true;
} }
FS_AllowDirectPaths( false ); FS_AllowDirectPaths( false );
} }
// do not update gameinfo.txt, if it was just copied from rodir's
// if user change liblist.gam update the gameinfo.txt // if user change liblist.gam update the gameinfo.txt
if( FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false )) if( !haveUpdate && FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path ); FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
// force to create gameinfo for specified game if missing // force to create gameinfo for specified game if missing
@@ -1252,6 +1287,26 @@ static qboolean FS_CheckForCrypt( const char *dllname )
return ( key == 0x12345678 ) ? true : false; return ( key == 0x12345678 ) ? true : false;
} }
static int FS_StripIdiotRelativePath( const char *dllname, const char *gamefolder )
{
string idiot_relpath;
int len;
if(( len = Q_snprintf( idiot_relpath, sizeof( idiot_relpath ), "../%s/", gamefolder )) >= 4 )
{
if( !Q_strnicmp( dllname, idiot_relpath, len ))
return len;
// try backslashes
idiot_relpath[1] = '\\';
idiot_relpath[len - 1] = '\\';
if( !Q_strnicmp( dllname, idiot_relpath, len ))
return len;
}
return 0;
}
/* /*
================== ==================
FS_FindLibrary FS_FindLibrary
@@ -1271,9 +1326,16 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
fs_ext_path = directpath; fs_ext_path = directpath;
// HACKHACK remove absoulte path to valve folder // HACKHACK remove relative path to game folder
if( !Q_strnicmp( dllname, "..\\valve\\", 9 ) || !Q_strnicmp( dllname, "../valve/", 9 )) if( !Q_strnicmp( dllname, "..", 2 ))
start += 9; {
// some modders put relative path to themselves???
len = FS_StripIdiotRelativePath( dllname, GI->gamefolder );
if( len == 0 ) // or put relative path to Half-Life game libs
len = FS_StripIdiotRelativePath( dllname, "valve" );
start += len;
}
// replace all backward slashes // replace all backward slashes
len = Q_strlen( dllname ); len = Q_strlen( dllname );
@@ -1406,6 +1468,10 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
FS_InitMemory(); FS_InitMemory();
#ifdef XASH_ANDROID
FS_InitAndroid();
#endif
Q_strncpy( fs_rootdir, rootdir, sizeof( fs_rootdir )); Q_strncpy( fs_rootdir, rootdir, sizeof( fs_rootdir ));
Q_strncpy( fs_gamedir, gamedir, sizeof( fs_gamedir )); Q_strncpy( fs_gamedir, gamedir, sizeof( fs_gamedir ));
Q_strncpy( fs_basedir, basedir, sizeof( fs_basedir )); Q_strncpy( fs_basedir, basedir, sizeof( fs_basedir ));
@@ -1638,6 +1704,9 @@ file_t *FS_SysOpen( const char *filepath, const char *mode )
if( file->handle < 0 ) if( file->handle < 0 )
{ {
if( errno != ENOENT )
Con_Printf( S_ERROR "%s: can't open file %s: %s\n", __func__, filepath, strerror( errno ));
Mem_Free( file ); Mem_Free( file );
return NULL; return NULL;
} }

View File

@@ -106,6 +106,10 @@ typedef struct gameinfo_s
int quicksave_aged_count; // min is 1, max is 99 int quicksave_aged_count; // min is 1, max is 99
int autosave_aged_count; // min is 1, max is 99 int autosave_aged_count; // min is 1, max is 99
// HL25 compatibility keys
qboolean hd_background;
qboolean animated_title;
} gameinfo_t; } gameinfo_t;
typedef enum typedef enum
@@ -206,8 +210,8 @@ typedef struct fs_interface_t
// memory // memory
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline ); poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline ); void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ); void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void (*_Mem_Free)( void *data, const char *filename, int fileline ); void (*_Mem_Free)( void *data, const char *filename, int fileline );
// platform // platform

View File

@@ -22,6 +22,10 @@ GNU General Public License for more details.
#include "xash3d_types.h" #include "xash3d_types.h"
#include "filesystem.h" #include "filesystem.h"
#if XASH_ANDROID
#include <android/asset_manager.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
@@ -31,6 +35,10 @@ typedef struct dir_s dir_t;
typedef struct zip_s zip_t; typedef struct zip_s zip_t;
typedef struct pack_s pack_t; typedef struct pack_s pack_t;
typedef struct wfile_s wfile_t; typedef struct wfile_s wfile_t;
#if XASH_ANDROID
typedef struct android_assets_s android_assets_t;
// typedef struct android_saf_s android_saf_t;
#endif
#define FILE_BUFF_SIZE (2048) #define FILE_BUFF_SIZE (2048)
@@ -58,7 +66,8 @@ enum
SEARCHPATH_PAK, SEARCHPATH_PAK,
SEARCHPATH_WAD, SEARCHPATH_WAD,
SEARCHPATH_ZIP, SEARCHPATH_ZIP,
SEARCHPATH_PK3DIR, // it's actually a plain directory but it must behave like a ZIP archive SEARCHPATH_PK3DIR, // it's actually a plain directory but it must behave like a ZIP archive,
SEARCHPATH_ANDROID_ASSETS
}; };
typedef struct stringlist_s typedef struct stringlist_s
@@ -81,6 +90,9 @@ typedef struct searchpath_s
pack_t *pack; pack_t *pack;
wfile_t *wad; wfile_t *wad;
zip_t *zip; zip_t *zip;
#if XASH_ANDROID
android_assets_t *assets;
#endif
}; };
struct searchpath_s *next; struct searchpath_s *next;
@@ -179,7 +191,7 @@ qboolean MD5_HashFile( byte digest[16], const char *pszFileName, uint seed[4] );
// stringlist ops // stringlist ops
void stringlistinit( stringlist_t *list ); void stringlistinit( stringlist_t *list );
void stringlistfreecontents( stringlist_t *list ); void stringlistfreecontents( stringlist_t *list );
void stringlistappend( stringlist_t *list, char *text ); void stringlistappend( stringlist_t *list, const char *text );
void stringlistsort( stringlist_t *list ); void stringlistsort( stringlist_t *list );
void listdirectory( stringlist_t *list, const char *path ); void listdirectory( stringlist_t *list, const char *path );
@@ -225,6 +237,12 @@ searchpath_t *FS_AddDir_Fullpath( const char *path, int flags );
qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t len, qboolean createpath ); qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t len, qboolean createpath );
void FS_InitDirectorySearchpath( searchpath_t *search, const char *path, int flags ); void FS_InitDirectorySearchpath( searchpath_t *search, const char *path, int flags );
//
// android.c
//
void FS_InitAndroid( void );
searchpath_t *FS_AddAndroidAssets_Fullpath( const char *path, int flags );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -334,7 +334,7 @@ searchpath_t *FS_AddPak_Fullpath( const char *pakfile, int flags )
{ {
searchpath_t *search; searchpath_t *search;
pack_t *pak; pack_t *pak;
int i, errorcode = PAK_LOAD_COULDNT_OPEN; int errorcode = PAK_LOAD_COULDNT_OPEN;
pak = FS_LoadPackPAK( pakfile, &errorcode ); pak = FS_LoadPackPAK( pakfile, &errorcode );

View File

@@ -10,19 +10,19 @@ def configure(conf):
} }
conf.env.append_unique('CXXFLAGS', conf.get_flags_by_compiler(nortti, conf.env.COMPILER_CC)) conf.env.append_unique('CXXFLAGS', conf.get_flags_by_compiler(nortti, conf.env.COMPILER_CC))
if conf.env.DEST_OS != 'android': if conf.env.DEST_OS == 'android':
if conf.env.cxxshlib_PATTERN.startswith('lib'): conf.check_cc(lib='android')
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:] elif conf.env.cxxshlib_PATTERN.startswith('lib'): # remove lib prefix for other systems than Android
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
def build(bld): def build(bld):
bld(name = 'filesystem_includes', export_includes = '.') bld(name = 'filesystem_includes', export_includes = '.')
libs = [ 'filesystem_includes' ] libs = [ 'filesystem_includes', 'sdk_includes' ]
# on PSVita do not link any libraries that are already in the main executable, but add the includes target # on PSVita do not link any libraries that are already in the main executable, but add the includes target
if bld.env.DEST_OS == 'psvita': if bld.env.DEST_OS != 'psvita':
libs += [ 'sdk_includes' ] libs += [ 'public', 'ANDROID' ]
else:
libs += [ 'public' ]
bld.shlib(target = 'filesystem_stdio', bld.shlib(target = 'filesystem_stdio',
features = 'cxx seq', features = 'cxx seq',

View File

@@ -129,6 +129,8 @@ struct zip_s
zipfile_t *files; zipfile_t *files;
}; };
// #define ENABLE_CRC_CHECK // known to be buggy because of possible libpublic crc32 bug, disabled
#ifdef XASH_REDUCE_FD #ifdef XASH_REDUCE_FD
static void FS_EnsureOpenZip( zip_t *zip ) static void FS_EnsureOpenZip( zip_t *zip )
{ {
@@ -423,12 +425,13 @@ FS_LoadZIPFile
static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *sizeptr ) static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *sizeptr )
{ {
zipfile_t *file; zipfile_t *file;
int index;
byte *compressed_buffer = NULL, *decompressed_buffer = NULL; byte *compressed_buffer = NULL, *decompressed_buffer = NULL;
int zlib_result = 0; int zlib_result = 0;
dword test_crc, final_crc;
z_stream decompress_stream; z_stream decompress_stream;
size_t c; size_t c;
#ifdef ENABLE_CRC_CHECK
dword test_crc, final_crc;
#endif // ENABLE_CRC_CHECK
if( sizeptr ) *sizeptr = 0; if( sizeptr ) *sizeptr = 0;
@@ -460,7 +463,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
return NULL; return NULL;
} }
#if 0 #ifdef ENABLE_CRC_CHECK
CRC32_Init( &test_crc ); CRC32_Init( &test_crc );
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size ); CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
@@ -472,7 +475,8 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
Mem_Free( decompressed_buffer ); Mem_Free( decompressed_buffer );
return NULL; return NULL;
} }
#endif #endif // ENABLE_CRC_CHECK
if( sizeptr ) *sizeptr = file->size; if( sizeptr ) *sizeptr = file->size;
FS_EnsureOpenZip( NULL ); FS_EnsureOpenZip( NULL );
@@ -516,7 +520,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
if( zlib_result == Z_OK || zlib_result == Z_STREAM_END ) if( zlib_result == Z_OK || zlib_result == Z_STREAM_END )
{ {
Mem_Free( compressed_buffer ); // finaly free compressed buffer Mem_Free( compressed_buffer ); // finaly free compressed buffer
#if 0 #if ENABLE_CRC_CHECK
CRC32_Init( &test_crc ); CRC32_Init( &test_crc );
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size ); CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
@@ -668,7 +672,7 @@ searchpath_t *FS_AddZip_Fullpath( const char *zipfile, int flags )
{ {
searchpath_t *search; searchpath_t *search;
zip_t *zip; zip_t *zip;
int i, errorcode = ZIP_LOAD_COULDNT_OPEN; int errorcode = ZIP_LOAD_COULDNT_OPEN;
zip = FS_LoadZip( zipfile, &errorcode ); zip = FS_LoadZip( zipfile, &errorcode );

View File

@@ -21,21 +21,19 @@ def configure(conf):
conf.define_cond('XASH_DISABLE_MENU_CHANGEGAME', conf.options.DISABLE_MENU_CHANGEGAME) conf.define_cond('XASH_DISABLE_MENU_CHANGEGAME', conf.options.DISABLE_MENU_CHANGEGAME)
def build(bld): def build(bld):
libs = ['sdk_includes']
source = ['game.cpp'] source = ['game.cpp']
defines = []
if bld.env.DEST_OS != 'win32': if bld.env.DEST_OS == 'win32':
libs += [ 'DL' ]
else:
libs += ['USER32', 'SHELL32']
source += ['game.rc'] source += ['game.rc']
# Half-Life 25th anniversary update doesn't have server library explicitly linked to libm
if bld.env.DEST_OS == 'linux':
bld.env.LDFLAGS += ['-Wl,--no-as-needed', '-lm']
bld(source = source, bld(source = source,
target = 'xash3d', # hl.exe target = 'xash3d', # hl.exe
features = 'c cxx cxxprogram', features = 'c cxx cxxprogram',
use = libs, use = 'sdk_includes DL USER32 SHELL32',
defines = defines,
rpath = bld.env.DEFAULT_RPATH, rpath = bld.env.DEFAULT_RPATH,
install_path = bld.env.BINDIR, install_path = bld.env.BINDIR,
subsystem = bld.env.MSVC_SUBSYSTEM subsystem = bld.env.MSVC_SUBSYSTEM

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