mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 19:45:05 +08:00
Compare commits
113 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15bc09b06b | ||
|
|
315aea1991 | ||
|
|
380422a6dc | ||
|
|
be26ecf1c9 | ||
|
|
d2bbe9dfd2 | ||
|
|
9c929c1405 | ||
|
|
9551240680 | ||
|
|
6605d0456c | ||
|
|
99e8f7b486 | ||
|
|
5ac8f63741 | ||
|
|
9d3949a948 | ||
|
|
5bd1dd34b3 | ||
|
|
6862b14e59 | ||
|
|
dc1d65f621 | ||
|
|
fba3a2b67f | ||
|
|
b946c8455d | ||
|
|
c56e876043 | ||
|
|
9773d11464 | ||
|
|
3c28b11754 | ||
|
|
f2584dcb9d | ||
|
|
ce73838f1b | ||
|
|
49f972a7c9 | ||
|
|
1ae01d89de | ||
|
|
8e54e18c8f | ||
|
|
18136e5320 | ||
|
|
a29f1899d3 | ||
|
|
0f804ffc30 | ||
|
|
620a4b4894 | ||
|
|
4cf87c2c23 | ||
|
|
f031c31b77 | ||
|
|
c2447d8634 | ||
|
|
ae9c1d9f18 | ||
|
|
0132eb6e44 | ||
|
|
f12df54226 | ||
|
|
d971055927 | ||
|
|
6059538d77 | ||
|
|
17deba0606 | ||
|
|
82a2d272ad | ||
|
|
707a9228e1 | ||
|
|
59ddfb787f | ||
|
|
acdf1da995 | ||
|
|
f1cdab91eb | ||
|
|
05d5abe4db | ||
|
|
44e017a410 | ||
|
|
64f3884f23 | ||
|
|
6386782674 | ||
|
|
8084687e50 | ||
|
|
6c16de55c0 | ||
|
|
537237ef62 | ||
|
|
4dfc3f34cb | ||
|
|
d22bbb4213 | ||
|
|
0e3b14e9a5 | ||
|
|
afb0540aa3 | ||
|
|
4d802d8901 | ||
|
|
6a4bf4965f | ||
|
|
a3c9538d12 | ||
|
|
632264809f | ||
|
|
bcfabbe802 | ||
|
|
c244cfc937 | ||
|
|
520fc33394 | ||
|
|
f705a7cd26 | ||
|
|
65bfff69d0 | ||
|
|
9d8ba03f5e | ||
|
|
778b8ede58 | ||
|
|
f8a1a2ed71 | ||
|
|
b4a7c266b5 | ||
|
|
a488f79852 | ||
|
|
b290046503 | ||
|
|
e8409cee8b | ||
|
|
1d4d355b38 | ||
|
|
dfe12535a5 | ||
|
|
74946100f1 | ||
|
|
9a1717915c | ||
|
|
3691eb6e48 | ||
|
|
3bb7471fd3 | ||
|
|
74e09ddb12 | ||
|
|
6b73d056b2 | ||
|
|
3e7847551a | ||
|
|
91d92935fa | ||
|
|
eff033298a | ||
|
|
3a8f4961bc | ||
|
|
b81f94518a | ||
|
|
96f7f5457d | ||
|
|
498ec6b4f1 | ||
|
|
607e62a1ae | ||
|
|
d41a80bc2c | ||
|
|
643bec4071 | ||
|
|
a7e84230c3 | ||
|
|
c96cf7e22d | ||
|
|
46c61660cf | ||
|
|
f6fecce52b | ||
|
|
54a5947a3c | ||
|
|
521bc675a2 | ||
|
|
845cee2578 | ||
|
|
93ceb0e4ed | ||
|
|
13aab4e59c | ||
|
|
36c2f9e9f2 | ||
|
|
514da0ffa9 | ||
|
|
37b8d5da79 | ||
|
|
b5d602d953 | ||
|
|
c926fee13c | ||
|
|
a675806c91 | ||
|
|
683c4874f8 | ||
|
|
20ced857b4 | ||
|
|
c6c86f9665 | ||
|
|
1e0107944f | ||
|
|
21797f9ac8 | ||
|
|
c800b34cd4 | ||
|
|
1612e2d669 | ||
|
|
26d229c8ca | ||
|
|
9c66e86be1 | ||
|
|
7e9f87de2d | ||
|
|
67737446ac |
21
.cirrus.yml
21
.cirrus.yml
@@ -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
|
||||
|
||||
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: d2544938fa...b4bb815420
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1109,12 +1109,12 @@ void CL_InitEdicts( int maxclients )
|
||||
clgame.remap_info = (remap_info_t **)Mem_Calloc( clgame.mempool, sizeof( remap_info_t* ) * clgame.maxRemapInfos );
|
||||
}
|
||||
|
||||
ref.dllFuncs.R_ProcessEntData( true );
|
||||
ref.dllFuncs.R_ProcessEntData( true, clgame.entities, clgame.maxEntities );
|
||||
}
|
||||
|
||||
void CL_FreeEdicts( void )
|
||||
{
|
||||
ref.dllFuncs.R_ProcessEntData( false );
|
||||
ref.dllFuncs.R_ProcessEntData( false, NULL, 0 );
|
||||
|
||||
if( clgame.entities )
|
||||
Mem_Free( clgame.entities );
|
||||
@@ -1235,11 +1235,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
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 )
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -78,7 +78,7 @@ CL_CreateRawTextureFromPixels
|
||||
Convert texture_t struct into mstudiotexture_t prototype
|
||||
====================
|
||||
*/
|
||||
byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
static byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor, int bottomcolor )
|
||||
{
|
||||
static mstudiotexture_t pin;
|
||||
byte *pal;
|
||||
@@ -111,7 +111,7 @@ CL_DuplicateTexture
|
||||
Dupliacte texture with remap pixels
|
||||
====================
|
||||
*/
|
||||
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
const char *name;
|
||||
texture_t *tx = NULL;
|
||||
@@ -154,7 +154,7 @@ CL_UpdateStudioTexture
|
||||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
|
||||
{
|
||||
rgbdata_t *pic;
|
||||
texture_t *tx = NULL;
|
||||
@@ -215,7 +215,7 @@ CL_UpdateAliasTexture
|
||||
Update texture top and bottom colors
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
static void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int skinnum, int topcolor, int bottomcolor )
|
||||
{
|
||||
char texname[MAX_QPATH];
|
||||
rgbdata_t skin, *pic;
|
||||
@@ -247,6 +247,68 @@ void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int sk
|
||||
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
static void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_AllocRemapInfo
|
||||
@@ -255,7 +317,7 @@ Allocate new remap info per entity
|
||||
and make copy of remap textures
|
||||
====================
|
||||
*/
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
static void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
studiohdr_t *phdr;
|
||||
@@ -362,68 +424,6 @@ void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int b
|
||||
info->model = model;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_UpdateRemapInfo
|
||||
|
||||
Update all remaps per entity
|
||||
====================
|
||||
*/
|
||||
void CL_UpdateRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
|
||||
{
|
||||
remap_info_t *info;
|
||||
int i;
|
||||
|
||||
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
|
||||
info = clgame.remap_info[i];
|
||||
if( !info ) return; // no remap info
|
||||
|
||||
if( info->topcolor == topcolor && info->bottomcolor == bottomcolor )
|
||||
return; // values is valid
|
||||
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
CL_UpdateStudioTexture( entity, &info->ptexture[i], topcolor, bottomcolor );
|
||||
}
|
||||
else CL_UpdateAliasTexture( entity, &info->textures[i], i, topcolor, bottomcolor );
|
||||
}
|
||||
|
||||
info->topcolor = topcolor;
|
||||
info->bottomcolor = bottomcolor;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_FreeRemapInfo
|
||||
|
||||
Release remap info per entity
|
||||
====================
|
||||
*/
|
||||
void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_ClearAllRemaps
|
||||
@@ -446,3 +446,21 @@ void CL_ClearAllRemaps( void )
|
||||
}
|
||||
clgame.remap_info = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_EntitySetRemapColors
|
||||
=============
|
||||
*/
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom )
|
||||
{
|
||||
CL_AllocRemapInfo( e, mod, top, bottom );
|
||||
|
||||
if( CL_GetRemapInfoForEntity( e ))
|
||||
{
|
||||
CL_UpdateRemapInfo( e, top, bottom );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -2665,7 +2665,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
// update flashlight endpos
|
||||
dl = CL_AllocDlight( ent->index );
|
||||
#if 1
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace.ent].info );
|
||||
hit = CL_GetEntityByIndex( clgame.pmove->physents[trace.ent].info );
|
||||
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
|
||||
VectorCopy( hit->origin, dl->origin );
|
||||
else VectorCopy( trace.endpos, dl->origin );
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -549,5 +549,6 @@ void V_PostRender( void )
|
||||
|
||||
SCR_MakeScreenShot();
|
||||
ref.dllFuncs.R_AllowFog( true );
|
||||
Platform_SetTimer( 0.0f );
|
||||
ref.dllFuncs.R_EndFrame();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
@@ -996,9 +1003,7 @@ void CL_EmitEntities( void );
|
||||
// cl_remap.c
|
||||
//
|
||||
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
|
||||
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
|
||||
void CL_FreeRemapInfo( remap_info_t *info );
|
||||
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
|
||||
qboolean CL_EntitySetRemapColors( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||
void CL_ClearAllRemaps( void );
|
||||
|
||||
//
|
||||
|
||||
@@ -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( int color ) // clgame.palette[color]
|
||||
{
|
||||
return &clgame.palette[color];
|
||||
}
|
||||
|
||||
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
|
||||
{
|
||||
if( width ) *width = clgame.scrInfo.iWidth;
|
||||
@@ -158,11 +158,6 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
|
||||
0;
|
||||
}
|
||||
|
||||
static poolhandle_t pfnImage_GetPool( void )
|
||||
{
|
||||
return host.imagepool;
|
||||
}
|
||||
|
||||
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
|
||||
{
|
||||
return &PFDesc[idx];
|
||||
@@ -246,16 +241,12 @@ static ref_api_t gEngfuncs =
|
||||
Con_DrawString,
|
||||
CL_DrawCenterPrint,
|
||||
|
||||
CL_GetLocalPlayer,
|
||||
CL_GetViewModel,
|
||||
CL_GetEntityByIndex,
|
||||
R_BeamGetEntity,
|
||||
CL_GetWaterEntity,
|
||||
CL_AddVisibleEntity,
|
||||
|
||||
Mod_SampleSizeForFace,
|
||||
Mod_BoxVisible,
|
||||
pfnGetWorld,
|
||||
Mod_PointInLeaf,
|
||||
Mod_CreatePolygonsForHull,
|
||||
|
||||
@@ -272,12 +263,9 @@ static ref_api_t gEngfuncs =
|
||||
|
||||
Mod_ForName,
|
||||
pfnMod_Extradata,
|
||||
CL_ModelHandle,
|
||||
|
||||
CL_EntitySetRemapColors,
|
||||
CL_GetRemapInfoForEntity,
|
||||
CL_AllocRemapInfo,
|
||||
CL_FreeRemapInfo,
|
||||
CL_UpdateRemapInfo,
|
||||
|
||||
CL_ExtraUpdate,
|
||||
Host_Error,
|
||||
@@ -285,9 +273,6 @@ static ref_api_t gEngfuncs =
|
||||
COM_RandomFloat,
|
||||
COM_RandomLong,
|
||||
pfnRefGetScreenFade,
|
||||
CL_TextMessageGet,
|
||||
pfnGetPredictedOrigin,
|
||||
pfnCL_GetPaletteColor,
|
||||
pfnCL_GetScreenInfo,
|
||||
pfnSetLocalLightLevel,
|
||||
Sys_CheckParm,
|
||||
@@ -337,7 +322,6 @@ static ref_api_t gEngfuncs =
|
||||
PM_CL_TraceLine,
|
||||
CL_VisTraceLine,
|
||||
CL_TraceLine,
|
||||
pfnGetMoveVars,
|
||||
|
||||
Image_AddCmdFlags,
|
||||
Image_SetForceFlags,
|
||||
@@ -349,7 +333,6 @@ static ref_api_t gEngfuncs =
|
||||
FS_CopyImage,
|
||||
FS_FreeImage,
|
||||
Image_SetMDLPointer,
|
||||
pfnImage_GetPool,
|
||||
pfnImage_GetPFDesc,
|
||||
|
||||
pfnDrawNormalTriangles,
|
||||
@@ -431,7 +414,7 @@ static qboolean R_LoadProgs( const char *name )
|
||||
// make local copy of engfuncs to prevent overwrite it with user dll
|
||||
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
|
||||
|
||||
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ))
|
||||
if( GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ) != REF_API_VERSION )
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -52,7 +52,7 @@ struct tests_stats_s tests_stats;
|
||||
#endif
|
||||
|
||||
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
|
||||
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" );
|
||||
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_FILTERABLE, "scale frame time" );
|
||||
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
|
||||
|
||||
static CVAR_DEFINE_AUTO( host_serverstate, "0", FCVAR_READ_ONLY, "displays current server state" );
|
||||
@@ -62,6 +62,7 @@ CVAR_DEFINE_AUTO( host_limitlocal, "0", 0, "apply cl_cmdrate and rate to loopbac
|
||||
CVAR_DEFINE( host_maxfps, "fps_max", "72", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "host fps upper limit" );
|
||||
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
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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__ )
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
||||
@@ -28,13 +28,21 @@ 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
|
||||
// 2. FS functions are removed, instead we have full fs_api_t
|
||||
// 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib
|
||||
// 4. R_StudioEstimateFrame now has time argument
|
||||
#define REF_API_VERSION 4
|
||||
// 5. Removed GetSomethingByIndex calls, renderers are supposed to cache pointer values
|
||||
// Removed previously unused calls
|
||||
// Simplified remapping calls
|
||||
// GetRefAPI is now expected to return REF_API_VERSION
|
||||
// 6. Removed timing from ref_globals_t.
|
||||
// Renderers are supposed to migrate to ref_client_t/ref_host_t using PARM_GET_CLIENT_PTR and PARM_GET_HOST_PTR
|
||||
// Removed functions to get internal engine structions. Use PARM_GET_*_PTR instead.
|
||||
#define REF_API_VERSION 6
|
||||
|
||||
|
||||
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
|
||||
@@ -90,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;
|
||||
@@ -116,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,
|
||||
@@ -247,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
|
||||
@@ -299,9 +324,6 @@ typedef struct ref_api_s
|
||||
void (*CL_DrawCenterPrint)( void );
|
||||
|
||||
// entity management
|
||||
struct cl_entity_s *(*GetLocalPlayer)( void );
|
||||
struct cl_entity_s *(*GetViewModel)( void );
|
||||
struct cl_entity_s *(*GetEntityByIndex)( int idx );
|
||||
struct cl_entity_s *(*R_BeamGetEntity)( int index );
|
||||
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
|
||||
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
|
||||
@@ -309,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 );
|
||||
|
||||
@@ -329,13 +350,10 @@ 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 *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle
|
||||
|
||||
// remap
|
||||
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
|
||||
void (*CL_AllocRemapInfo)( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
|
||||
void (*CL_FreeRemapInfo)( struct remap_info_s *info );
|
||||
void (*CL_UpdateRemapInfo)( cl_entity_t *entity, int topcolor, int bottomcolor );
|
||||
|
||||
// utils
|
||||
void (*CL_ExtraUpdate)( void );
|
||||
@@ -344,9 +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 );
|
||||
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
|
||||
void (*GetPredictedOrigin)( vec3_t v );
|
||||
color24 *(*CL_GetPaletteColor)(int color); // clgame.palette[color]
|
||||
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
|
||||
void (*SetLocalLightLevel)( int level ); // cl.local.light_level
|
||||
int (*Sys_CheckParm)( const char *flag );
|
||||
@@ -362,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
|
||||
@@ -407,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
|
||||
@@ -420,7 +434,6 @@ typedef struct ref_api_s
|
||||
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
|
||||
void (*FS_FreeImage)( rgbdata_t *pack );
|
||||
void (*Image_SetMDLPointer)( byte *p );
|
||||
poolhandle_t (*Image_GetPool)( void );
|
||||
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
|
||||
|
||||
// client exports
|
||||
@@ -449,6 +462,7 @@ typedef struct ref_interface_s
|
||||
void (*GL_InitExtensions)( void );
|
||||
void (*GL_ClearExtensions)( void );
|
||||
|
||||
// scene rendering
|
||||
void (*R_BeginFrame)( qboolean clearScene );
|
||||
void (*R_RenderScene)( void );
|
||||
void (*R_EndFrame)( void );
|
||||
@@ -463,7 +477,8 @@ typedef struct ref_interface_s
|
||||
|
||||
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
||||
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
|
||||
void (*R_ProcessEntData)( qboolean allocate );
|
||||
void (*R_ProcessEntData)( qboolean allocate, cl_entity_t *entities, unsigned int max_entities );
|
||||
void (*R_Flush)( unsigned int flush_flags );
|
||||
|
||||
// debug
|
||||
void (*R_ShowTextures)( void );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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" );
|
||||
}
|
||||
|
||||
@@ -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 ));
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -438,7 +438,10 @@ uint COM_HashKey( const char *string, uint hashSize )
|
||||
unsigned char i;
|
||||
|
||||
while(( i = *string++ ))
|
||||
{
|
||||
i = Q_tolower( i );
|
||||
hashKey = ( hashKey << 5 ) + hashKey + ( i & 0xDF );
|
||||
}
|
||||
|
||||
return hashKey & ( hashSize - 1 );
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
|
||||
skin.encode = DXT_ENCODE_DEFAULT;
|
||||
skin.numMips = 1;
|
||||
skin.buffer = data;
|
||||
skin.palette = (byte *)gEngfuncs.CL_GetPaletteColor( 0 );
|
||||
skin.palette = (byte *)tr.palette;
|
||||
skin.size = width * height;
|
||||
|
||||
if( !gEngfuncs.Image_CustomPalette() )
|
||||
@@ -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;
|
||||
@@ -1002,15 +1002,10 @@ R_AliasSetRemapColors
|
||||
|
||||
===============
|
||||
*/
|
||||
void R_AliasSetRemapColors( int newTop, int newBottom )
|
||||
static void R_AliasSetRemapColors( int newTop, int newBottom )
|
||||
{
|
||||
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
|
||||
|
||||
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
|
||||
{
|
||||
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
|
||||
if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
|
||||
m_fDoRemap = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1261,7 +1256,7 @@ static void R_AliasDrawAbsBBox( cl_entity_t *e, const vec3_t absmin, const vec3_
|
||||
int i;
|
||||
|
||||
// looks ugly, skip
|
||||
if( r_drawentities->value != 5 || e == gEngfuncs.GetViewModel() )
|
||||
if( r_drawentities->value != 5 || e == tr.viewent )
|
||||
return;
|
||||
|
||||
// compute a full bounding box
|
||||
@@ -1337,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;
|
||||
@@ -1386,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
|
||||
|
||||
@@ -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
|
||||
@@ -943,13 +939,13 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
|
||||
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex );
|
||||
model = CL_ModelHandle( pbeam->modelIndex );
|
||||
SetBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
|
||||
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;
|
||||
@@ -1146,7 +1142,7 @@ passed through this
|
||||
*/
|
||||
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
|
||||
{
|
||||
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
model_t *sprite = CL_ModelHandle( modelIndex );
|
||||
|
||||
if( !sprite ) 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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
@@ -295,19 +297,32 @@ const byte *GL_TextureData( unsigned int texnum )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void R_ProcessEntData( qboolean allocate )
|
||||
void R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned int max_entities )
|
||||
{
|
||||
if( !allocate )
|
||||
{
|
||||
tr.draw_list->num_solid_entities = 0;
|
||||
tr.draw_list->num_trans_entities = 0;
|
||||
tr.draw_list->num_beam_entities = 0;
|
||||
|
||||
tr.max_entities = 0;
|
||||
tr.entities = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr.max_entities = max_entities;
|
||||
tr.entities = entities;
|
||||
}
|
||||
|
||||
if( gEngfuncs.drawFuncs->R_ProcessEntData )
|
||||
gEngfuncs.drawFuncs->R_ProcessEntData( allocate );
|
||||
}
|
||||
|
||||
static void GAME_EXPORT R_Flush( unsigned int flags )
|
||||
{
|
||||
// stub
|
||||
}
|
||||
|
||||
qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y )
|
||||
{
|
||||
qboolean ret = true;
|
||||
@@ -372,6 +387,7 @@ ref_interface_t gReffuncs =
|
||||
R_AddEntity,
|
||||
CL_AddCustomBeam,
|
||||
R_ProcessEntData,
|
||||
R_Flush,
|
||||
|
||||
R_ShowTextures,
|
||||
|
||||
@@ -504,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;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ R_CullModel
|
||||
*/
|
||||
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
|
||||
{
|
||||
if( e == gEngfuncs.GetViewModel() )
|
||||
if( e == tr.viewent )
|
||||
{
|
||||
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
|
||||
return 1;
|
||||
@@ -77,7 +77,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
|
||||
return CULL_VISIBLE;
|
||||
|
||||
// world surfaces can be culled by vis frame too
|
||||
if( RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) && surf->visframe != tr.framecount )
|
||||
if( RI.currententity == CL_GetEntityByIndex( 0 ) && surf->visframe != tr.framecount )
|
||||
return CULL_VISFRAME;
|
||||
|
||||
// only static ents can be culled by frustum
|
||||
@@ -92,7 +92,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
|
||||
{
|
||||
vec3_t orthonormal;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) ) orthonormal[2] = surf->plane->normal[2];
|
||||
if( e == CL_GetEntityByIndex( 0 )) orthonormal[2] = surf->plane->normal[2];
|
||||
else Matrix4x4_VectorRotate( RI.objectMatrix, surf->plane->normal, orthonormal );
|
||||
dist = orthonormal[2];
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ GNU General Public License for more details.
|
||||
// REFTODO: rewrite in triapi
|
||||
void R_DrawWorldHull( void )
|
||||
{
|
||||
hull_model_t *hull = &WORLD->hull_models[0];
|
||||
hull_model_t *hull = &tr.world->hull_models[0];
|
||||
winding_t *poly;
|
||||
int i;
|
||||
|
||||
@@ -69,10 +69,10 @@ void R_DrawModelHull( void )
|
||||
return;
|
||||
|
||||
i = atoi( RI.currentmodel->name + 1 );
|
||||
if( i < 1 || i >= WORLD->num_hull_models )
|
||||
if( i < 1 || i >= tr.world->num_hull_models )
|
||||
return;
|
||||
|
||||
hull = &WORLD->hull_models[i];
|
||||
hull = &tr.world->hull_models[i];
|
||||
|
||||
pglPolygonOffset( 1.0f, 2.0 );
|
||||
pglEnable( GL_POLYGON_OFFSET_FILL );
|
||||
|
||||
@@ -750,15 +750,15 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
|
||||
|
||||
if( entityIndex > 0 )
|
||||
{
|
||||
ent = gEngfuncs.GetEntityByIndex( entityIndex );
|
||||
ent = CL_GetEntityByIndex( entityIndex );
|
||||
|
||||
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex );
|
||||
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
|
||||
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
else return;
|
||||
}
|
||||
else if( modelIndex > 0 )
|
||||
model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
else model = WORLDMODEL;
|
||||
model = CL_ModelHandle( modelIndex );
|
||||
else model = CL_ModelHandle( 1 );
|
||||
|
||||
if( !model ) return;
|
||||
|
||||
|
||||
@@ -1668,11 +1668,11 @@ int GL_LoadTextureArray( const char **names, int flags )
|
||||
else
|
||||
{
|
||||
// create new image
|
||||
pic = Mem_Malloc( gEngfuncs.Image_GetPool(), sizeof( rgbdata_t ));
|
||||
pic = Mem_Malloc( r_temppool, sizeof( rgbdata_t ));
|
||||
memcpy( pic, src, sizeof( rgbdata_t ));
|
||||
|
||||
// expand pic buffer for all layers
|
||||
pic->buffer = Mem_Malloc( gEngfuncs.Image_GetPool(), pic->size * numLayers );
|
||||
pic->buffer = Mem_Malloc( r_temppool, pic->size * numLayers );
|
||||
pic->depth = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
@@ -57,10 +58,6 @@ void VGL_ShimEndFrame( void );
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define WORLD (gEngfuncs.GetWorld())
|
||||
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
|
||||
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
|
||||
|
||||
// make mod_ref.h?
|
||||
#define LM_SAMPLE_SIZE 16
|
||||
|
||||
@@ -91,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
|
||||
@@ -256,7 +253,14 @@ typedef struct
|
||||
// cull info
|
||||
vec3_t modelorg; // relative to viewpoint
|
||||
|
||||
qboolean fCustomSkybox;
|
||||
// get from engine
|
||||
world_static_t *world;
|
||||
cl_entity_t *entities;
|
||||
movevars_t *movevars;
|
||||
color24 *palette;
|
||||
cl_entity_t *viewent;
|
||||
|
||||
uint max_entities;
|
||||
} gl_globals_t;
|
||||
|
||||
typedef struct
|
||||
@@ -395,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 );
|
||||
@@ -707,7 +712,6 @@ typedef struct
|
||||
qboolean in2DMode;
|
||||
} glstate_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
qboolean initialized; // OpenGL subsystem started
|
||||
@@ -720,10 +724,33 @@ 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 )
|
||||
|
||||
//
|
||||
// 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 )
|
||||
{
|
||||
if( unlikely( index < 0 || index >= gp_cl->nummodels ))
|
||||
return NULL;
|
||||
|
||||
return gp_cl->models[index];
|
||||
}
|
||||
|
||||
#define WORLDMODEL (gp_cl->models[1])
|
||||
|
||||
//
|
||||
// renderer cvars
|
||||
//
|
||||
@@ -754,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;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1284,6 +1286,12 @@ qboolean R_Init( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
// see R_ProcessEntData for tr.entities initialization
|
||||
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();
|
||||
R_InitImages();
|
||||
|
||||
@@ -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 );
|
||||
@@ -152,7 +152,7 @@ void R_PushDlights( void )
|
||||
|
||||
tr.dlightframecount = tr.framecount;
|
||||
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
if( RI.currententity )
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
|
||||
@@ -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 ))
|
||||
|
||||
@@ -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;
|
||||
@@ -324,7 +324,7 @@ R_GetFarClip
|
||||
static float R_GetFarClip( void )
|
||||
{
|
||||
if( WORLDMODEL && RI.drawWorld )
|
||||
return MOVEVARS->zmax * 1.73f;
|
||||
return tr.movevars->zmax * 1.73f;
|
||||
return 2048.0f;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -429,7 +429,7 @@ void R_RotateForEntity( cl_entity_t *e )
|
||||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ))
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -455,7 +455,7 @@ void R_TranslateForEntity( cl_entity_t *e )
|
||||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ))
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -669,7 +669,7 @@ static void R_CheckFog( void )
|
||||
// quake global fog
|
||||
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
|
||||
{
|
||||
if( !MOVEVARS->fog_settings )
|
||||
if( !tr.movevars->fog_settings )
|
||||
{
|
||||
if( pglIsEnabled( GL_FOG ))
|
||||
pglDisable( GL_FOG );
|
||||
@@ -678,10 +678,10 @@ static void R_CheckFog( void )
|
||||
}
|
||||
|
||||
// quake-style global fog
|
||||
RI.fogColor[0] = ((MOVEVARS->fog_settings & 0xFF000000) >> 24) / 255.0f;
|
||||
RI.fogColor[1] = ((MOVEVARS->fog_settings & 0xFF0000) >> 16) / 255.0f;
|
||||
RI.fogColor[2] = ((MOVEVARS->fog_settings & 0xFF00) >> 8) / 255.0f;
|
||||
RI.fogDensity = ((MOVEVARS->fog_settings & 0xFF) / 255.0f) * 0.01f;
|
||||
RI.fogColor[0] = ((tr.movevars->fog_settings & 0xFF000000) >> 24) / 255.0f;
|
||||
RI.fogColor[1] = ((tr.movevars->fog_settings & 0xFF0000) >> 16) / 255.0f;
|
||||
RI.fogColor[2] = ((tr.movevars->fog_settings & 0xFF00) >> 8) / 255.0f;
|
||||
RI.fogDensity = ((tr.movevars->fog_settings & 0xFF) / 255.0f) * 0.01f;
|
||||
RI.fogStart = RI.fogEnd = 0.0f;
|
||||
RI.fogColor[3] = 1.0f;
|
||||
RI.fogCustom = false;
|
||||
@@ -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;
|
||||
|
||||
@@ -146,7 +146,7 @@ void R_NewMap( void )
|
||||
tx->texturechain = NULL;
|
||||
}
|
||||
|
||||
R_SetupSky( MOVEVARS->skyName );
|
||||
R_SetupSky( tr.movevars->skyName );
|
||||
|
||||
GL_BuildLightmaps ();
|
||||
R_GenerateVBO();
|
||||
|
||||
@@ -49,7 +49,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
|
||||
@@ -85,15 +85,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
|
||||
VectorScale( RI.cull_vup, size, up );
|
||||
|
||||
p->color = bound( 0, p->color, 255 );
|
||||
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
|
||||
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;
|
||||
|
||||
pglColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
|
||||
gEngfuncs.LightToTexGamma( pColor->g ),
|
||||
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
|
||||
pglColor4ub( gEngfuncs.LightToTexGamma( color.r ),
|
||||
gEngfuncs.LightToTexGamma( color.g ),
|
||||
gEngfuncs.LightToTexGamma( color.b ), alpha );
|
||||
|
||||
pglTexCoord2f( 0.0f, 1.0f );
|
||||
pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] );
|
||||
@@ -188,13 +188,13 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
pglDepthMask( GL_FALSE );
|
||||
|
||||
gravity = frametime * MOVEVARS->gravity;
|
||||
gravity = frametime * tr.movevars->gravity;
|
||||
scale = 1.0 - (frametime * 0.9);
|
||||
if( scale < 0.0f ) scale = 0.0f;
|
||||
|
||||
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 );
|
||||
@@ -205,7 +205,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
{
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
|
||||
// Transform point into screen space
|
||||
TriWorldToScreen( start, screen );
|
||||
@@ -235,8 +235,8 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
|
||||
p->color = 0;
|
||||
}
|
||||
|
||||
pColor = &gTracerColors[p->color];
|
||||
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
|
||||
color = gTracerColors[p->color];
|
||||
pglColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
|
||||
pglBegin( GL_QUADS );
|
||||
pglTexCoord2f( 0.0f, 0.8f );
|
||||
@@ -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 )
|
||||
|
||||
1300
ref/gl/gl_rsurf.c
1300
ref/gl/gl_rsurf.c
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -826,7 +826,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
{
|
||||
cl_entity_t *parent;
|
||||
|
||||
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
|
||||
parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
if( parent && parent->model )
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
|
||||
{
|
||||
if( cl_righthand && cl_righthand->value > 0 )
|
||||
{
|
||||
if( e == gEngfuncs.GetViewModel() )
|
||||
if( e == tr.viewent )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ pfnGetViewEntity
|
||||
*/
|
||||
static cl_entity_t *pfnGetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
return tr.viewent;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -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;
|
||||
@@ -1851,7 +1851,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
|
||||
if( !p1 || !p2 || !p3 || !p4 )
|
||||
return;
|
||||
|
||||
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 ))
|
||||
if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
|
||||
{
|
||||
TriRenderMode( kRenderTransAlpha );
|
||||
TriColor4f( 0.0f, 0.0f, 0.0f, 1.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 )
|
||||
{
|
||||
@@ -2488,7 +2488,7 @@ static void R_StudioDrawAbsBBox( void )
|
||||
int i;
|
||||
|
||||
// looks ugly, skip
|
||||
if( RI.currententity == gEngfuncs.GetViewModel() )
|
||||
if( RI.currententity == tr.viewent )
|
||||
return;
|
||||
|
||||
if( !R_StudioComputeBBox( p ))
|
||||
@@ -2624,13 +2624,8 @@ R_StudioSetRemapColors
|
||||
*/
|
||||
static void R_StudioSetRemapColors( int newTop, int newBottom )
|
||||
{
|
||||
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
|
||||
|
||||
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
|
||||
{
|
||||
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
|
||||
if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
|
||||
m_fDoRemap = true;
|
||||
}
|
||||
}
|
||||
|
||||
void R_StudioResetPlayerModels( void )
|
||||
@@ -2761,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;
|
||||
@@ -2777,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 )
|
||||
@@ -3302,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 );
|
||||
@@ -3371,7 +3366,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3384,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;
|
||||
@@ -3414,7 +3409,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
if( pplayer->weaponmodel )
|
||||
{
|
||||
cl_entity_t saveent = *RI.currententity;
|
||||
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel );
|
||||
model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
|
||||
|
||||
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
|
||||
|
||||
@@ -3447,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
|
||||
@@ -3500,7 +3495,7 @@ static int R_StudioDrawModel( int flags )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3532,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 )
|
||||
{
|
||||
@@ -3565,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 = gEngfuncs.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 );
|
||||
}
|
||||
}
|
||||
@@ -3605,14 +3620,14 @@ void R_RunViewmodelEvents( void )
|
||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||
return;
|
||||
|
||||
RI.currententity = gEngfuncs.GetViewModel();
|
||||
RI.currententity = tr.viewent;
|
||||
|
||||
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
|
||||
return;
|
||||
|
||||
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;
|
||||
@@ -3627,7 +3642,7 @@ R_GatherPlayerLight
|
||||
*/
|
||||
void R_GatherPlayerLight( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
colorVec c;
|
||||
|
||||
tr.ignore_lightgamma = true;
|
||||
@@ -3643,7 +3658,7 @@ R_DrawViewModel
|
||||
*/
|
||||
void R_DrawViewModel( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
|
||||
R_GatherPlayerLight();
|
||||
|
||||
@@ -3761,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
|
||||
@@ -3828,7 +3843,9 @@ void Mod_StudioUnloadTextures( void *data )
|
||||
|
||||
static model_t *pfnModelHandle( int modelindex )
|
||||
{
|
||||
return gEngfuncs.pfnGetModelByIndex( modelindex );
|
||||
if( modelindex < 0 || modelindex >= MAX_MODELS )
|
||||
return NULL;
|
||||
return CL_ModelHandle( modelindex );
|
||||
}
|
||||
|
||||
static void *pfnMod_CacheCheck( struct cache_user_s *c )
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -956,13 +952,13 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
model_t *model;
|
||||
vec3_t delta;
|
||||
|
||||
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex );
|
||||
model = CL_ModelHandle( pbeam->modelIndex );
|
||||
SetBits( pbeam->flags, FBEAM_ISACTIVE );
|
||||
|
||||
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;
|
||||
@@ -1159,7 +1155,7 @@ passed through this
|
||||
*/
|
||||
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
|
||||
{
|
||||
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
model_t *sprite = CL_ModelHandle( modelIndex );
|
||||
|
||||
if( !sprite ) 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 );
|
||||
|
||||
@@ -949,8 +949,8 @@ void R_RenderWorld (void)
|
||||
c_drawnode=0;
|
||||
|
||||
// auto cycle the world frame for texture animation
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||
//RI.currententity->frame = (int)(gpGlobals->time*2);
|
||||
RI.currententity = CL_GetEntityByIndex(0);
|
||||
//RI.currententity->frame = (int)(gp_cl->time*2);
|
||||
|
||||
VectorCopy (RI.vieworg, tr.modelorg);
|
||||
RI.currentmodel = WORLDMODEL;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
@@ -273,9 +275,15 @@ void Mod_UnloadTextures( model_t *mod )
|
||||
}
|
||||
}
|
||||
|
||||
void GAME_EXPORT R_ProcessEntData( qboolean allocate )
|
||||
void GAME_EXPORT R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned int max_entities )
|
||||
{
|
||||
tr.entities = entities;
|
||||
tr.max_entities = max_entities;
|
||||
}
|
||||
|
||||
static void GAME_EXPORT R_Flush( unsigned int flags )
|
||||
{
|
||||
// stub
|
||||
}
|
||||
|
||||
// stubs
|
||||
@@ -425,6 +433,7 @@ ref_interface_t gReffuncs =
|
||||
R_AddEntity,
|
||||
CL_AddCustomBeam,
|
||||
R_ProcessEntData,
|
||||
R_Flush,
|
||||
|
||||
R_ShowTextures,
|
||||
|
||||
@@ -557,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;
|
||||
}
|
||||
|
||||
@@ -774,14 +774,14 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
|
||||
|
||||
if( entityIndex > 0 )
|
||||
{
|
||||
ent = gEngfuncs.GetEntityByIndex( entityIndex );
|
||||
ent = CL_GetEntityByIndex( entityIndex );
|
||||
|
||||
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex );
|
||||
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
|
||||
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
else return;
|
||||
}
|
||||
else if( modelIndex > 0 )
|
||||
model = gEngfuncs.pfnGetModelByIndex( modelIndex );
|
||||
model = CL_ModelHandle( modelIndex );
|
||||
else model = WORLDMODEL;
|
||||
|
||||
if( !model ) return;
|
||||
|
||||
@@ -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
|
||||
@@ -1118,7 +1118,7 @@ void D_SolidSurf (surf_t *s)
|
||||
{
|
||||
if( alphaspans )
|
||||
return;
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex(0); //r_worldentity;
|
||||
RI.currententity = CL_GetEntityByIndex(0); //r_worldentity;
|
||||
tr.modelviewIdentity = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
@@ -155,7 +155,7 @@ void R_PushDlights( void )
|
||||
|
||||
tr.dlightframecount = tr.framecount;
|
||||
|
||||
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
|
||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||
if( RI.currententity )
|
||||
RI.currentmodel = RI.currententity->model;
|
||||
|
||||
@@ -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 ))
|
||||
|
||||
@@ -41,14 +41,9 @@ typedef int fixed16_t;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define WORLD (gEngfuncs.GetWorld())
|
||||
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
|
||||
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
|
||||
|
||||
// make mod_ref.h?
|
||||
#define LM_SAMPLE_SIZE 16
|
||||
|
||||
|
||||
extern poolhandle_t r_temppool;
|
||||
|
||||
#define BLOCK_SIZE tr.block_size // lightmap blocksize
|
||||
@@ -83,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
|
||||
@@ -294,10 +289,17 @@ typedef struct
|
||||
// cull info
|
||||
vec3_t modelorg; // relative to viewpoint
|
||||
|
||||
qboolean fCustomSkybox;
|
||||
int sample_size;
|
||||
uint sample_bits;
|
||||
qboolean map_unload;
|
||||
|
||||
// get from engine
|
||||
cl_entity_t *entities;
|
||||
movevars_t *movevars;
|
||||
color24 *palette;
|
||||
cl_entity_t *viewent;
|
||||
|
||||
uint max_entities;
|
||||
} gl_globals_t;
|
||||
|
||||
typedef struct
|
||||
@@ -474,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 );
|
||||
@@ -674,9 +677,32 @@ void TriBrightness( float brightness );
|
||||
|
||||
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 )
|
||||
{
|
||||
if( unlikely( index < 0 || index >= gp_cl->nummodels ))
|
||||
return NULL;
|
||||
|
||||
return gp_cl->models[index];
|
||||
}
|
||||
|
||||
#define WORLDMODEL (gp_cl->models[1])
|
||||
|
||||
// todo: gl_cull.c
|
||||
#define R_CullModel(...) 0
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -425,7 +425,7 @@ R_GetFarClip
|
||||
static float R_GetFarClip( void )
|
||||
{
|
||||
if( WORLDMODEL && RI.drawWorld )
|
||||
return MOVEVARS->zmax * 1.73f;
|
||||
return tr.movevars->zmax * 1.73f;
|
||||
return 2048.0f;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -539,7 +539,7 @@ void R_RotateForEntity( cl_entity_t *e )
|
||||
#if 0
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ) )
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -567,7 +567,7 @@ void R_TranslateForEntity( cl_entity_t *e )
|
||||
#if 0
|
||||
float scale = 1.0f;
|
||||
|
||||
if( e == gEngfuncs.GetEntityByIndex( 0 ) )
|
||||
if( e == CL_GetEntityByIndex( 0 ) )
|
||||
{
|
||||
R_LoadIdentity();
|
||||
return;
|
||||
@@ -784,7 +784,7 @@ void R_DrawEntitiesOnList( void )
|
||||
//d_aflatcolor = 0;
|
||||
tr.blend = 1.0f;
|
||||
// GL_CheckForErrors();
|
||||
//RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||
//RI.currententity = CL_GetEntityByIndex(0);
|
||||
d_pdrawspans = R_PolysetFillSpans8;
|
||||
GL_SetRenderMode(kRenderNormal);
|
||||
// first draw solid entities
|
||||
@@ -815,7 +815,7 @@ void R_DrawEntitiesOnList( void )
|
||||
extern void (*d_pdrawspans)(void *);
|
||||
extern void R_PolysetFillSpans8 ( void * );
|
||||
d_pdrawspans = R_PolysetFillSpans8;
|
||||
//RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||
//RI.currententity = CL_GetEntityByIndex(0);
|
||||
R_AliasSetUpTransform();
|
||||
image_t *image = R_GetTexture(GL_LoadTexture("gfx/env/desertbk", NULL, 0, 0));
|
||||
r_affinetridesc.pskin = image->pixels[0];
|
||||
@@ -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
|
||||
@@ -1938,6 +1938,11 @@ qboolean GAME_EXPORT R_Init( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
// see R_ProcessEntData for tr.entities initialization
|
||||
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 );
|
||||
|
||||
R_InitImages();
|
||||
@@ -1979,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( ))
|
||||
@@ -2027,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;
|
||||
|
||||
@@ -49,7 +49,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t right, up;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
int alpha;
|
||||
float size;
|
||||
|
||||
@@ -84,17 +84,17 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
||||
VectorScale( RI.cull_vup, size, up );
|
||||
|
||||
p->color = bound( 0, p->color, 255 );
|
||||
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
|
||||
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;
|
||||
|
||||
//TriColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
|
||||
// gEngfuncs.LightToTexGamma( pColor->g ),
|
||||
// gEngfuncs.LightToTexGamma( pColor->b ), alpha );
|
||||
//TriColor4ub( gEngfuncs.LightToTexGamma( color.r ),
|
||||
// gEngfuncs.LightToTexGamma( color.g ),
|
||||
// gEngfuncs.LightToTexGamma( color.b ), alpha );
|
||||
//TriBrightness( alpha / 255.0f );
|
||||
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f );
|
||||
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
TriTexCoord2f( 0.0f, 1.0f );
|
||||
@@ -194,13 +194,13 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
//pglDisable( GL_ALPHA_TEST );
|
||||
//pglDepthMask( GL_FALSE );
|
||||
|
||||
gravity = frametime * MOVEVARS->gravity;
|
||||
gravity = frametime * tr.movevars->gravity;
|
||||
scale = 1.0 - (frametime * 0.9);
|
||||
if( scale < 0.0f ) scale = 0.0f;
|
||||
|
||||
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 );
|
||||
@@ -211,7 +211,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
{
|
||||
vec3_t verts[4], tmp2;
|
||||
vec3_t tmp, normal;
|
||||
color24 *pColor;
|
||||
color24 color;
|
||||
short alpha = p->packedColor;
|
||||
|
||||
// Transform point into screen space
|
||||
@@ -242,9 +242,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
|
||||
p->color = 0;
|
||||
}
|
||||
|
||||
pColor = &gTracerColors[p->color];
|
||||
//TriColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
|
||||
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f );
|
||||
color = gTracerColors[p->color];
|
||||
//TriColor4ub( color.r, color.g, color.b, p->packedColor );
|
||||
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
|
||||
|
||||
|
||||
TriBegin( TRI_QUADS );
|
||||
@@ -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 )
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -895,7 +895,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
||||
{
|
||||
cl_entity_t *parent;
|
||||
|
||||
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
|
||||
parent = CL_GetEntityByIndex( e->curstate.aiment );
|
||||
|
||||
if( parent && parent->model )
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
|
||||
{
|
||||
if( cl_righthand && cl_righthand->value > 0 )
|
||||
{
|
||||
if( e == gEngfuncs.GetViewModel() )
|
||||
if( e == tr.viewent )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ pfnGetViewEntity
|
||||
*/
|
||||
static cl_entity_t *pfnGetViewEntity( void )
|
||||
{
|
||||
return gEngfuncs.GetViewModel();
|
||||
return tr.viewent;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -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;
|
||||
@@ -1846,7 +1846,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
|
||||
if( !p1 || !p2 || !p3 || !p4 )
|
||||
return;
|
||||
|
||||
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 ))
|
||||
if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
|
||||
{
|
||||
TriRenderMode( kRenderTransAlpha );
|
||||
_TriColor4f( 0.0f, 0.0f, 0.0f, 1.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 )
|
||||
{
|
||||
@@ -2246,7 +2246,7 @@ static void R_StudioDrawAbsBBox( void )
|
||||
int i;
|
||||
|
||||
// looks ugly, skip
|
||||
if( RI.currententity == gEngfuncs.GetViewModel() )
|
||||
if( RI.currententity == tr.viewent )
|
||||
return;
|
||||
|
||||
if( !R_StudioComputeBBox( p ))
|
||||
@@ -2384,13 +2384,8 @@ R_StudioSetRemapColors
|
||||
*/
|
||||
static void R_StudioSetRemapColors( int newTop, int newBottom )
|
||||
{
|
||||
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
|
||||
|
||||
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
|
||||
{
|
||||
gEngfuncs.CL_UpdateRemapInfo( RI.currententity, newTop, newBottom );
|
||||
if( gEngfuncs.CL_EntitySetRemapColors( RI.currententity, RI.currentmodel, newTop, newBottom ))
|
||||
m_fDoRemap = true;
|
||||
}
|
||||
}
|
||||
|
||||
void R_StudioResetPlayerModels( void )
|
||||
@@ -2521,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;
|
||||
@@ -2537,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 )
|
||||
@@ -3068,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 );
|
||||
@@ -3137,7 +3132,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3150,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;
|
||||
@@ -3180,7 +3175,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
||||
if( pplayer->weaponmodel )
|
||||
{
|
||||
cl_entity_t saveent = *RI.currententity;
|
||||
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel );
|
||||
model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
|
||||
|
||||
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
|
||||
|
||||
@@ -3213,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
|
||||
@@ -3266,7 +3261,7 @@ static int R_StudioDrawModel( int flags )
|
||||
// copy attachments into global entity array
|
||||
if( RI.currententity->index > 0 )
|
||||
{
|
||||
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
|
||||
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
|
||||
}
|
||||
}
|
||||
@@ -3298,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 )
|
||||
{
|
||||
@@ -3331,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 = gEngfuncs.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
|
||||
@@ -3371,14 +3387,14 @@ void R_RunViewmodelEvents( void )
|
||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||
return;
|
||||
|
||||
RI.currententity = gEngfuncs.GetViewModel();
|
||||
RI.currententity = tr.viewent;
|
||||
|
||||
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
|
||||
return;
|
||||
|
||||
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;
|
||||
@@ -3393,7 +3409,7 @@ R_GatherPlayerLight
|
||||
*/
|
||||
void R_GatherPlayerLight( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
colorVec c;
|
||||
|
||||
tr.ignore_lightgamma = true;
|
||||
@@ -3409,7 +3425,7 @@ R_DrawViewModel
|
||||
*/
|
||||
void R_DrawViewModel( void )
|
||||
{
|
||||
cl_entity_t *view = gEngfuncs.GetViewModel();
|
||||
cl_entity_t *view = tr.viewent;
|
||||
|
||||
R_GatherPlayerLight();
|
||||
|
||||
@@ -3543,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
|
||||
@@ -3610,7 +3626,7 @@ void Mod_StudioUnloadTextures( void *data )
|
||||
|
||||
static model_t *pfnModelHandle( int modelindex )
|
||||
{
|
||||
return gEngfuncs.pfnGetModelByIndex( modelindex );
|
||||
return CL_ModelHandle( modelindex );
|
||||
}
|
||||
|
||||
static void *pfnMod_CacheCheck( struct cache_user_s *c )
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
20
wscript
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user