Compare commits

...

103 Commits

Author SHA1 Message Date
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
71 changed files with 1751 additions and 1095 deletions

View File

@@ -1,14 +1,15 @@
task:
name: freebsd-12-amd64
freebsd_instance:
image_family: freebsd-12-4
setup_script:
- pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
# Seems packages for it were removed from the mirrors
# name: freebsd-12-amd64
# freebsd_instance:
# image_family: freebsd-12-4
# setup_script:
# - pkg update
# - pkg install -y pkgconf git sdl2 python fontconfig opus
# - git submodule update --init --recursive
# test_script:
# - ./scripts/cirrus/build_freebsd.sh dedicated
# - ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-13-amd64

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

View File

@@ -229,7 +229,7 @@ typedef struct render_api_s
void (*R_Reserved0)( void );
// static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
// engine utils (not related with render API but placed here)

View File

@@ -88,18 +88,21 @@ typedef uint64_t longtime_t;
#define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull))
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
#elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#else
#define EXPORT
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#endif
#if ( __GNUC__ >= 3 )
@@ -118,10 +121,15 @@ typedef uint64_t longtime_t;
#define likely(x) (x)
#endif
#if defined( static_assert ) // C11 static_assert
#define STATIC_ASSERT static_assert
#if __STDC_VERSION >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
#define STATIC_ASSERT_ static_assert
#define STATIC_ASSERT static_assert
#elif __STDC_VERSION >= 201112L // in C11 it's _Static_assert
#define STATIC_ASSERT_ _Static_assert
#define STATIC_ASSERT _Static_assert
#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]
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_( static_assert_##__LINE__, x, y )
#endif
#ifdef XASH_BIG_ENDIAN

View File

@@ -372,7 +372,7 @@ void CL_WriteDemoHeader( const char *name )
demo.header.id = IDEMOHEADER;
demo.header.dem_protocol = DEMO_PROTOCOL;
demo.header.net_protocol = cls.legacymode ? PROTOCOL_LEGACY_VERSION : PROTOCOL_VERSION;
demo.header.host_fps = bound( MIN_FPS, host_maxfps.value, MAX_FPS );
demo.header.host_fps = 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.comment, clgame.maptitle, sizeof( demo.header.comment ));
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 ));
MSG_Init( &buf, "UserCmd", data, sizeof( data ));
// a1ba: I have no proper explanation why
cmdnumber++;
pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK];
pcmd->processedfuncs = false;
pcmd->senttime = 0.0f;

View File

@@ -175,7 +175,7 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float )
return NULL;
// 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 )
{
@@ -226,7 +226,7 @@ particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
return NULL;
// 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 )
{

View File

@@ -24,7 +24,7 @@ GNU General Public License for more details.
#include "sound.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 )
{
position_history_t *ph;
position_history_t *ph, *prev;
prev = &ent->ph[ent->current_position];
ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
ph = &ent->ph[ent->current_position];
VectorCopy( ent->curstate.origin, ph->origin );
VectorCopy( ent->curstate.angles, ph->angles );
if( ent->model && ent->model->type == mod_brush )
ph->animtime = ent->curstate.animtime;
else
ph->animtime = cl.time;
ph->animtime = ent->curstate.animtime;
// a1ba: for some reason, this sometimes still may happen
// at this time, I'm not sure whether this bug happens in delta readwrite code
// or server just decides to go backwards and really sends these values
if( ph->animtime < prev->animtime )
{
// try to deduce real animtime by looking up the difference between
// server messages (cl.mtime is never modified ny the interpolation code)
float diff = Q_max( 0, ent->curstate.msg_time - ent->prevstate.msg_time );
ph->animtime = prev->animtime + diff;
}
}
/*
@@ -159,6 +170,13 @@ qboolean CL_EntityCustomLerp( cl_entity_t *e )
case MOVETYPE_FLY:
case MOVETYPE_COMPOUND:
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;
@@ -171,7 +189,7 @@ CL_ParametricMove
check for parametrical moved entities
==================
*/
qboolean CL_ParametricMove( cl_entity_t *ent )
static qboolean CL_ParametricMove( cl_entity_t *ent )
{
float frac, dt, t;
vec3_t delta;
@@ -349,11 +367,10 @@ CL_FindInterpolationUpdates
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;
uint i, i0, i1, imod;
float at;
imod = ent->current_position;
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++ )
{
at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
if( at == 0.0f ) break;
double at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
if( at == 0.0f )
break;
if( targettime > at )
{
@@ -387,15 +406,14 @@ CL_PureOrigin
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;
float t1, t0, frac;
double t1, t0, frac;
position_history_t *ph0, *ph1;
vec3_t delta;
// NOTE: ph0 is next, ph1 is a prev
extrapolate = CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
if ( !ph0 || !ph1 )
return;
@@ -403,7 +421,7 @@ void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangle
t0 = ph0->animtime;
t1 = ph1->animtime;
if( t0 != 0.0f )
if( t0 != 0.0 )
{
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 ))
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 );
@@ -437,11 +455,11 @@ CL_InterpolateModel
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;
vec3_t origin, angles, delta;
float t, t1, t2, frac;
double t, t1, t2, frac;
vec4_t q, q1, q2;
VectorCopy( e->curstate.origin, e->origin );
@@ -489,9 +507,7 @@ int CL_InterpolateModel( cl_entity_t *e )
return 0;
}
// HACKHACK: workaround buggy position history animtime
// going backward sometimes
if( Q_equal( t2, t1 ) || t2 < t1 )
if( Q_equal( t2, t1 ))
{
VectorCopy( ph0->origin, e->origin );
VectorCopy( ph0->angles, e->angles );
@@ -529,7 +545,7 @@ interpolate non-local clients
*/
void CL_ComputePlayerOrigin( cl_entity_t *ent )
{
float targettime;
double targettime;
vec4_t q, q1, q2;
vec3_t origin;
vec3_t angles;
@@ -1212,17 +1228,33 @@ void CL_LinkPacketEntities( frame_t *frame )
#else
if( ent->lastmove >= cl.time )
{
float at = ent->curstate.animtime;
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.angles, ent->latched.prevangles );
// disable step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_NONE;
if( !FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
{
// disable step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_NONE;
}
}
else
{
// restore step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_STEP;
if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
{
interpolate = true;
}
else
{
// restore step interpolation in client.dll
ent->curstate.movetype = MOVETYPE_STEP;
}
}
#endif
}
@@ -1247,11 +1279,24 @@ void CL_LinkPacketEntities( frame_t *frame )
if ( !CL_InterpolateModel( ent ))
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 ))
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
{
// no interpolation right now

View File

@@ -1235,11 +1235,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
{
char name[MAX_QPATH];
model_t *mod;
int i;
// use high indices for client sprites
// for GoldSrc bug-compatibility
const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0;
int i, start;
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 ));
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 ))
{
@@ -1267,8 +1263,15 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
}
// find a free model slot spot
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
if( !mod->name[0] ) break; // this is a valid spot
// use low indices only for HUD sprites
// for GoldSrc bug compatibility
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
{
if( !mod->name[0] )
break; // this is a valid spot
}
if( i == MAX_CLIENT_SPRITES / 2 )
{

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" );
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" );
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
@@ -605,10 +607,10 @@ void CL_CreateCmd( void )
// message we are constructing.
i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
pcmd = &cl.commands[i];
pcmd->processedfuncs = false;
if( !cls.demoplayback )
{
pcmd->processedfuncs = false;
pcmd->senttime = host.realtime;
memset( &pcmd->cmd, 0, sizeof( pcmd->cmd ));
pcmd->receivedtime = -1.0;
@@ -2917,6 +2919,8 @@ void CL_InitLocal( void )
Cvar_RegisterVariable( &cl_showevents );
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );
Cvar_RegisterVariable( &ui_renderworld );
Cvar_RegisterVariable( &cl_maxframetime );
Cvar_RegisterVariable( &cl_fixmodelinterpolationartifacts );
// these two added to shut up CS 1.5 about 'unknown' commands
Cvar_Get( "lightgamma", "1", FCVAR_ARCHIVE, "ambient lighting level (legacy, unused)" );
@@ -3057,6 +3061,8 @@ void Host_ClientFrame( void )
{
// if client is not active, do nothing
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
// 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 ));
background = MSG_ReadOneBit( msg );
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
host.features = (uint)MSG_ReadLong( msg );
Host_ValidateEngineFeatures( MSG_ReadDword( msg ));
if( !legacy )
{
@@ -1638,9 +1638,6 @@ void CL_RegisterResources( sizebuf_t *msg )
CL_ClearWorld ();
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();

View File

@@ -660,9 +660,6 @@ void CL_LegacyPrecache_f( void )
if( clgame.entities )
clgame.entities->model = cl.worldmodel;
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();

View File

@@ -824,6 +824,27 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
cd = &from->client;
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->runfuncs = runfuncs;
pmove->time = time * 1000.0f;

View File

@@ -142,8 +142,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return 1;
#endif
return 0;
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARAM_GAMEPAUSED:
return cl.paused;
case PARM_CLIENT_INGAME:
@@ -187,26 +185,30 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return CL_IsThirdPerson();
case PARM_QUAKE_COMPATIBLE:
return Host_IsQuakeCompatible();
case PARM_PLAYER_INDEX:
return cl.playernum + 1;
case PARM_VIEWENT_INDEX:
return cl.viewentity;
case PARM_CONNSTATE:
return (int)cls.state;
case PARM_PLAYING_DEMO:
return cls.demoplayback;
case PARM_WATER_LEVEL:
return cl.local.waterlevel;
case PARM_MAX_CLIENTS:
return cl.maxclients;
case PARM_LOCAL_HEALTH:
return cl.local.health;
case PARM_LOCAL_GAME:
return Host_IsLocalGame();
case PARM_NUMENTITIES:
return pfnNumberOfEntities();
case PARM_NUMMODELS:
return cl.nummodels;
case PARM_GET_CLIENT_PTR:
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;

View File

@@ -2624,7 +2624,7 @@ CL_UpdateFlashlight
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 vecSrc, vecEnd;
@@ -2684,6 +2684,41 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
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
@@ -2693,50 +2728,41 @@ apply various effects to entity origin or attachment
*/
void CL_AddEntityEffects( cl_entity_t *ent )
{
// yellow flies effect 'monster stuck in the wall'
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ) && !RP_LOCALCLIENT( ent ))
R_EntityParticles( ent );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
// players have special set of effects, from CL_LinkPlayers
if( ent->player && ent->index != cl.viewentity )
{
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 );
}
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;
}
}
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
else
{
dlight_t *dl = CL_AllocDlight( ent->index );
dl->color.r = dl->color.g = dl->color.b = 250;
if( ent->player ) dl->radius = 400; // don't flickering
else dl->radius = COM_RandomFloat( 400, 431 );
VectorCopy( ent->origin, dl->origin );
dl->die = cl.time + 0.001;
dl->origin[2] += 16.0f;
}
// from CL_LinkPacketEntities
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ))
R_EntityParticles( ent );
// add light effect
if( FBitSet( ent->curstate.effects, EF_LIGHT ))
{
dlight_t *dl = CL_AllocDlight( ent->index );
dl->color.r = dl->color.g = dl->color.b = 100;
VectorCopy( ent->origin, dl->origin );
R_RocketFlare( ent->origin );
dl->die = cl.time + 0.001;
dl->radius = 200;
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
R_EntityBrightlight( ent, ent->index, 0 );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
R_EntityDimlight( ent, ent->index );
if( FBitSet( ent->curstate.effects, EF_LIGHT ))
R_EntityLight( ent, ent->curstate.number );
}
// 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 );
vec3_t fv;
@@ -2765,15 +2791,11 @@ void CL_AddModelEffects( cl_entity_t *ent )
vec3_t neworigin;
vec3_t oldorigin;
if( !ent->model ) return;
if( !ent->model || ent->player )
return;
switch( ent->model->type )
{
case mod_alias:
case mod_studio:
break;
default: return;
}
if( ent->model->type != mod_alias && ent->model->type != mod_studio )
return;
if( cls.demoplayback == DEMO_QUAKE1 )
{
@@ -2793,19 +2815,15 @@ void CL_AddModelEffects( cl_entity_t *ent )
if( FBitSet( ent->model->flags, STUDIO_GIB ))
R_RocketTrail( oldorigin, neworigin, 2 );
if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
else if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
R_RocketTrail( oldorigin, neworigin, 4 );
if( FBitSet( ent->model->flags, STUDIO_TRACER ))
else if( FBitSet( ent->model->flags, STUDIO_TRACER ))
R_RocketTrail( oldorigin, neworigin, 3 );
if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
else if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
R_RocketTrail( oldorigin, neworigin, 5 );
if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
else 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;
VectorCopy( ent->origin, dl->origin );
@@ -2819,11 +2837,9 @@ void CL_AddModelEffects( cl_entity_t *ent )
R_RocketTrail( oldorigin, neworigin, 0 );
}
if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
else if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
R_RocketTrail( oldorigin, neworigin, 1 );
if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
else if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
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 );
struct dlight_s *CL_AllocDlight( 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_AddModelEffects( cl_entity_t *ent );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );

View File

@@ -549,5 +549,6 @@ void V_PostRender( void )
SCR_MakeScreenShot();
ref.dllFuncs.R_AllowFog( true );
Platform_SetTimer( 0.0f );
ref.dllFuncs.R_EndFrame();
}

View File

@@ -174,6 +174,26 @@ typedef struct
// at every server map change
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 validsequence; // this is the sequence number of the last good
// 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 audio_prepped; // false if on new level or new snd dll
qboolean paused;
int delta_sequence; // acknowledged sequence number
@@ -205,11 +224,6 @@ typedef struct
runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds
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
char serverinfo[MAX_SERVERINFO_STRING];
@@ -223,7 +237,6 @@ typedef struct
// player final info
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
int viewentity;
vec3_t viewangles;
vec3_t viewheight;
vec3_t punchangle;
@@ -236,14 +249,9 @@ typedef struct
float addangletotal;
float prevaddangletotal;
// predicted origin and velocity
vec3_t simorg;
// predicted velocity
vec3_t simvel;
// server state information
int playernum;
int maxclients;
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
int instanced_baseline_count;
@@ -251,8 +259,6 @@ typedef struct
char event_precache[MAX_EVENTS][MAX_QPATH];
char files_precache[MAX_CUSTOM][MAX_QPATH];
lightstyle_t lightstyles[MAX_LIGHTSTYLES];
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
int nummodels;
int numfiles;
consistency_t consistency_list[MAX_MODELS];
@@ -694,6 +700,7 @@ extern convar_t rate;
extern convar_t m_ignore;
extern convar_t r_showtree;
extern convar_t ui_renderworld;
extern convar_t cl_fixmodelinterpolationartifacts;
//=============================================================================

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_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 )
{
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 );
}
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 )
{
R_UpdateRefState();
VectorCopy( rvp->vieworigin, refState.vieworg );
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
}
static world_static_t *pfnGetWorld( void )
{
return &world;
}
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
{
clgame.dllFuncs.pfnStudioEvent( event, e );
@@ -99,16 +109,6 @@ static void *pfnMod_Extradata( int type, model_t *m )
return NULL;
}
static void pfnGetPredictedOrigin( vec3_t v )
{
VectorCopy( cl.simorg, v );
}
static color24 *pfnCL_GetPaletteColor( void ) // clgame.palette[color]
{
return clgame.palette;
}
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
{
if( width ) *width = clgame.scrInfo.iWidth;
@@ -207,11 +207,6 @@ static qboolean R_Init_Video_( const int type )
return R_Init_Video( type );
}
static model_t **pfnGetModels( void )
{
return cl.models;
}
static ref_api_t gEngfuncs =
{
pfnEngineGetParm,
@@ -246,14 +241,12 @@ static ref_api_t gEngfuncs =
Con_DrawString,
CL_DrawCenterPrint,
CL_GetViewModel,
R_BeamGetEntity,
CL_GetWaterEntity,
CL_AddVisibleEntity,
Mod_SampleSizeForFace,
Mod_BoxVisible,
pfnGetWorld,
Mod_PointInLeaf,
Mod_CreatePolygonsForHull,
@@ -270,7 +263,6 @@ static ref_api_t gEngfuncs =
Mod_ForName,
pfnMod_Extradata,
pfnGetModels,
CL_EntitySetRemapColors,
CL_GetRemapInfoForEntity,
@@ -281,8 +273,6 @@ static ref_api_t gEngfuncs =
COM_RandomFloat,
COM_RandomLong,
pfnRefGetScreenFade,
pfnGetPredictedOrigin,
pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo,
pfnSetLocalLightLevel,
Sys_CheckParm,
@@ -332,7 +322,6 @@ static ref_api_t gEngfuncs =
PM_CL_TraceLine,
CL_VisTraceLine,
CL_TraceLine,
pfnGetMoveVars,
Image_AddCmdFlags,
Image_SetForceFlags,

View File

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

View File

@@ -302,8 +302,12 @@ typedef struct host_parm_s
int argc;
char **argv;
// ==== shared through RefAPI's ref_host_t
double realtime; // host.curtime
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
uint framecount; // global framecount
@@ -344,8 +348,6 @@ typedef struct host_parm_s
poolhandle_t imagepool; // imagelib mempool
poolhandle_t soundpool; // soundlib mempool
uint features; // custom features that enables by mod-maker request
// for IN_MouseMove() easy access
int window_center_x;
int window_center_y;
@@ -422,8 +424,8 @@ void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
// zone.c
//
void Memory_Init( void );
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
void *_Mem_Alloc( poolhandle_t poolptr, 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 ) ALLOC_CHECK( 2 );
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
@@ -552,7 +554,7 @@ qboolean Host_IsLocalGame( void );
qboolean Host_IsLocalClient( void );
void Host_ShutdownServer( void );
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_InitDecals( void );
void Host_Credits( void );
@@ -793,7 +795,7 @@ void VID_Init( void );
void UI_SetActiveMenu( qboolean fActive );
void UI_ShowConnectionWarning( 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 );
void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename );

View File

@@ -490,7 +490,7 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
#ifdef XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#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
if( host.type == HOST_NORMAL )

View File

@@ -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" );
static CVAR_DEFINE_AUTO( host_framerate, "0", FCVAR_FILTERABLE, "locks frame timing to this value in seconds" );
static CVAR_DEFINE( host_sleeptime, "sleeptime", "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" );
static CVAR_DEFINE_AUTO( host_sleeptime_debug, "0", 0, "print sleeps between frames" );
CVAR_DEFINE( con_gamemaps, "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
void Sys_PrintUsage( void )
@@ -189,22 +190,66 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures
================
*/
void Host_PrintEngineFeatures( void )
static void Host_PrintEngineFeatures( int features )
{
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
Con_Reportf( "^3EXT:^7 big world support enabled\n" );
struct
{
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 ))
Con_Reportf( "^3EXT:^7 deluxemap support enabled\n" );
for( i = 0; i < ARRAYSIZE( features_str ); i++ )
{
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 ))
Con_Reportf( "^3EXT:^7 Large lightmaps enabled\n" );
validate features bits and set host.features
==============
*/
void Host_ValidateEngineFeatures( uint32_t features )
{
uint32_t mask = ENGINE_FEATURES_MASK;
if( FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
Con_Reportf( "^3EXT:^7 Compensate quake bug enabled\n" );
#if !HOST_DEDICATED
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;
}
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
@@ -628,55 +751,15 @@ Returns false if the time is too short to run a frame
qboolean Host_FilterTime( float time )
{
static double oldtime;
double fps, scale = sys_timescale.value;
double dt;
double scale = sys_timescale.value;
host.realtime += time * scale;
fps = Host_CalcFPS();
dt = host.realtime - oldtime;
// clamp the fps in multiplayer games
if( fps != 0.0 )
{
static int sleeps;
double targetframetime;
int sleeptime = Host_CalcSleep();
// limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS );
if( Host_IsDedicated( ))
targetframetime = ( 1.0 / ( fps + 1.0 ));
else targetframetime = ( 1.0 / fps );
if(( host.realtime - oldtime ) < targetframetime * scale )
{
if( sleeptime > 0 && sleeps > 0 )
{
Sys_Sleep( sleeptime );
sleeps--;
}
return false;
}
if( sleeptime > 0 && sleeps <= 0 )
{
if( host.status == HOST_FRAME )
{
// give few sleeps this frame with small margin
double targetsleeptime = targetframetime - host.pureframetime * 2;
// don't sleep if we can't keep up with the framerate
if( targetsleeptime > 0 )
sleeps = targetsleeptime / ( sleeptime * 0.001 );
else sleeps = 0;
}
else
{
// always sleep at least once in minimized/nofocus state
sleeps = 1;
}
}
}
if( !Host_Autosleep( dt, scale ))
return false;
host.frametime = host.realtime - oldtime;
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 );
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
@@ -1181,6 +1264,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
Cvar_RegisterVariable( &host_maxfps );
Cvar_RegisterVariable( &host_framerate );
Cvar_RegisterVariable( &host_sleeptime );
Cvar_RegisterVariable( &host_sleeptime_debug );
Cvar_RegisterVariable( &host_gameloaded );
Cvar_RegisterVariable( &host_clientloaded );
Cvar_RegisterVariable( &host_limitlocal );
@@ -1297,6 +1381,8 @@ Host_Shutdown
*/
void EXPORT Host_Shutdown( void )
{
qboolean error = host.status == HOST_ERR_FATAL;
if( host.shutdown_issued ) return;
host.shutdown_issued = true;
@@ -1304,7 +1390,7 @@ void EXPORT Host_Shutdown( void )
if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
#if !XASH_DEDICATED
if( host.type == HOST_NORMAL )
if( host.type == HOST_NORMAL && !error )
Host_WriteConfig();
#endif

View File

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

View File

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

View File

@@ -2998,6 +2998,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
if( isworld )
{
world.version = bmod->version;
#if !XASH_DEDICATED
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer

View File

@@ -113,6 +113,8 @@ typedef struct world_static_s
// tree visualization stuff
int recursion_level;
int max_recursion;
uint32_t version; // BSP version
} world_static_t;
#ifndef REF_DLL

View File

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

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 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
#define MS_SCAN_REQUEST "1\xFF" "0.0.0.0:0\0" // TODO: implement IP filter

View File

@@ -402,7 +402,7 @@ void Sys_Warn( const char *format, ... )
Msg( "Sys_Warn: %s\n", text );
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
Wcon_ShowConsole( false );
#endif
MSGBOX( text );
Sys_Print( text );
Platform_MessageBox( "Xash Error", text, false );
}
else
{
@@ -562,7 +562,7 @@ void Sys_Print( const char *pMsg )
Sys_PrintLog( pMsg );
Rcon_Print( pMsg );
Rcon_Print( &host.rd, pMsg );
}
/*

View File

@@ -30,9 +30,6 @@ extern "C" {
#include "crtlib.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__ )
/*

View File

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

View File

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

View File

@@ -13,11 +13,33 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <time.h>
#include <stdlib.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <signal.h>
#include <ucontext.h>
#include <time.h>
#include <unistd.h>
#include <math.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 int (*g_pfn_sd_notify)( int unset_environment, const char *state );
@@ -103,3 +125,44 @@ void Linux_Shutdown( void )
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

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

View File

@@ -28,6 +28,7 @@ GNU General Public License for more details.
#include "r_efx.h"
#include "com_image.h"
#include "filesystem.h"
#include "common/protocol.h"
// RefAPI changelog:
// 1. Initial release
@@ -38,7 +39,10 @@ GNU General Public License for more details.
// Removed previously unused calls
// Simplified remapping calls
// GetRefAPI is now expected to return REF_API_VERSION
#define REF_API_VERSION 5
// 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.
#define REF_API_VERSION 6
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
@@ -94,11 +98,6 @@ typedef struct ref_globals_s
{
qboolean developer;
float time; // cl.time
float oldtime; // cl.oldtime
double realtime; // host.realtime
double frametime; // host.frametime
// viewport width and height
int width;
int height;
@@ -120,6 +119,26 @@ typedef struct ref_globals_s
int desktopBitsPixel;
} 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
{
GL_KEEP_UNIT = -1,
@@ -251,16 +270,18 @@ typedef enum
PARM_DEV_OVERVIEW = -1,
PARM_THIRDPERSON = -2,
PARM_QUAKE_COMPATIBLE = -3,
PARM_PLAYER_INDEX = -4, // cl.playernum + 1
PARM_VIEWENT_INDEX = -5, // cl.viewentity
PARM_GET_CLIENT_PTR = -4, // ref_client_t
PARM_GET_HOST_PTR = -5, // ref_host_t
PARM_CONNSTATE = -6, // cls.state
PARM_PLAYING_DEMO = -7, // cls.demoplayback
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_GAME = -11,
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;
typedef struct ref_api_s
@@ -303,7 +324,6 @@ typedef struct ref_api_s
void (*CL_DrawCenterPrint)( void );
// entity management
struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
@@ -311,7 +331,6 @@ typedef struct ref_api_s
// brushes
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
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 );
void (*Mod_CreatePolygonsForHull)( int hullnum );
@@ -331,7 +350,6 @@ typedef struct ref_api_s
// model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model );
struct model_s **(*pfnGetModels)( void );
// remap
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
@@ -344,8 +362,6 @@ typedef struct ref_api_s
float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax );
struct screenfade_s *(*GetScreenFade)( void );
void (*GetPredictedOrigin)( vec3_t v );
color24 *(*CL_GetPaletteColor)( void ); // clgame.palette[color]
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
void (*SetLocalLightLevel)( int level ); // cl.local.light_level
int (*Sys_CheckParm)( const char *flag );
@@ -361,8 +377,8 @@ typedef struct ref_api_s
// memory
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_Alloc)( poolhandle_t poolptr, 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 );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void (*_Mem_Free)( void *data, const char *filename, int fileline );
// library management
@@ -406,7 +422,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 *(*EV_VisTraceLine )( float *start, float *end, int flags );
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
struct movevars_s *(*pfnGetMoveVars)( void );
// imagelib
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported

View File

@@ -564,7 +564,7 @@ qboolean SV_IsPlayerIndex( int idx );
int SV_CalcPing( sv_client_t *cl );
void SV_InitClientMove( 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_GetPlayerCount( int *clients, int *bots );

View File

@@ -639,7 +639,7 @@ void SV_DropClient( sv_client_t *cl, qboolean crash )
cl->frames = NULL;
if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address ))
SV_EndRedirect();
SV_EndRedirect( &host.rd );
// throw away any residual garbage in the channel.
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 )
return;
host.rd.target = target;
host.rd.buffer = buffer;
host.rd.buffersize = buffersize;
host.rd.flush = flush;
host.rd.address = adr;
host.rd.buffer[0] = 0;
if( host.rd.lines == 0 )
host.rd.lines = -1;
rd->target = target;
rd->buffer = buffer;
rd->buffersize = buffersize;
rd->flush = flush;
rd->address = adr;
rd->buffer[0] = 0;
if( rd->lines == 0 )
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 ))
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;
if( host.rd.flush )
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
if( rd->flush )
rd->flush( rd->address, rd->target, rd->buffer );
host.rd.target = 0;
host.rd.buffer = NULL;
host.rd.buffersize = 0;
host.rd.flush = NULL;
rd->target = RD_NONE;
rd->buffer = NULL;
rd->buffersize = 0;
rd->flush = NULL;
}
/*
@@ -733,24 +730,26 @@ Rcon_Print
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' )
{
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
if( rd->lines > 0 )
rd->lines--;
if( host.rd.lines > 0 )
host.rd.lines--;
rd->buffer[0] = 0;
host.rd.buffer[0] = 0;
if( !host.rd.lines )
Msg( "End of redirection!\n" );
}
if( !rd->lines )
Msg( "End of redirection!\n" );
}
}
@@ -1090,7 +1089,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
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;
for( i = 2; i < Cmd_Argc(); i++ )
@@ -1101,7 +1100,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
}
Cmd_ExecuteString( remaining );
SV_EndRedirect();
SV_EndRedirect( &host.rd );
}
else Con_Printf( S_ERROR "Bad rcon_password.\n" );
}

View File

@@ -4525,7 +4525,7 @@ static qboolean GAME_EXPORT pfnVoice_GetClientListening( int iReceiver, int iSen
iReceiver -= 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 (FBitSet( svs.clients[iSender].listeners, BIT( iReceiver )) != 0 );
@@ -4542,7 +4542,7 @@ static qboolean GAME_EXPORT pfnVoice_SetClientListening( int iReceiver, int iSen
iReceiver -= 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;
if( bListen ) SetBits( svs.clients[iSender].listeners, BIT( iReceiver ));

View File

@@ -1103,7 +1103,7 @@ void SV_Shutdown( const char *finalmsg )
Con_Printf( "%s", finalmsg );
// rcon will be disconnected
SV_EndRedirect();
SV_EndRedirect( &host.rd );
if( svs.clients )
SV_FinalMessage( finalmsg, false );

View File

@@ -2139,18 +2139,18 @@ qboolean SV_InitPhysicsAPI( void )
if( svgame.physFuncs.SV_CheckFeatures != NULL )
{
// grab common engine features (it will be shared across the network)
host.features = svgame.physFuncs.SV_CheckFeatures();
Host_PrintEngineFeatures ();
Host_ValidateEngineFeatures( svgame.physFuncs.SV_CheckFeatures( ));
}
return true;
}
// make sure what physic functions is cleared
memset( &svgame.physFuncs, 0, sizeof( svgame.physFuncs ));
Host_ValidateEngineFeatures( 0 );
return false; // just tell user about problems
}
// physic interface is missed
Host_ValidateEngineFeatures( 0 );
return true;
}

View File

@@ -37,8 +37,6 @@ def options(opt):
def configure(conf):
# check for dedicated server build
if conf.options.DEDICATED:
if conf.env.DEST_OS == 'linux':
conf.check_cc(lib='rt')
conf.define('XASH_DEDICATED', 1)
elif conf.env.DEST_OS == 'dos':
conf.options.STATIC = True
@@ -73,12 +71,9 @@ def configure(conf):
# unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support
# conf.define('XASH_FBDEV', 1)
conf.check_cc( lib = 'asound' )
conf.check_cc( lib = 'rt' )
elif conf.options.SDL12:
conf.define('XASH_SDL', 12)
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
else:
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:
conf.check_pthreads()
if conf.env.DEST_OS == 'linux':
conf.check_cc(lib='rt')
if hasattr(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_STATIC_LIBS', conf.env.STATIC_LINKING)
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('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT)
conf.define_cond('XASH_64BIT', conf.env.DEST_SIZEOF_VOID_P != 4)

View File

@@ -1287,6 +1287,26 @@ static qboolean FS_CheckForCrypt( const char *dllname )
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
@@ -1306,9 +1326,16 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
fs_ext_path = directpath;
// HACKHACK remove absoulte path to valve folder
if( !Q_strnicmp( dllname, "..\\valve\\", 9 ) || !Q_strnicmp( dllname, "../valve/", 9 ))
start += 9;
// HACKHACK remove relative path to game folder
if( !Q_strnicmp( dllname, "..", 2 ))
{
// 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
len = Q_strlen( dllname );
@@ -1677,6 +1704,9 @@ file_t *FS_SysOpen( const char *filepath, const char *mode )
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 );
return NULL;
}

View File

@@ -210,8 +210,8 @@ typedef struct fs_interface_t
// memory
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_Alloc)( poolhandle_t poolptr, 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 );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 2 );
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline ) ALLOC_CHECK( 3 );
void (*_Mem_Free)( void *data, const char *filename, int fileline );
// platform

View File

@@ -765,7 +765,7 @@ similar to R_StudioDynamicLight
*/
void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
{
movevars_t *mv = gEngfuncs.pfnGetMoveVars();
movevars_t *mv = tr.movevars;
vec3_t lightDir, vecSrc, vecEnd;
vec3_t origin, dist, finalLight;
float add, radius, total;
@@ -801,7 +801,7 @@ void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
msurface_t *psurf = NULL;
pmtrace_t trace;
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_WRITE_LARGE_COORD ))
if( FBitSet( gp_host->features, ENGINE_WRITE_LARGE_COORD ))
{
vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f;
vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f;
@@ -1332,12 +1332,12 @@ static void R_AliasSetupTimings( void )
if( RI.drawWorld )
{
// synchronize with server time
g_alias.time = gpGlobals->time;
g_alias.time = gp_cl->time;
}
else
{
// menu stuff
g_alias.time = gpGlobals->realtime;
g_alias.time = gp_host->realtime;
}
m_fDoRemap = false;
@@ -1381,7 +1381,7 @@ void R_DrawAliasModel( cl_entity_t *e )
R_AliasLerpMovement( e );
if( !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPENSATE_QUAKE_BUG ))
if( !FBitSet( gp_host->features, ENGINE_COMPENSATE_QUAKE_BUG ))
e->angles[PITCH] = -e->angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim

View File

@@ -608,7 +608,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
if( pnew )
{
VectorCopy( pbeam->source, pnew->org );
pnew->die = gpGlobals->time + pbeam->amplitude;
pnew->die = gp_cl->time + pbeam->amplitude;
VectorClear( pnew->vel );
pnew->next = particles;
@@ -655,7 +655,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
VectorMA( delta, -pbeam->width, normal, last2 );
div = 1.0f / pbeam->amplitude;
fraction = ( pbeam->die - gpGlobals->time ) * div;
fraction = ( pbeam->die - gp_cl->time ) * div;
vLast = 0.0f;
vStep = 1.0f;
@@ -688,7 +688,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
if( particles->next != NULL )
{
fraction = (particles->die - gpGlobals->time) * div;
fraction = (particles->die - gp_cl->time) * div;
}
else
{
@@ -867,12 +867,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
// get attachment
if( attach > 0 )
VectorCopy( ent->attachment[attach - 1], pt );
else if( ent->index == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) )
{
vec3_t simorg;
gEngfuncs.GetPredictedOrigin( simorg );
VectorCopy( simorg, pt );
}
else if( ent->index == ( gp_cl->playernum + 1 ))
VectorCopy( gp_cl->simorg, pt );
else VectorCopy( ent->origin, pt );
return true;
@@ -916,7 +912,7 @@ qboolean R_BeamRecomputeEndpoints( BEAM *pbeam )
else if( !FBitSet( pbeam->flags, FBEAM_FOREVER ))
{
ClearBits( pbeam->flags, FBEAM_ENDENTITY );
pbeam->die = gpGlobals->time;
pbeam->die = gp_cl->time;
return false;
}
else
@@ -949,7 +945,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
if( !model || model->type != mod_sprite )
{
pbeam->flags &= ~FBEAM_ISACTIVE; // force to ignore
pbeam->die = gpGlobals->time;
pbeam->die = gp_cl->time;
return;
}
@@ -1007,7 +1003,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
if( pbeam->flags & ( FBEAM_FADEIN|FBEAM_FADEOUT ))
{
// update life cycle
pbeam->t = pbeam->freq + ( pbeam->die - gpGlobals->time );
pbeam->t = pbeam->freq + ( pbeam->die - gp_cl->time );
if( pbeam->t != 0.0f ) pbeam->t = 1.0f - pbeam->freq / pbeam->t;
}
@@ -1055,7 +1051,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
TriRenderMode( FBitSet( pbeam->flags, FBEAM_SOLID ) ? kRenderNormal : kRenderTransAdd );
if( !TriSpriteTexture( model, (int)(pbeam->frame + pbeam->frameRate * gpGlobals->time) % pbeam->frameCount ))
if( !TriSpriteTexture( model, (int)(pbeam->frame + pbeam->frameRate * gp_cl->time) % pbeam->frameCount ))
{
ClearBits( pbeam->flags, FBEAM_ISACTIVE );
return;
@@ -1160,8 +1156,8 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
VectorCopy( end, pbeam->target );
VectorSubtract( end, start, pbeam->delta );
pbeam->freq = speed * gpGlobals->time;
pbeam->die = life + gpGlobals->time;
pbeam->freq = speed * gp_cl->time;
pbeam->die = life + gp_cl->time;
pbeam->amplitude = amplitude;
pbeam->brightness = brightness;
pbeam->width = width;
@@ -1291,7 +1287,7 @@ void CL_DrawBeams( int fTrans, BEAM *active_beams )
if( !fTrans && !FBitSet( pBeam->flags, FBEAM_SOLID ))
continue;
R_BeamDraw( pBeam, gpGlobals->time - gpGlobals->oldtime );
R_BeamDraw( pBeam, gp_cl->time - gp_cl->oldtime );
}
pglShadeModel( GL_FLAT );

View File

@@ -24,6 +24,8 @@ GNU General Public License for more details.
ref_api_t gEngfuncs;
ref_globals_t *gpGlobals;
ref_client_t *gp_cl;
ref_host_t *gp_host;
static void R_ClearScreen( void )
{
@@ -234,7 +236,7 @@ static int GL_RefGetParm( int parm, int arg )
case PARM_STENCIL_ACTIVE:
return glState.stencilEnabled;
case PARM_SKY_SPHERE:
return ENGINE_GET_PARM_( parm, arg ) && !tr.fCustomSkybox;
return FBitSet( tr.world->flags, FWORLD_SKYSPHERE ) && !FBitSet( tr.world->flags, FWORLD_CUSTOM_SKYBOX );
default:
return ENGINE_GET_PARM_( parm, arg );
}
@@ -518,5 +520,8 @@ int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs,
memcpy( &gEngfuncs, engfuncs, sizeof( ref_api_t ));
gpGlobals = globals;
gp_cl = (ref_client_t *)ENGINE_GET_PARM( PARM_GET_CLIENT_PTR );
gp_host = (ref_host_t *)ENGINE_GET_PARM( PARM_GET_HOST_PTR );
return REF_API_VERSION;
}

View File

@@ -34,6 +34,7 @@ GNU General Public License for more details.
#include "common/cvar.h"
#include "gl_export.h"
#include "wadfile.h"
#include "common/mod_local.h"
#if XASH_PSVITA
int VGL_ShimInit( void );
@@ -87,10 +88,10 @@ extern poolhandle_t r_temppool;
#define RP_NONVIEWERREF (RP_ENVVIEW)
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) && e->player )
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define CL_IsViewEntityLocalPlayer() ( ENGINE_GET_PARM( PARM_VIEWENT_INDEX ) == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) )
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
#define CULL_VISIBLE 0 // not culled
#define CULL_BACKSIDE 1 // backside of transparent wall
@@ -252,13 +253,10 @@ typedef struct
// cull info
vec3_t modelorg; // relative to viewpoint
qboolean fCustomSkybox;
// get from engine
struct world_static_s *world;
world_static_t *world;
cl_entity_t *entities;
movevars_t *movevars;
model_t **models;
color24 *palette;
cl_entity_t *viewent;
@@ -401,6 +399,7 @@ void R_TranslateForEntity( cl_entity_t *e );
void R_RotateForEntity( cl_entity_t *e );
void R_SetupGL( qboolean set_gl_state );
void R_AllowFog( qboolean allowed );
qboolean R_OpaqueEntity( cl_entity_t *ent );
void R_SetupFrustum( void );
void R_FindViewLeaf( void );
void R_CheckGamma( void );
@@ -725,6 +724,8 @@ extern glstate_t glState;
extern glwstate_t glw_state;
extern ref_api_t gEngfuncs;
extern ref_globals_t *gpGlobals;
extern ref_client_t *gp_cl;
extern ref_host_t *gp_host;
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( ( parm ), 0 )
@@ -734,15 +735,21 @@ extern ref_globals_t *gpGlobals;
//
static inline cl_entity_t *CL_GetEntityByIndex( int index )
{
if( unlikely( index < 0 || index >= tr.max_entities || !tr.entities ))
return NULL;
return &tr.entities[index];
}
static inline model_t *CL_ModelHandle( int index )
{
return tr.models[index];
if( unlikely( index < 0 || index >= gp_cl->nummodels ))
return NULL;
return gp_cl->models[index];
}
#define WORLDMODEL (tr.models[1])
#define WORLDMODEL (gp_cl->models[1])
//
// renderer cvars
@@ -774,6 +781,7 @@ extern convar_t r_lockfrustum;
extern convar_t r_traceglow;
extern convar_t r_vbo;
extern convar_t r_vbo_dlightmode;
extern convar_t r_vbo_detail;
extern convar_t r_studio_sort_textures;
extern convar_t r_studio_drawelements;
extern convar_t r_ripple;

View File

@@ -29,6 +29,7 @@ CVAR_DEFINE_AUTO( r_lockfrustum, "0", FCVAR_CHEAT, "lock frustrum area at curren
CVAR_DEFINE_AUTO( r_traceglow, "0", FCVAR_GLCONFIG, "cull flares behind models" );
CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" );
CVAR_DEFINE( r_vbo_detail, "gl_vbo_detail", "0", FCVAR_ARCHIVE, "detail vbo mode (0: disable, 1: multipass, 2: singlepass, broken decal dlights)" );
CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" );
CVAR_DEFINE_AUTO( r_ripple, "0", FCVAR_GLCONFIG, "enable software-like water texture ripple simulation" );
CVAR_DEFINE_AUTO( r_ripple_updatetime, "0.05", FCVAR_GLCONFIG, "how fast ripple simulation is" );
@@ -1244,6 +1245,7 @@ static void R_CheckVBO( void )
gEngfuncs.Cvar_RegisterVariable( &r_vbo );
gEngfuncs.Cvar_RegisterVariable( &r_vbo_dlightmode );
gEngfuncs.Cvar_RegisterVariable( &r_vbo_detail );
}
/*
@@ -1285,11 +1287,10 @@ qboolean R_Init( void )
}
// see R_ProcessEntData for tr.entities initialization
tr.world = gEngfuncs.GetWorld();
tr.models = gEngfuncs.pfnGetModels();
tr.movevars = gEngfuncs.pfnGetMoveVars();
tr.palette = gEngfuncs.CL_GetPaletteColor();
tr.viewent = gEngfuncs.GetViewModel();
tr.world = (struct world_static_s *)ENGINE_GET_PARM( PARM_GET_WORLD_PTR );
tr.movevars = (movevars_t *)ENGINE_GET_PARM( PARM_GET_MOVEVARS_PTR );
tr.palette = (color24 *)ENGINE_GET_PARM( PARM_GET_PALETTE_PTR );
tr.viewent = (cl_entity_t *)ENGINE_GET_PARM( PARM_GET_VIEWENT_PTR );
GL_SetDefaults();
R_CheckVBO();

View File

@@ -36,7 +36,7 @@ void CL_RunLightStyles( void )
{
int i, k, flight, clight;
float l, lerpfrac, backlerp;
float frametime = (gpGlobals->time - gpGlobals->oldtime);
float frametime = (gp_cl->time - gp_cl->oldtime);
float scale;
lightstyle_t *ls;
@@ -55,7 +55,7 @@ void CL_RunLightStyles( void )
continue;
}
if( !ENGINE_GET_PARM( PARAM_GAMEPAUSED ) && frametime <= 0.1f )
if( !gp_cl->paused && frametime <= 0.1f )
ls->time += frametime; // evaluate local time
flight = (int)Q_floor( ls->time * 10 );
@@ -160,7 +160,7 @@ void R_PushDlights( void )
{
l = gEngfuncs.GetDynamicLight( i );
if( l->die < gpGlobals->time || !l->radius )
if( l->die < gp_cl->time || !l->radius )
continue;
if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 ))

View File

@@ -61,7 +61,7 @@ R_OpaqueEntity
Opaque entity can be brush or studio model but sprite
===============
*/
static qboolean R_OpaqueEntity( cl_entity_t *ent )
qboolean R_OpaqueEntity( cl_entity_t *ent )
{
if( R_GetEntityRenderMode( ent ) == kRenderNormal )
return true;
@@ -339,8 +339,8 @@ void R_SetupFrustum( void )
if( RP_NORMALPASS() && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ) && ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97f + sin( gpGlobals->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03f - sin( gpGlobals->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97f + sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03f - sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
}
// build the transformation matrix for the given view angles
@@ -954,7 +954,7 @@ void R_RenderScene( void )
// frametime is valid only for normal pass
if( RP_NORMALPASS( ))
tr.frametime = gpGlobals->time - gpGlobals->oldtime;
tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0;
// begin a new frame
@@ -1181,16 +1181,16 @@ int CL_FxBlend( cl_entity_t *e )
switch( e->curstate.renderfx )
{
case kRenderFxPulseSlowWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 2 + offset );
blend = e->curstate.renderamt + 0x40 * sin( gp_cl->time * 2 + offset );
break;
case kRenderFxPulseFastWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 8 + offset );
blend = e->curstate.renderamt + 0x40 * sin( gp_cl->time * 8 + offset );
break;
case kRenderFxPulseSlow:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 2 + offset );
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 2 + offset );
break;
case kRenderFxPulseFast:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 8 + offset );
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( RP_NORMALPASS( ))
@@ -1229,27 +1229,27 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( gpGlobals->time * 4 + offset );
blend = 20 * sin( gp_cl->time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( gpGlobals->time * 16 + offset );
blend = 20 * sin( gp_cl->time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( gpGlobals->time * 36 + offset );
blend = 20 * sin( gp_cl->time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * (sin( gpGlobals->time * 2 ) + sin( gpGlobals->time * 17 + offset ));
blend = 20 * (sin( gp_cl->time * 2 ) + sin( gp_cl->time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * (sin( gpGlobals->time * 16 ) + sin( gpGlobals->time * 23 + offset ));
blend = 20 * (sin( gp_cl->time * 16 ) + sin( gp_cl->time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;

View File

@@ -87,7 +87,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
p->color = bound( 0, p->color, 255 );
color = tr.palette[p->color];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
alpha = 255 * (p->die - gp_cl->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
@@ -194,7 +194,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
for( p = cl_active_tracers; p; p = p->next )
{
atten = (p->die - gpGlobals->time);
atten = (p->die - gp_cl->time);
if( atten > 0.1f ) atten = 0.1f;
VectorScale( p->vel, ( p->ramp * atten ), delta );
@@ -259,7 +259,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
p->vel[1] *= scale;
p->vel[2] -= gravity;
p->packedColor = 255 * (p->die - gpGlobals->time) * 2;
p->packedColor = 255 * (p->die - gp_cl->time) * 2;
if( p->packedColor > 255 ) p->packedColor = 255;
}
else if( p->type == pt_slowgrav )

File diff suppressed because it is too large Load Diff

View File

@@ -430,7 +430,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by zero
targettime = gpGlobals->time - ((int)( gpGlobals->time / fullinterval )) * fullinterval;
targettime = gp_cl->time - ((int)( gp_cl->time / fullinterval )) * fullinterval;
for( i = 0; i < (numframes - 1); i++ )
{
@@ -494,25 +494,25 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
// this can be happens when rendering switched between single and angled frames
// or change model on replace delta-entity
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 1.0f;
}
if( ent->latched.sequencetime < gpGlobals->time )
if( ent->latched.sequencetime < gp_cl->time )
{
if( frame != ent->latched.prevblending[1] )
{
ent->latched.prevblending[0] = ent->latched.prevblending[1];
ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gpGlobals->time - ent->latched.sequencetime) * 11.0f;
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * 11.0f;
}
else
{
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
}
@@ -526,7 +526,7 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
{
// reset interpolation on change model
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
@@ -541,7 +541,7 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
numframes = pspritegroup->numframes;
fullinterval = pintervals[numframes-1];
jinterval = pintervals[1] - pintervals[0];
time = gpGlobals->time;
time = gp_cl->time;
jtime = 0.0f;
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
@@ -580,25 +580,25 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
// this can be happens when rendering switched between single and angled frames
// or change model on replace delta-entity
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 1.0f;
}
if( ent->latched.sequencetime < gpGlobals->time )
if( ent->latched.sequencetime < gp_cl->time )
{
if( frame != ent->latched.prevblending[1] )
{
ent->latched.prevblending[0] = ent->latched.prevblending[1];
ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gpGlobals->time - ent->latched.sequencetime) * ent->curstate.framerate;
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * ent->curstate.framerate;
}
else
{
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
}

View File

@@ -174,14 +174,14 @@ static void R_StudioSetupTimings( void )
if( RI.drawWorld )
{
// synchronize with server time
g_studio.time = gpGlobals->time;
g_studio.frametime = gpGlobals->time - gpGlobals->oldtime;
g_studio.time = gp_cl->time;
g_studio.frametime = gp_cl->time - gp_cl->oldtime;
}
else
{
// menu stuff
g_studio.time = gpGlobals->realtime;
g_studio.frametime = gpGlobals->frametime;
g_studio.time = gp_host->realtime;
g_studio.frametime = gp_host->frametime;
}
}
@@ -424,8 +424,8 @@ pfnGetEngineTimes
static void pfnGetEngineTimes( int *framecount, double *current, double *old )
{
if( framecount ) *framecount = tr.realframecount;
if( current ) *current = gpGlobals->time;
if( old ) *old = gpGlobals->oldtime;
if( current ) *current = gp_cl->time;
if( old ) *old = gp_cl->oldtime;
}
/*
@@ -596,12 +596,12 @@ void R_StudioSetUpTransform( cl_entity_t *e )
VectorCopy( e->angles, angles );
// interpolate monsters position (moved into UpdateEntityFields by user request)
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPUTE_STUDIO_LERP ))
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( gp_host->features, ENGINE_COMPUTE_STUDIO_LERP ))
{
R_StudioLerpMovement( e, g_studio.time, origin, angles );
}
if( !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPENSATE_QUAKE_BUG ))
if( !FBitSet( gp_host->features, ENGINE_COMPENSATE_QUAKE_BUG ))
angles[PITCH] = -angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim
@@ -1324,7 +1324,7 @@ R_StudioDynamicLight
*/
void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
{
movevars_t *mv = gEngfuncs.pfnGetMoveVars();
movevars_t *mv = tr.movevars;
vec3_t lightDir, vecSrc, vecEnd;
vec3_t origin, dist, finalLight;
float add, radius, total;
@@ -1360,7 +1360,7 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
msurface_t *psurf = NULL;
pmtrace_t trace;
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_WRITE_LARGE_COORD ))
if( FBitSet( gp_host->features, ENGINE_WRITE_LARGE_COORD ))
{
vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f;
vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f;
@@ -2242,8 +2242,7 @@ static void R_StudioDrawPoints( void )
g_studio.numverts = g_studio.numelems = 0;
// safety bounding the skinnum
m_skinnum = bound( 0, RI.currententity->curstate.skin, ( m_pStudioHeader->numskinfamilies - 1 ));
m_skinnum = RI.currententity->curstate.skin;
ptexture = (mstudiotexture_t *)((byte *)m_pStudioHeader + m_pStudioHeader->textureindex);
pvertbone = ((byte *)m_pStudioHeader + m_pSubModel->vertinfoindex);
pnormbone = ((byte *)m_pStudioHeader + m_pSubModel->norminfoindex);
@@ -2253,7 +2252,8 @@ static void R_StudioDrawPoints( void )
pstudionorms = (vec3_t *)((byte *)m_pStudioHeader + m_pSubModel->normindex);
pskinref = (short *)((byte *)m_pStudioHeader + m_pStudioHeader->skinindex);
if( m_skinnum != 0 ) pskinref += (m_skinnum * m_pStudioHeader->numskinref);
if( m_skinnum > 0 && m_skinnum < m_pStudioHeader->numskinfamilies )
pskinref += (m_skinnum * m_pStudioHeader->numskinref);
if( FBitSet( m_pStudioHeader->flags, STUDIO_HAS_BONEWEIGHTS ) && m_pSubModel->blendvertinfoindex != 0 && m_pSubModel->blendnorminfoindex != 0 )
{
@@ -2756,7 +2756,7 @@ static void R_StudioClientEvents( void )
ClearBits( e->curstate.effects, EF_MUZZLEFLASH );
VectorCopy( e->attachment[0], el->origin );
el->die = gpGlobals->time + 0.05f;
el->die = gp_cl->time + 0.05f;
el->color.r = 255;
el->color.g = 192;
el->color.b = 64;
@@ -2772,7 +2772,7 @@ static void R_StudioClientEvents( void )
return;
end = R_StudioEstimateFrame( e, pseqdesc, g_studio.time );
start = end - e->curstate.framerate * gpGlobals->frametime * pseqdesc->fps;
start = end - e->curstate.framerate * gp_host->frametime * pseqdesc->fps;
pevent = (mstudioevent_t *)((byte *)m_pStudioHeader + pseqdesc->eventindex);
if( e->latched.sequencetime == e->curstate.animtime )
@@ -3297,7 +3297,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
m_nPlayerIndex = pplayer->number - 1;
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= ENGINE_GET_PARM( PARM_MAX_CLIENTS ) )
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= gp_cl->maxclients )
return 0;
RI.currentmodel = R_StudioSetupPlayerModel( m_nPlayerIndex );
@@ -3379,7 +3379,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
RI.currententity->curstate.body = 255;
}
if( !( !gpGlobals->developer && ENGINE_GET_PARM( PARM_MAX_CLIENTS ) == 1 ) && ( RI.currentmodel == RI.currententity->model ))
if( !( !gpGlobals->developer && gp_cl->maxclients == 1 ) && ( RI.currentmodel == RI.currententity->model ))
RI.currententity->curstate.body = 1; // force helmet
lighting.plightvec = dir;
@@ -3442,7 +3442,7 @@ static int R_StudioDrawModel( int flags )
int result;
if( RI.currententity->curstate.renderamt <= 0 ||
RI.currententity->curstate.renderamt > ENGINE_GET_PARM( PARM_MAX_CLIENTS ) )
RI.currententity->curstate.renderamt > gp_cl->maxclients )
return 0;
// get copy of player
@@ -3527,7 +3527,7 @@ static int R_StudioDrawModel( int flags )
R_StudioDrawModelInternal
=================
*/
void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
{
if( !RI.drawWorld )
{
@@ -3560,22 +3560,42 @@ void R_DrawStudioModel( cl_entity_t *e )
{
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
}
else
else if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment ), **entities;
uint i, num_entities;
if( parent && parent->model && parent->model->type == mod_studio )
{
RI.currententity = parent;
R_StudioDrawModelInternal( RI.currententity, 0 );
VectorCopy( parent->curstate.origin, e->curstate.origin );
VectorCopy( parent->origin, e->origin );
RI.currententity = e;
}
if( !parent || !parent->model || parent->model->type != mod_studio )
return;
if( R_OpaqueEntity( parent ))
{
entities = tr.draw_list->solid_entities;
num_entities = tr.draw_list->num_solid_entities;
}
else
{
entities = tr.draw_list->trans_entities;
num_entities = tr.draw_list->num_solid_entities;
}
for( i = 0; i < num_entities; i++ )
{
if( (*entities)[i].index != e->curstate.aiment )
continue;
RI.currententity = &(*entities)[i];
R_StudioDrawModelInternal( RI.currententity, 0 );
VectorCopy( RI.currententity->curstate.origin, e->curstate.origin );
VectorCopy( RI.currententity->origin, e->origin );
RI.currententity = e;
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
break;
}
}
else
{
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
}
}
@@ -3607,7 +3627,7 @@ void R_RunViewmodelEvents( void )
R_StudioSetupTimings();
gEngfuncs.GetPredictedOrigin( simorg );
VectorCopy( gp_cl->simorg, simorg );
for( i = 0; i < 4; i++ )
VectorCopy( simorg, RI.currententity->attachment[i] );
RI.currentmodel = RI.currententity->model;
@@ -3756,7 +3776,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
gEngfuncs.Image_SetMDLPointer((byte *)phdr + ptexture->index);
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_IMPROVED_LINETRACE ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
if( FBitSet( gp_host->features, ENGINE_IMPROVED_LINETRACE ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing
// build the texname

View File

@@ -332,7 +332,7 @@ void R_AddSkyBoxSurface( msurface_t *fa )
float *v;
int i;
if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) && fa->polys && !tr.fCustomSkybox )
if( FBitSet( tr.world->flags, FWORLD_SKYSPHERE ) && fa->polys && !FBitSet( tr.world->flags, FWORLD_CUSTOM_SKYBOX ))
{
glpoly_t *p = fa->polys;
@@ -376,7 +376,7 @@ void R_UnloadSkybox( void )
tr.skyboxbasenum = SKYBOX_BASE_NUM; // set skybox base (to let some mods load hi-res skyboxes)
memset( tr.skyboxTextures, 0, sizeof( tr.skyboxTextures ));
tr.fCustomSkybox = false;
ClearBits( tr.world->flags, FWORLD_CUSTOM_SKYBOX );
}
/*
@@ -478,7 +478,7 @@ void R_SetupSky( const char *skyboxname )
if( i == 6 )
{
tr.fCustomSkybox = true;
SetBits( tr.world->flags, FWORLD_CUSTOM_SKYBOX );
gEngfuncs.Con_DPrintf( "done\n" );
return; // loaded
}
@@ -526,7 +526,7 @@ static void R_CloudTexCoord( vec3_t v, float speed, float *s, float *t )
float length, speedscale;
vec3_t dir;
speedscale = gpGlobals->time * speed;
speedscale = gp_cl->time * speed;
speedscale -= (int)speedscale & ~127;
VectorSubtract( v, RI.vieworg, dir );
@@ -813,8 +813,8 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
{
if( waveHeight )
{
nv = r_turbsin[(int)(gpGlobals->time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
nv = (r_turbsin[(int)(v[0] * 5.0f + gpGlobals->time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
nv = r_turbsin[(int)(gp_cl->time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
nv = (r_turbsin[(int)(v[0] * 5.0f + gp_cl->time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
nv = nv * waveHeight + v[2];
}
else nv = v[2];
@@ -824,8 +824,8 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
if( !r_ripple.value )
{
s = os + r_turbsin[(int)((ot * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
t = ot + r_turbsin[(int)((os * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
s = os + r_turbsin[(int)((ot * 0.125f + gp_cl->time) * TURBSCALE) & 255];
t = ot + r_turbsin[(int)((os * 0.125f + gp_cl->time) * TURBSCALE) & 255];
}
else
{
@@ -865,7 +865,7 @@ void R_ResetRipples( void )
{
g_ripple.curbuf = g_ripple.buf[0];
g_ripple.oldbuf = g_ripple.buf[1];
g_ripple.time = g_ripple.oldtime = gpGlobals->time - 0.1;
g_ripple.time = g_ripple.oldtime = gp_cl->time - 0.1;
memset( g_ripple.buf, 0, sizeof( g_ripple.buf ));
}
@@ -936,14 +936,14 @@ static int MostSignificantBit( unsigned int v )
void R_AnimateRipples( void )
{
double frametime = gpGlobals->time - g_ripple.time;
double frametime = gp_cl->time - g_ripple.time;
g_ripple.update = r_ripple.value && frametime >= r_ripple_updatetime.value;
if( !g_ripple.update )
return;
g_ripple.time = gpGlobals->time;
g_ripple.time = gp_cl->time;
R_SwapBufs();

View File

@@ -611,7 +611,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
if( pnew )
{
VectorCopy( pbeam->source, pnew->org );
pnew->die = gpGlobals->time + pbeam->amplitude;
pnew->die = gp_cl->time + pbeam->amplitude;
VectorClear( pnew->vel );
pnew->next = particles;
@@ -658,7 +658,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
VectorMA( delta, -pbeam->width, normal, last2 );
div = 1.0f / pbeam->amplitude;
fraction = ( pbeam->die - gpGlobals->time ) * div;
fraction = ( pbeam->die - gp_cl->time ) * div;
vLast = 0.0f;
vStep = 1.0f;
@@ -694,7 +694,7 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
if( particles->next != NULL )
{
fraction = (particles->die - gpGlobals->time) * div;
fraction = (particles->die - gp_cl->time) * div;
}
else
{
@@ -880,12 +880,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
// get attachment
if( attach > 0 )
VectorCopy( ent->attachment[attach - 1], pt );
else if( ent->index == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) )
{
vec3_t simorg;
gEngfuncs.GetPredictedOrigin( simorg );
VectorCopy( simorg, pt );
}
else if( ent->index == ( gp_cl->playernum + 1 ))
VectorCopy( gp_cl->simorg, pt );
else VectorCopy( ent->origin, pt );
return true;
@@ -929,7 +925,7 @@ qboolean R_BeamRecomputeEndpoints( BEAM *pbeam )
else if( !FBitSet( pbeam->flags, FBEAM_FOREVER ))
{
ClearBits( pbeam->flags, FBEAM_ENDENTITY );
pbeam->die = gpGlobals->time;
pbeam->die = gp_cl->time;
return false;
}
else
@@ -962,7 +958,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
if( !model || model->type != mod_sprite )
{
pbeam->flags &= ~FBEAM_ISACTIVE; // force to ignore
pbeam->die = gpGlobals->time;
pbeam->die = gp_cl->time;
return;
}
@@ -1020,7 +1016,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
if( pbeam->flags & ( FBEAM_FADEIN|FBEAM_FADEOUT ))
{
// update life cycle
pbeam->t = pbeam->freq + ( pbeam->die - gpGlobals->time );
pbeam->t = pbeam->freq + ( pbeam->die - gp_cl->time );
if( pbeam->t != 0.0f ) pbeam->t = 1.0f - pbeam->freq / pbeam->t;
}
@@ -1068,7 +1064,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
TriRenderMode( FBitSet( pbeam->flags, FBEAM_SOLID ) ? kRenderNormal : kRenderTransAdd );
if( !TriSpriteTexture( model, (int)(pbeam->frame + pbeam->frameRate * gpGlobals->time) % pbeam->frameCount ))
if( !TriSpriteTexture( model, (int)(pbeam->frame + pbeam->frameRate * gp_cl->time) % pbeam->frameCount ))
{
ClearBits( pbeam->flags, FBEAM_ISACTIVE );
return;
@@ -1173,8 +1169,8 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
VectorCopy( end, pbeam->target );
VectorSubtract( end, start, pbeam->delta );
pbeam->freq = speed * gpGlobals->time;
pbeam->die = life + gpGlobals->time;
pbeam->freq = speed * gp_cl->time;
pbeam->die = life + gp_cl->time;
pbeam->amplitude = amplitude;
pbeam->brightness = brightness;
pbeam->width = width;
@@ -1304,7 +1300,7 @@ void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
if( !fTrans && !FBitSet( pBeam->flags, FBEAM_SOLID ))
continue;
R_BeamDraw( pBeam, gpGlobals->time - gpGlobals->oldtime );
R_BeamDraw( pBeam, gp_cl->time - gp_cl->oldtime );
}
//pglShadeModel( GL_FLAT );

View File

@@ -950,7 +950,7 @@ void R_RenderWorld (void)
// auto cycle the world frame for texture animation
RI.currententity = CL_GetEntityByIndex(0);
//RI.currententity->frame = (int)(gpGlobals->time*2);
//RI.currententity->frame = (int)(gp_cl->time*2);
VectorCopy (RI.vieworg, tr.modelorg);
RI.currentmodel = WORLDMODEL;

View File

@@ -17,6 +17,8 @@ GNU General Public License for more details.
ref_api_t gEngfuncs;
ref_globals_t *gpGlobals;
ref_client_t *gp_cl;
ref_host_t *gp_host;
gl_globals_t tr;
ref_speeds_t r_stats;
poolhandle_t r_temppool;
@@ -169,7 +171,7 @@ static int GL_RefGetParm( int parm, int arg )
case PARM_STENCIL_ACTIVE:
return 0; //glState.stencilEnabled;
case PARM_SKY_SPHERE:
return ENGINE_GET_PARM_( parm, arg ) && !tr.fCustomSkybox;
return 0; // ref_soft doesn't support sky sphere
default:
return ENGINE_GET_PARM_( parm, arg );
}
@@ -564,5 +566,8 @@ int EXPORT GAME_EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t
memcpy( &gEngfuncs, engfuncs, sizeof( ref_api_t ));
gpGlobals = globals;
gp_cl = (ref_client_t *)ENGINE_GET_PARM( PARM_GET_CLIENT_PTR );
gp_host = (ref_host_t *)ENGINE_GET_PARM( PARM_GET_HOST_PTR );
return REF_API_VERSION;
}

View File

@@ -864,9 +864,9 @@ void D_CalcGradients (msurface_t *pface)
{
if(pface->flags & SURF_DRAWTURB)
sadjust += 0x10000 * (-128 * ( (gpGlobals->time * 0.25f) - (int)(gpGlobals->time * 0.25f) ));
sadjust += 0x10000 * (-128 * ( (gp_cl->time * 0.25f) - (int)(gp_cl->time * 0.25f) ));
else
sadjust += 0x10000 * (-128 * ( (gpGlobals->time * 0.77f) - (int)(gpGlobals->time * 0.77f) ));
sadjust += 0x10000 * (-128 * ( (gp_cl->time * 0.77f) - (int)(gp_cl->time * 0.77f) ));
bbextents = ((pface->extents[0] << 16) >> miplevel) - 1;
}
else

View File

@@ -39,7 +39,7 @@ void GAME_EXPORT CL_RunLightStyles( void )
{
int i, k, flight, clight;
float l, lerpfrac, backlerp;
float frametime = (gpGlobals->time - gpGlobals->oldtime);
float frametime = (gp_cl->time - gp_cl->oldtime);
float scale;
lightstyle_t *ls;
@@ -58,7 +58,7 @@ void GAME_EXPORT CL_RunLightStyles( void )
continue;
}
if( !ENGINE_GET_PARM( PARAM_GAMEPAUSED ) && frametime <= 0.1f )
if( !gp_cl->paused && frametime <= 0.1f )
ls->time += frametime; // evaluate local time
flight = (int)Q_floor( ls->time * 10 );
@@ -163,7 +163,7 @@ void R_PushDlights( void )
{
l = gEngfuncs.GetDynamicLight( i );
if( l->die < gpGlobals->time || !l->radius )
if( l->die < gp_cl->time || !l->radius )
continue;
//if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 ))

View File

@@ -78,10 +78,10 @@ extern poolhandle_t r_temppool;
#define RP_NONVIEWERREF (RP_ENVVIEW)
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == gEngfuncs.GetPlayerIndex() && e->player )
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define CL_IsViewEntityLocalPlayer() ( ENGINE_GET_PARM( PARM_VIEWENT_INDEX ) == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) )
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
#define CULL_VISIBLE 0 // not culled
#define CULL_BACKSIDE 1 // backside of transparent wall
@@ -289,7 +289,6 @@ typedef struct
// cull info
vec3_t modelorg; // relative to viewpoint
qboolean fCustomSkybox;
int sample_size;
uint sample_bits;
qboolean map_unload;
@@ -297,7 +296,6 @@ typedef struct
// get from engine
cl_entity_t *entities;
movevars_t *movevars;
model_t **models;
color24 *palette;
cl_entity_t *viewent;
@@ -478,6 +476,7 @@ void R_SetupRefParams( const struct ref_viewpass_s *rvp );
void R_TranslateForEntity( cl_entity_t *e );
void R_RotateForEntity( cl_entity_t *e );
void R_SetupGL( qboolean set_gl_state );
qboolean R_OpaqueEntity( cl_entity_t *ent );
void R_AllowFog( qboolean allowed );
void R_SetupFrustum( void );
void R_FindViewLeaf( void );
@@ -676,25 +675,33 @@ void TriBrightness( float brightness );
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( (parm), 0 )
extern ref_api_t gEngfuncs;
extern ref_globals_t *gpGlobals;
extern ref_client_t *gp_cl;
extern ref_host_t *gp_host;
DECLARE_ENGINE_SHARED_CVAR_LIST()
//
// helper funcs
//
static inline cl_entity_t *CL_GetEntityByIndex( int index )
{
if( unlikely( index < 0 || index >= tr.max_entities || !tr.entities ))
return NULL;
return &tr.entities[index];
}
static inline model_t *CL_ModelHandle( int index )
{
return tr.models[index];
if( unlikely( index < 0 || index >= gp_cl->nummodels ))
return NULL;
return gp_cl->models[index];
}
#define WORLDMODEL (tr.models[1])
extern ref_api_t gEngfuncs;
extern ref_globals_t *gpGlobals;
DECLARE_ENGINE_SHARED_CVAR_LIST()
#define WORLDMODEL (gp_cl->models[1])
// todo: gl_cull.c
#define R_CullModel(...) 0

View File

@@ -145,7 +145,7 @@ R_OpaqueEntity
Opaque entity can be brush or studio model but sprite
===============
*/
static qboolean R_OpaqueEntity( cl_entity_t *ent )
qboolean R_OpaqueEntity( cl_entity_t *ent )
{
int rendermode = R_GetEntityRenderMode( ent );
@@ -441,8 +441,8 @@ void R_SetupFrustum( void )
/*if( RP_NORMALPASS() && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ) && ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( gp_cl->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gp_cl->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
}*/
// build the transformation matrix for the given view angles
@@ -1171,7 +1171,7 @@ void R_DrawBEntitiesOnList (void)
dlight_t *l = gEngfuncs.GetDynamicLight( k );
vec3_t origin_l, oldorigin;
if( l->die < gpGlobals->time || !l->radius )
if( l->die < gp_cl->time || !l->radius )
continue;
VectorCopy( l->origin, oldorigin ); // save lightorigin
@@ -1326,7 +1326,7 @@ void R_DrawBrushModel(cl_entity_t *pent)
dlight_t *l = gEngfuncs.GetDynamicLight( k );
vec3_t origin_l, oldorigin;
if( l->die < gpGlobals->time || !l->radius )
if( l->die < gp_cl->time || !l->radius )
continue;
VectorCopy( l->origin, oldorigin ); // save lightorigin
@@ -1561,7 +1561,7 @@ void GAME_EXPORT R_RenderScene( void )
// frametime is valid only for normal pass
if( RP_NORMALPASS( ))
tr.frametime = gpGlobals->time - gpGlobals->oldtime;
tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0;
// begin a new frame
@@ -1939,10 +1939,9 @@ qboolean GAME_EXPORT R_Init( void )
}
// see R_ProcessEntData for tr.entities initialization
tr.models = gEngfuncs.pfnGetModels();
tr.movevars = gEngfuncs.pfnGetMoveVars();
tr.palette = gEngfuncs.CL_GetPaletteColor();
tr.viewent = gEngfuncs.GetViewModel();
tr.movevars = (movevars_t *)ENGINE_GET_PARM( PARM_GET_MOVEVARS_PTR );
tr.palette = (color24 *)ENGINE_GET_PARM( PARM_GET_PALETTE_PTR );
tr.viewent = (cl_entity_t *)ENGINE_GET_PARM( PARM_GET_VIEWENT_PTR );
R_InitBlit( glblit );
@@ -1985,16 +1984,16 @@ int CL_FxBlend( cl_entity_t *e )
switch( e->curstate.renderfx )
{
case kRenderFxPulseSlowWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 2 + offset );
blend = e->curstate.renderamt + 0x40 * sin( gp_cl->time * 2 + offset );
break;
case kRenderFxPulseFastWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 8 + offset );
blend = e->curstate.renderamt + 0x40 * sin( gp_cl->time * 8 + offset );
break;
case kRenderFxPulseSlow:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 2 + offset );
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 2 + offset );
break;
case kRenderFxPulseFast:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 8 + offset );
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( RP_NORMALPASS( ))
@@ -2033,27 +2032,27 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( gpGlobals->time * 4 + offset );
blend = 20 * sin( gp_cl->time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( gpGlobals->time * 16 + offset );
blend = 20 * sin( gp_cl->time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( gpGlobals->time * 36 + offset );
blend = 20 * sin( gp_cl->time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * (sin( gpGlobals->time * 2 ) + sin( gpGlobals->time * 17 + offset ));
blend = 20 * (sin( gp_cl->time * 2 ) + sin( gp_cl->time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * (sin( gpGlobals->time * 16 ) + sin( gpGlobals->time * 23 + offset ));
blend = 20 * (sin( gp_cl->time * 16 ) + sin( gp_cl->time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;

View File

@@ -86,7 +86,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
p->color = bound( 0, p->color, 255 );
color = tr.palette[p->color];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
alpha = 255 * (p->die - gp_cl->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
@@ -200,7 +200,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
for( p = cl_active_tracers; p; p = p->next )
{
atten = (p->die - gpGlobals->time);
atten = (p->die - gp_cl->time);
if( atten > 0.1f ) atten = 0.1f;
VectorScale( p->vel, ( p->ramp * atten ), delta );
@@ -268,7 +268,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
p->vel[1] *= scale;
p->vel[2] -= gravity;
p->packedColor = 255 * (p->die - gpGlobals->time) * 2;
p->packedColor = 255 * (p->die - gp_cl->time) * 2;
if( p->packedColor > 255 ) p->packedColor = 255;
}
else if( p->type == pt_slowgrav )

View File

@@ -100,7 +100,7 @@ void Turbulent8 (espan_t *pspan)
float sdivz, tdivz, zi, z, du, dv, spancountminus1;
float sdivz16stepu, tdivz16stepu, zi16stepu;
r_turb_turb = sintable + ((int)(gpGlobals->time*SPEED)&(CYCLE-1));
r_turb_turb = sintable + ((int)(gp_cl->time*SPEED)&(CYCLE-1));
r_turb_sstep = 0; // keep compiler happy
r_turb_tstep = 0; // ditto
@@ -239,7 +239,7 @@ void TurbulentZ8 (espan_t *pspan, int alpha1)
if( alpha == 0 )
return;
r_turb_turb = sintable + ((int)(gpGlobals->time*SPEED)&(CYCLE-1));
r_turb_turb = sintable + ((int)(gp_cl->time*SPEED)&(CYCLE-1));
r_turb_sstep = 0; // keep compiler happy
r_turb_tstep = 0; // ditto

View File

@@ -430,7 +430,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by zero
targettime = gpGlobals->time - ((int)( gpGlobals->time / fullinterval )) * fullinterval;
targettime = gp_cl->time - ((int)( gp_cl->time / fullinterval )) * fullinterval;
for( i = 0; i < (numframes - 1); i++ )
{
@@ -494,25 +494,25 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
// this can be happens when rendering switched between single and angled frames
// or change model on replace delta-entity
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 1.0f;
}
if( ent->latched.sequencetime < gpGlobals->time )
if( ent->latched.sequencetime < gp_cl->time )
{
if( frame != ent->latched.prevblending[1] )
{
ent->latched.prevblending[0] = ent->latched.prevblending[1];
ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gpGlobals->time - ent->latched.sequencetime) * 11.0f;
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * 11.0f;
}
else
{
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
}
@@ -526,7 +526,7 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
{
// reset interpolation on change model
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
@@ -541,7 +541,7 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
numframes = pspritegroup->numframes;
fullinterval = pintervals[numframes-1];
jinterval = pintervals[1] - pintervals[0];
time = gpGlobals->time;
time = gp_cl->time;
jtime = 0.0f;
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
@@ -580,25 +580,25 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
// this can be happens when rendering switched between single and angled frames
// or change model on replace delta-entity
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 1.0f;
}
if( ent->latched.sequencetime < gpGlobals->time )
if( ent->latched.sequencetime < gp_cl->time )
{
if( frame != ent->latched.prevblending[1] )
{
ent->latched.prevblending[0] = ent->latched.prevblending[1];
ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gpGlobals->time - ent->latched.sequencetime) * ent->curstate.framerate;
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * ent->curstate.framerate;
}
else
{
ent->latched.prevblending[0] = ent->latched.prevblending[1] = frame;
ent->latched.sequencetime = gpGlobals->time;
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
}

View File

@@ -163,14 +163,14 @@ static void R_StudioSetupTimings( void )
if( RI.drawWorld )
{
// synchronize with server time
g_studio.time = gpGlobals->time;
g_studio.frametime = gpGlobals->time - gpGlobals->oldtime;
g_studio.time = gp_cl->time;
g_studio.frametime = gp_cl->time - gp_cl->oldtime;
}
else
{
// menu stuff
g_studio.time = gpGlobals->realtime;
g_studio.frametime = gpGlobals->frametime;
g_studio.time = gp_host->realtime;
g_studio.frametime = gp_host->frametime;
}
}
@@ -413,8 +413,8 @@ pfnGetEngineTimes
static void pfnGetEngineTimes( int *framecount, double *current, double *old )
{
if( framecount ) *framecount = tr.realframecount;
if( current ) *current = gpGlobals->time;
if( old ) *old = gpGlobals->oldtime;
if( current ) *current = gp_cl->time;
if( old ) *old = gp_cl->oldtime;
}
/*
@@ -585,12 +585,12 @@ void R_StudioSetUpTransform( cl_entity_t *e )
VectorCopy( e->angles, angles );
// interpolate monsters position (moved into UpdateEntityFields by user request)
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPUTE_STUDIO_LERP ))
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( gp_host->features, ENGINE_COMPUTE_STUDIO_LERP ))
{
R_StudioLerpMovement( e, g_studio.time, origin, angles );
}
if( !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPENSATE_QUAKE_BUG ))
if( !FBitSet( gp_host->features, ENGINE_COMPENSATE_QUAKE_BUG ))
angles[PITCH] = -angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim
@@ -1320,7 +1320,7 @@ R_StudioDynamicLight
*/
void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
{
movevars_t *mv = gEngfuncs.pfnGetMoveVars();
movevars_t *mv = tr.movevars;
vec3_t lightDir, vecSrc, vecEnd;
vec3_t origin, dist, finalLight;
float add, radius, total;
@@ -1356,7 +1356,7 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
msurface_t *psurf = NULL;
pmtrace_t trace;
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_WRITE_LARGE_COORD ))
if( FBitSet( gp_host->features, ENGINE_WRITE_LARGE_COORD ))
{
vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f;
vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f;
@@ -2023,8 +2023,7 @@ static void R_StudioDrawPoints( void )
if( !m_pStudioHeader ) return;
// safety bounding the skinnum
m_skinnum = bound( 0, RI.currententity->curstate.skin, ( m_pStudioHeader->numskinfamilies - 1 ));
m_skinnum = RI.currententity->curstate.skin;
ptexture = (mstudiotexture_t *)((byte *)m_pStudioHeader + m_pStudioHeader->textureindex);
pvertbone = ((byte *)m_pStudioHeader + m_pSubModel->vertinfoindex);
pnormbone = ((byte *)m_pStudioHeader + m_pSubModel->norminfoindex);
@@ -2034,7 +2033,8 @@ static void R_StudioDrawPoints( void )
pstudionorms = (vec3_t *)((byte *)m_pStudioHeader + m_pSubModel->normindex);
pskinref = (short *)((byte *)m_pStudioHeader + m_pStudioHeader->skinindex);
if( m_skinnum != 0 ) pskinref += (m_skinnum * m_pStudioHeader->numskinref);
if( m_skinnum > 0 && m_skinnum < m_pStudioHeader->numskinfamilies )
pskinref += (m_skinnum * m_pStudioHeader->numskinref);
if( FBitSet( m_pStudioHeader->flags, STUDIO_HAS_BONEWEIGHTS ) && m_pSubModel->blendvertinfoindex != 0 && m_pSubModel->blendnorminfoindex != 0 )
{
@@ -2516,7 +2516,7 @@ static void R_StudioClientEvents( void )
ClearBits( e->curstate.effects, EF_MUZZLEFLASH );
VectorCopy( e->attachment[0], el->origin );
el->die = gpGlobals->time + 0.05f;
el->die = gp_cl->time + 0.05f;
el->color.r = 255;
el->color.g = 192;
el->color.b = 64;
@@ -2532,7 +2532,7 @@ static void R_StudioClientEvents( void )
return;
end = R_StudioEstimateFrame( e, pseqdesc, g_studio.time );
start = end - e->curstate.framerate * gpGlobals->frametime * pseqdesc->fps;
start = end - e->curstate.framerate * gp_host->frametime * pseqdesc->fps;
pevent = (mstudioevent_t *)((byte *)m_pStudioHeader + pseqdesc->eventindex);
if( e->latched.sequencetime == e->curstate.animtime )
@@ -3063,7 +3063,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
m_nPlayerIndex = pplayer->number - 1;
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= ENGINE_GET_PARM( PARM_MAX_CLIENTS ) )
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= gp_cl->maxclients )
return 0;
RI.currentmodel = R_StudioSetupPlayerModel( m_nPlayerIndex );
@@ -3145,7 +3145,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
RI.currententity->curstate.body = 255;
}
if( !( !gpGlobals->developer && ENGINE_GET_PARM( PARM_MAX_CLIENTS ) == 1 ) && ( RI.currentmodel == RI.currententity->model ))
if( !( !gpGlobals->developer && gp_cl->maxclients == 1 ) && ( RI.currentmodel == RI.currententity->model ))
RI.currententity->curstate.body = 1; // force helmet
lighting.plightvec = dir;
@@ -3208,7 +3208,7 @@ static int R_StudioDrawModel( int flags )
int result;
if( RI.currententity->curstate.renderamt <= 0 ||
RI.currententity->curstate.renderamt > ENGINE_GET_PARM( PARM_MAX_CLIENTS ) )
RI.currententity->curstate.renderamt > gp_cl->maxclients )
return 0;
// get copy of player
@@ -3293,7 +3293,7 @@ static int R_StudioDrawModel( int flags )
R_StudioDrawModelInternal
=================
*/
void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
{
if( !RI.drawWorld )
{
@@ -3326,26 +3326,47 @@ void R_DrawStudioModel( cl_entity_t *e )
{
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
}
else
else if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment ), **entities;
uint i, num_entities;
if( parent && parent->model && parent->model->type == mod_studio )
{
RI.currententity = parent;
R_StudioDrawModelInternal( RI.currententity, 0 );
VectorCopy( parent->curstate.origin, e->curstate.origin );
VectorCopy( parent->origin, e->origin );
RI.currententity = e;
}
if( !parent || !parent->model || parent->model->type != mod_studio )
return;
if( R_OpaqueEntity( parent ))
{
entities = tr.draw_list->solid_entities;
num_entities = tr.draw_list->num_solid_entities;
}
else
{
entities = tr.draw_list->trans_entities;
num_entities = tr.draw_list->num_solid_entities;
}
for( i = 0; i < num_entities; i++ )
{
if( (*entities)[i].index != e->curstate.aiment )
continue;
RI.currententity = &(*entities)[i];
R_StudioDrawModelInternal( RI.currententity, 0 );
VectorCopy( RI.currententity->curstate.origin, e->curstate.origin );
VectorCopy( RI.currententity->origin, e->origin );
RI.currententity = e;
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
break;
}
}
else
{
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
}
}
/*
=================
R_RunViewmodelEvents
@@ -3373,7 +3394,7 @@ void R_RunViewmodelEvents( void )
R_StudioSetupTimings();
gEngfuncs.GetPredictedOrigin( simorg );
VectorCopy( gp_cl->simorg, simorg );
for( i = 0; i < 4; i++ )
VectorCopy( simorg, RI.currententity->attachment[i] );
RI.currentmodel = RI.currententity->model;
@@ -3538,7 +3559,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
gEngfuncs.Image_SetMDLPointer((byte *)phdr + ptexture->index);
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
if( FBitSet( gp_host->features, ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing
// build the texname

View File

@@ -401,7 +401,7 @@ texture_t *R_TextureAnim( texture_t *b )
speed = 10;
else speed = 20;
reletive = (int)(gpGlobals->time * speed) % base->anim_total;
reletive = (int)(gp_cl->time * speed) % base->anim_total;
}
@@ -455,7 +455,7 @@ texture_t *R_TextureAnimation( msurface_t *s )
speed = 10;
else speed = 20;
reletive = (int)(gpGlobals->time * speed) % base->anim_total;
reletive = (int)(gp_cl->time * speed) % base->anim_total;
}
count = 0;

View File

@@ -385,7 +385,7 @@ static qboolean LoadMDL( const char *modelname )
}
}
if( filesize < sizeof( studiohdr_t ) || filesize != model_hdr->length )
if( filesize < sizeof( studiohdr_t ) || filesize != texture_hdr->length )
{
fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", texturename );
return false;
@@ -427,7 +427,7 @@ static qboolean LoadMDL( const char *modelname )
return false;
}
if( filesize < sizeof( studiohdr_t ) || filesize != model_hdr->length )
if( filesize < sizeof( studiohdr_t ) || filesize != anim_hdr[i]->length )
{
fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", seqgroupname );
return false;

View File

@@ -123,19 +123,13 @@ ProperBoneRotationZ
*/
static void ProperBoneRotationZ( vec_t *motion, float angle )
{
float c, s, x, y;
float rot;
float tmp, rot;
rot = DEG2RAD( angle );
s = sin( rot );
c = cos( rot );
x = motion[0];
y = motion[1];
motion[0] = c * x - s * y;
motion[1] = s * x + c * y;
tmp = motion[0];
motion[0] = motion[1];
motion[1] = -tmp;
motion[5] += rot;
}
@@ -440,9 +434,12 @@ static void WriteFrameInfo( FILE *fp, mstudioanim_t *anim, mstudioseqdesc_t *seq
if( bone->parent == -1 )
{
scale = frame / (float)( seqdesc->numframes - 1 );
if( seqdesc->numframes > 1 && frame > 0 )
{
scale = frame / (float)( seqdesc->numframes - 1 );
VectorMA( motion, scale, seqdesc->linearmovement, motion );
VectorMA( motion, scale, seqdesc->linearmovement, motion );
}
ProperBoneRotationZ( motion, 270.0f );
}

20
wscript
View File

@@ -74,11 +74,11 @@ SUBDIRS = [
Subproject('3rdparty/gl-wes-v2', lambda x: not x.env.DEDICATED and x.env.GLWES),
Subproject('3rdparty/gl4es', lambda x: not x.env.DEDICATED and x.env.GL4ES),
Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)),
Subproject('ref/soft', lambda x: not x.env.DEDICATED and x.env.SOFT),
Subproject('ref/soft', lambda x: not x.env.DEDICATED and not x.env.SUPPORT_BSP2_FORMAT and x.env.SOFT),
Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED),
Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED),
Subproject('stub/client', lambda x: not x.env.DEDICATED),
Subproject('game_launch', lambda x: not x.env.SINGLE_BINARY and x.env.DEST_OS != 'android'),
Subproject('game_launch', lambda x: not x.env.DEDICATED and not x.env.DISABLE_LAUNCHER),
# disable only by external dependency presense
Subproject('3rdparty/opus', lambda x: not x.env.HAVE_SYSTEM_OPUS and not x.env.DEDICATED),
@@ -113,9 +113,6 @@ def options(opt):
grp.add_option('--gamedir', action = 'store', dest = 'GAMEDIR', default = 'valve',
help = 'engine default game directory [default: %default]')
grp.add_option('--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False,
help = 'build single "xash" binary (always enabled for dedicated) [default: %default]')
grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False,
help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %default]')
@@ -202,29 +199,23 @@ def configure(conf):
conf.options.GL4ES = True
conf.options.GLES3COMPAT = True
conf.options.GL = False
conf.options.SINGLE_BINARY = True
conf.define('XASH_SDLMAIN', 1)
elif conf.env.MAGX:
conf.options.SDL12 = True
conf.options.NO_VGUI = True
conf.options.GL = False
conf.options.LOW_MEMORY = 1
conf.options.SINGLE_BINARY = True
conf.options.NO_ASYNC_RESOLVE = True
conf.define('XASH_SDLMAIN', 1)
enforce_pic = False
elif conf.env.DEST_OS == 'dos':
conf.options.SINGLE_BINARY = True
elif conf.env.DEST_OS == 'nswitch':
conf.options.NO_VGUI = True
conf.options.GL = True
conf.options.SINGLE_BINARY = True
conf.options.NO_ASYNC_RESOLVE = True
conf.options.USE_STBTT = True
elif conf.env.DEST_OS == 'psvita':
conf.options.NO_VGUI = True
conf.options.GL = True
conf.options.SINGLE_BINARY = True
conf.options.NO_ASYNC_RESOLVE = True
conf.options.USE_STBTT = True
# we'll specify -fPIC by hand for shared libraries only
@@ -292,6 +283,7 @@ def configure(conf):
'-fdiagnostics-color=always',
# stable diagnostics, forced to error, sorted
'-Werror=alloc-size',
'-Werror=bool-compare',
'-Werror=bool-operation',
'-Werror=cast-align=strict',
@@ -321,6 +313,7 @@ def configure(conf):
'-Wmisleading-indentation',
'-Wstringop-overflow',
'-Wunintialized',
'-Walloc-zero',
# disabled, flood
# '-Wdouble-promotion',
@@ -355,7 +348,10 @@ def configure(conf):
conf.env.ENABLE_UTILS = conf.options.ENABLE_UTILS
conf.env.ENABLE_FUZZER = conf.options.ENABLE_FUZZER
conf.env.DEDICATED = conf.options.DEDICATED
conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED
conf.env.SUPPORT_BSP2_FORMAT = conf.options.SUPPORT_BSP2_FORMAT
# disable game_launch compiling on platform where it's not needed
conf.env.DISABLE_LAUNCHER = conf.env.DEST_OS in ['android', 'nswitch', 'psvita', 'dos'] or conf.env.MAGX
if conf.env.SAILFISH == 'aurora':
conf.env.DEFAULT_RPATH = '/usr/share/su.xash.Engine/lib'