13 Jul 2017

This commit is contained in:
g-cont 2017-07-13 00:00:00 +03:00 committed by Alibek Omarov
parent 320523bb7d
commit 9a33012580
25 changed files with 454 additions and 196 deletions

View File

@ -413,43 +413,24 @@ Alias models are position independent, so the cache manager can move them.
#define MAXALIASTRIS 4096
#define MAX_SKINS 32
// This mirrors trivert_t in trilib.h, is present so Quake knows how to
// load this data
typedef struct
{
byte v[3];
byte lightnormalindex;
} mtrivertex_t;
} trivertex_t;
typedef struct
{
int firstpose;
int numposes;
trivertex_t bboxmin;
trivertex_t bboxmax;
float interval;
mtrivertex_t bboxmin;
mtrivertex_t bboxmax;
int frame;
char name[16];
} maliasframedesc_t;
typedef struct
{
mtrivertex_t bboxmin;
mtrivertex_t bboxmax;
int frame;
} maliasgroupdesc_t;
typedef struct
{
int numframes;
int intervals;
maliasgroupdesc_t frames[1];
} maliasgroup_t;
typedef struct mtriangle_s
{
int facesfront;
int vertindex[3];
} mtriangle_t;
typedef struct
{
int ident;
@ -470,9 +451,10 @@ typedef struct
int numposes;
int poseverts;
mtrivertex_t *posedata; // numposes * poseverts trivert_t
trivertex_t *posedata; // numposes * poseverts trivert_t
int *commands; // gl command list with embedded s/t
int gl_texturenum[MAX_SKINS][4];
unsigned short gl_texturenum[MAX_SKINS][4];
unsigned short fb_texturenum[MAX_SKINS][4];
int *texels[MAX_SKINS]; // only for player skins
maliasframedesc_t frames[1]; // variable sized
} aliashdr_t;

View File

@ -18,10 +18,10 @@ GNU General Public License for more details.
// list of engine features that can be enabled through callback SV_CheckFeatures
#define ENGINE_WRITE_LARGE_COORD (1<<0) // replace standard message WRITE_COORD with big message for support more than 8192 units in world
// reserved
#define ENGINE_QUAKE_COMPATIBLE (1<<1) // make engine compatible with quake (flags and effects)
#define ENGINE_LOAD_DELUXEDATA (1<<2) // loading deluxemap for map (if present)
#define ENGINE_TRANSFORM_TRACE_AABB (1<<3) // transform trace bbox into local space of rotating bmodels
#define ENGINE_LARGE_LIGHTMAPS (1<<4) // change lightmap sizes from 128x128 to 256x256
#define ENGINE_LARGE_LIGHTMAPS (1<<4) // change lightmap sizes from 128x128 to 1024x1024
#define ENGINE_COMPENSATE_QUAKE_BUG (1<<5) // compensate stupid quake bug (inverse pitch) for mods where this bug is fixed
#define ENGINE_DISABLE_HDTEXTURES (1<<6) // disable support of HD-textures in case custom renderer have separate way to load them
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine

View File

@ -29,6 +29,16 @@ Alias models are position independent, so the cache manager can move them.
#define ALIAS_VERSION 6
// client-side model flags
#define ALIAS_ROCKET 0x0001 // leave a trail
#define ALIAS_GRENADE 0x0002 // leave a trail
#define ALIAS_GIB 0x0004 // leave a trail
#define ALIAS_ROTATE 0x0008 // rotate (bonus items)
#define ALIAS_TRACER 0x0010 // green split trail
#define ALIAS_ZOMGIB 0x0020 // small blood trail
#define ALIAS_TRACER2 0x0040 // orange split trail + rotate
#define ALIAS_TRACER3 0x0080 // purple trail
// must match definition in sprite.h
#ifndef SYNCTYPE_T
#define SYNCTYPE_T
@ -87,26 +97,18 @@ typedef struct dtriangle_s
#define DT_FACES_FRONT 0x0010
#define ALIAS_ONSEAM 0x0020
// This mirrors trivert_t in trilib.h, is present so Quake knows how to
// load this data
typedef struct
{
byte v[3];
byte lightnormalindex;
} dtrivertex_t;
typedef struct
{
dtrivertex_t bboxmin; // lightnormal isn't used
dtrivertex_t bboxmax; // lightnormal isn't used
trivertex_t bboxmin; // lightnormal isn't used
trivertex_t bboxmax; // lightnormal isn't used
char name[16]; // frame name from grabbing
} daliasframe_t;
typedef struct
{
int numframes;
dtrivertex_t bboxmin; // lightnormal isn't used
dtrivertex_t bboxmax; // lightnormal isn't used
trivertex_t bboxmin; // lightnormal isn't used
trivertex_t bboxmax; // lightnormal isn't used
} daliasgroup_t;
typedef struct

View File

@ -123,6 +123,21 @@ qboolean CL_CompareTimestamps( float t1, float t2 )
return (( iTime1 - iTime2 ) <= 1 );
}
/*
==================
CL_EntityIgnoreLerp
some ents will be ignore lerping
==================
*/
qboolean CL_EntityIgnoreLerp( cl_entity_t *e )
{
if( e->model && e->model->type == mod_alias )
return false;
return (e->curstate.movetype == MOVETYPE_NONE) ? true : false;
}
/*
==================
CL_EntityCustomLerp
@ -190,12 +205,14 @@ CL_UpdateLatchedVars
*/
void CL_UpdateLatchedVars( cl_entity_t *ent )
{
if( !ent->model || ent->model->type != mod_studio )
return; // below fields used only for studio interpolation
if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio ))
return; // below fields used only for alias and studio interpolation
VectorCopy( ent->prevstate.origin, ent->latched.prevorigin );
VectorCopy( ent->prevstate.angles, ent->latched.prevangles );
if( ent->model->type == mod_alias )
ent->latched.prevframe = ent->prevstate.frame;
ent->latched.prevanimtime = ent->prevstate.animtime;
if( ent->curstate.sequence != ent->prevstate.sequence )
@ -217,8 +234,8 @@ CL_ResetLatchedVars
*/
void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset )
{
if( !ent->model || ent->model->type != mod_studio )
return; // below fields used only for studio interpolation
if( !ent->model || ( ent->model->type != mod_alias && ent->model->type != mod_studio ))
return; // below fields used only for alias and studio interpolation
if( full_reset )
{
@ -226,7 +243,10 @@ void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset )
memcpy( ent->latched.prevblending, ent->curstate.blending, sizeof( ent->latched.prevblending ));
ent->latched.sequencetime = ent->curstate.animtime;
memcpy( ent->latched.prevcontroller, ent->curstate.controller, sizeof( ent->latched.prevcontroller ));
ent->latched.prevframe = CL_GetStudioEstimatedFrame( ent );
if( ent->model->type == mod_studio )
ent->latched.prevframe = CL_GetStudioEstimatedFrame( ent );
else if( ent->model->type == mod_alias )
ent->latched.prevframe = ent->curstate.frame;
ent->prevstate = ent->curstate;
}
@ -262,7 +282,7 @@ void CL_ProcessEntityUpdate( cl_entity_t *ent )
if( CL_EntityCustomLerp( ent ) && !parametric )
ent->curstate.animtime = ent->curstate.msg_time;
if( !CL_CompareTimestamps( ent->curstate.animtime, ent->prevstate.animtime ) || ent->curstate.movetype == MOVETYPE_NONE )
if( !CL_CompareTimestamps( ent->curstate.animtime, ent->prevstate.animtime ) || CL_EntityIgnoreLerp( ent ))
{
CL_UpdateLatchedVars( ent );
CL_UpdatePositions( ent );
@ -679,7 +699,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
CL_WriteDemoJumpTime();
// sentinel count. save it for debug checking
count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1;
count = ( MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1 ) & 1023;
newframe = &cl.frames[cl.parsecountmod];
// allocate parse entities
@ -912,8 +932,8 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType )
// apply client-side effects
CL_AddEntityEffects( ent );
// studiomodel efefcts only
CL_AddStudioEffects( ent );
// alias & studiomodel efefcts
CL_AddModelEffects( ent );
}
return true;

View File

@ -1335,6 +1335,8 @@ pfnSPR_Draw
*/
static void pfnSPR_Draw( int frame, int x, int y, const wrect_t *prc )
{
pglDisable( GL_BLEND );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}

View File

@ -2198,6 +2198,7 @@ void CL_InitLocal( void )
Cmd_AddCommand ("stop", CL_Stop_f, "stop playing or recording a demo" );
Cmd_AddCommand ("info", NULL, "collect info about local servers with specified protocol" );
Cmd_AddCommand ("escape", CL_Escape_f, "escape from game to menu" );
Cmd_AddCommand ("togglemenu", CL_Escape_f, "toggle between game and menu" );
Cmd_AddCommand ("pointfile", CL_ReadPointFile_f, "show leaks on a map (if present of course)" );
Cmd_AddCommand ("linefile", CL_ReadLineFile_f, "show leaks on a map (if present of course)" );
Cmd_AddCommand ("fullserverinfo", CL_FullServerinfo_f, "sent by server when serverinfo changes" );

View File

@ -1321,6 +1321,11 @@ void CL_PredictMovement( qboolean repredicting )
if( !CL_IsPredicted( ))
{
// keep onground actual
if( FBitSet( frame->clientdata.flags, FL_ONGROUND ))
cl.local.onground = frame->playerstate[cl.playernum].onground;
else cl.local.onground = -1;
cl.local.viewmodel = to->client.viewmodel;
cl.local.repredicting = false;
cl.local.moving = false;

View File

@ -2689,7 +2689,7 @@ void CL_AddEntityEffects( cl_entity_t *ent )
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
{
if( ent->player )
if( ent->player && !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
{
CL_UpdateFlashlight( ent );
}
@ -2728,17 +2728,24 @@ void CL_AddEntityEffects( cl_entity_t *ent )
/*
================
CL_AddStudioEffects
CL_AddModelEffects
these effects will be enable by flag in model header
================
*/
void CL_AddStudioEffects( cl_entity_t *ent )
void CL_AddModelEffects( cl_entity_t *ent )
{
vec3_t oldorigin;
if( !ent->model || ent->model->type != mod_studio )
return;
if( !ent->model ) return;
switch( ent->model->type )
{
case mod_alias:
case mod_studio:
break;
default: return;
}
VectorCopy( ent->latched.prevorigin, oldorigin );

View File

@ -81,7 +81,7 @@ 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_AddStudioEffects( cl_entity_t *ent );
void CL_AddModelEffects( cl_entity_t *ent );
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
void CL_DecalRemoveAll( int textureIndex );
int CL_DecalIndexFromName( const char *name );

View File

@ -89,11 +89,16 @@ void V_SetupViewModel( void )
view->curstate.colormap = (info->topcolor & 0xFFFF)|((info->bottomcolor << 8) & 0xFFFF);
view->curstate.number = cl.playernum + 1;
view->index = cl.playernum + 1;
view->curstate.frame = 0.0f;
view->model = Mod_Handle( cl.local.viewmodel );
view->curstate.modelindex = cl.local.viewmodel;
view->curstate.animtime = cl.local.weaponstarttime;
view->curstate.sequence = cl.local.weaponsequence;
// alias models has another animation methods
if( view->model && view->model->type == mod_studio )
{
view->curstate.animtime = cl.local.weaponstarttime;
view->curstate.frame = 0.0f;
}
}
/*

View File

@ -31,10 +31,12 @@ typedef struct
double time;
double frametime;
int framecount; // alias framecount
qboolean interpolate;
float ambientlight;
float shadelight;
vec3_t lightvec; // averaging light direction
vec3_t lightvec_local; // light direction in local space
vec3_t lightspot; // shadow spot
vec3_t lightcolor; // averaging lightcolor
int oldpose; // shadow used
@ -52,8 +54,8 @@ ALIAS MODEL DISPLAY LIST GENERATION
=================================================================
*/
static aliashdr_t *m_pAliasHeader;
static mtrivertex_t *g_poseverts[MAXALIASFRAMES];
static mtriangle_t g_triangles[MAXALIASTRIS];
static trivertex_t *g_poseverts[MAXALIASFRAMES];
static dtriangle_t g_triangles[MAXALIASTRIS];
static stvert_t g_stverts[MAXALIASVERTS];
static qboolean g_used[8192];
@ -71,12 +73,21 @@ static int g_numcommands;
static int g_vertexorder[8192];
static int g_numorder;
static int g_allverts, g_alltris;
static int g_stripverts[128];
static int g_striptris[128];
static int g_stripcount;
/*
====================
R_StudioInit
====================
*/
void R_AliasInit( void )
{
g_alias.interpolate = true;
}
/*
================
StripLength
@ -85,7 +96,7 @@ StripLength
static int StripLength( int starttri, int startv )
{
int m1, m2, j, k;
mtriangle_t *last, *check;
dtriangle_t *last, *check;
g_used[starttri] = 2;
@ -151,7 +162,7 @@ FanLength
static int FanLength( int starttri, int startv )
{
int m1, m2, j, k;
mtriangle_t *last, *check;
dtriangle_t *last, *check;
g_used[starttri] = 2;
@ -290,9 +301,6 @@ void BuildTris( void )
g_commands[g_numcommands++] = 0; // end of list marker
MsgDev( D_REPORT, "%3i tri %3i vert %3i cmd\n", m_pAliasHeader->numtris, g_numorder, g_numcommands );
g_alltris += m_pAliasHeader->numtris;
g_allverts += g_numorder;
}
/*
@ -300,13 +308,11 @@ void BuildTris( void )
GL_MakeAliasModelDisplayLists
================
*/
void GL_MakeAliasModelDisplayLists( model_t *m, aliashdr_t *hdr )
void GL_MakeAliasModelDisplayLists( model_t *m )
{
mtrivertex_t *verts;
trivertex_t *verts;
int i, j;
m_pAliasHeader = hdr; // (aliashdr_t *)Mod_AliasExtradata (m);
BuildTris( );
// save the data out
@ -315,7 +321,8 @@ void GL_MakeAliasModelDisplayLists( model_t *m, aliashdr_t *hdr )
m_pAliasHeader->commands = Mem_Alloc( m->mempool, g_numcommands * 4 );
memcpy( m_pAliasHeader->commands, g_commands, g_numcommands * 4 );
m_pAliasHeader->posedata = verts = Mem_Alloc( m->mempool, m_pAliasHeader->numposes * m_pAliasHeader->poseverts * sizeof( mtrivertex_t ));
m_pAliasHeader->posedata = Mem_Alloc( m->mempool, m_pAliasHeader->numposes * m_pAliasHeader->poseverts * sizeof( trivertex_t ));
verts = m_pAliasHeader->posedata;
for( i = 0; i < m_pAliasHeader->numposes; i++ )
{
@ -338,8 +345,8 @@ Mod_LoadAliasFrame
*/
void *Mod_LoadAliasFrame( void *pin, maliasframedesc_t *frame )
{
dtrivertex_t *pinframe;
daliasframe_t *pdaliasframe;
trivertex_t *pinframe;
int i;
pdaliasframe = (daliasframe_t *)pin;
@ -354,12 +361,11 @@ void *Mod_LoadAliasFrame( void *pin, maliasframedesc_t *frame )
frame->bboxmax.v[i] = pdaliasframe->bboxmax.v[i];
}
pinframe = (dtrivertex_t *)(pdaliasframe + 1);
g_poseverts[g_posenum] = (mtrivertex_t *)pinframe;
g_posenum++;
pinframe = (trivertex_t *)(pdaliasframe + 1);
g_poseverts[g_posenum] = (trivertex_t *)pinframe;
pinframe += m_pAliasHeader->numverts;
g_posenum++;
return (void *)pinframe;
}
@ -390,16 +396,16 @@ void *Mod_LoadAliasGroup( void *pin, maliasframedesc_t *frame )
pin_intervals = (daliasinterval_t *)(pingroup + 1);
// all the intervals are always equal 0.1 so we don't care about them
frame->interval = pin_intervals->interval;
pin_intervals += numframes;
ptemp = (void *)pin_intervals;
for( i = 0; i < numframes; i++ )
{
g_poseverts[g_posenum] = (mtrivertex_t *)((daliasframe_t *)ptemp + 1);
g_poseverts[g_posenum] = (trivertex_t *)((daliasframe_t *)ptemp + 1);
ptemp = (trivertex_t *)((daliasframe_t *)ptemp + 1) + m_pAliasHeader->numverts;
g_posenum++;
ptemp = ((daliasframe_t *)ptemp + 1) + m_pAliasHeader->numverts;
}
return ptemp;
@ -477,18 +483,28 @@ Mod_CreateSkinData
rgbdata_t *Mod_CreateSkinData( byte *data, int width, int height )
{
static rgbdata_t skin;
int i;
skin.width = width;
skin.height = height;
skin.depth = 1;
skin.type = PF_INDEXED_24;
SetBits( skin.flags, IMAGE_HAS_COLOR );
skin.flags = IMAGE_HAS_COLOR;
skin.encode = DXT_ENCODE_DEFAULT;
skin.numMips = 1;
skin.buffer = data;
skin.palette = (byte *)&clgame.palette;
skin.size = width * height;
for( i = 0; i < skin.width * skin.height; i++ )
{
if( data[i] > 224 && data[i] != 255 )
{
SetBits( skin.flags, IMAGE_HAS_LUMA );
break;
}
}
// make an copy
return FS_CopyImage( &skin );
}
@ -500,10 +516,10 @@ Mod_LoadAllSkins
*/
void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
{
char name[32];
daliasskingroup_t *pinskingroup;
daliasskininterval_t *pinskinintervals;
int size, groupskins;
string name, lumaname;
daliasskingroup_t *pinskingroup;
int i, j, k;
byte *skin;
rgbdata_t *pic;
@ -526,6 +542,7 @@ void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
memcpy( m_pAliasHeader->texels[i], (byte *)(pskintype + 1), size );
Q_snprintf( name, sizeof( name ), "%s:frame%i", loadmodel->name, i );
Q_snprintf( lumaname, sizeof( lumaname ), "%s:luma%i", loadmodel->name, i );
pic = Mod_CreateSkinData( (byte *)(pskintype + 1), m_pAliasHeader->skinwidth, m_pAliasHeader->skinheight );
m_pAliasHeader->gl_texturenum[i][0] =
@ -533,6 +550,17 @@ void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
m_pAliasHeader->gl_texturenum[i][2] =
m_pAliasHeader->gl_texturenum[i][3] = GL_LoadTextureInternal( name, pic, 0, false );
FS_FreeImage( pic );
if( R_GetTexture( m_pAliasHeader->gl_texturenum[i][0] )->flags & TF_HAS_LUMA )
{
pic = Mod_CreateSkinData( (byte *)(pskintype + 1), m_pAliasHeader->skinwidth, m_pAliasHeader->skinheight );
m_pAliasHeader->fb_texturenum[i][0] =
m_pAliasHeader->fb_texturenum[i][1] =
m_pAliasHeader->fb_texturenum[i][2] =
m_pAliasHeader->fb_texturenum[i][3] = GL_LoadTextureInternal( lumaname, pic, TF_MAKELUMA, false );
FS_FreeImage( pic );
}
pskintype = (daliasskintype_t *)((byte *)(pskintype + 1) + size);
}
else
@ -555,12 +583,23 @@ void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
Q_snprintf( name, sizeof( name ), "%s_%i_%i", loadmodel->name, i, j );
pic = Mod_CreateSkinData( (byte *)(pskintype), m_pAliasHeader->skinwidth, m_pAliasHeader->skinheight );
m_pAliasHeader->gl_texturenum[i][j & 3] = GL_LoadTextureInternal( name, pic, 0, false );
pskintype = (daliasskintype_t *)((byte *)(pskintype) + size);
FS_FreeImage( pic );
if( R_GetTexture( m_pAliasHeader->gl_texturenum[i][j & 3] )->flags & TF_HAS_LUMA )
{
Q_snprintf( lumaname, sizeof( lumaname ), "%s_%i_%i_luma", loadmodel->name, i, j );
pic = Mod_CreateSkinData((byte *)(pskintype), m_pAliasHeader->skinwidth, m_pAliasHeader->skinheight );
m_pAliasHeader->fb_texturenum[i][j & 3] = GL_LoadTextureInternal( lumaname, pic, TF_MAKELUMA, false );
FS_FreeImage( pic );
}
pskintype = (daliasskintype_t *)((byte *)(pskintype) + size);
}
for( k = j; j < 4; j++ )
{
m_pAliasHeader->gl_texturenum[i][j & 3] = m_pAliasHeader->gl_texturenum[i][j - k];
m_pAliasHeader->fb_texturenum[i][j & 3] = m_pAliasHeader->fb_texturenum[i][j - k];
}
}
}
@ -573,25 +612,25 @@ void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
Mod_CalcAliasBounds
=================
*/
void Mod_CalcAliasBounds( aliashdr_t *a )
void Mod_CalcAliasBounds( model_t *mod )
{
int i, j, k;
float radius;
float dist;
vec3_t v;
ClearBounds( loadmodel->mins, loadmodel->maxs );
ClearBounds( mod->mins, mod->maxs );
radius = 0.0f;
// process verts
for( i = 0; i < a->numposes; i++ )
for( i = 0; i < m_pAliasHeader->numposes; i++ )
{
for( j = 0; j < a->numverts; j++ )
for( j = 0; j < m_pAliasHeader->numverts; j++ )
{
for( k = 0; k < 3; k++ )
v[k] = g_poseverts[i][j].v[k] * m_pAliasHeader->scale[k] + m_pAliasHeader->scale_origin[k];
AddPointToBounds( v, loadmodel->mins, loadmodel->maxs );
AddPointToBounds( v, mod->mins, mod->maxs );
dist = DotProduct( v, v );
if( radius < dist )
@ -599,7 +638,7 @@ void Mod_CalcAliasBounds( aliashdr_t *a )
}
}
loadmodel->radius = sqrt( radius );
mod->radius = sqrt( radius );
}
/*
@ -631,7 +670,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
// allocate space for a working header, plus all the data except the frames,
// skin and group info
size = sizeof( aliashdr_t ) + (pinmodel->numframes - 1) * sizeof( m_pAliasHeader->frames[0] );
size = sizeof( aliashdr_t ) + (pinmodel->numframes - 1) * sizeof( maliasframedesc_t );
m_pAliasHeader = Mem_Alloc( mod->mempool, size );
mod->flags = pinmodel->flags; // share effects flags
@ -722,11 +761,12 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
}
m_pAliasHeader->numposes = g_posenum;
Mod_CalcAliasBounds( m_pAliasHeader );
Mod_CalcAliasBounds( mod );
mod->type = mod_alias;
// build the draw lists
GL_MakeAliasModelDisplayLists( mod, m_pAliasHeader );
GL_MakeAliasModelDisplayLists( mod );
// move the complete, relocatable alias model to the cache
loadmodel->cache.data = m_pAliasHeader;
@ -742,7 +782,7 @@ Mod_UnloadAliasModel
void Mod_UnloadAliasModel( model_t *mod )
{
aliashdr_t *palias;
int i;
int i, j;
ASSERT( mod != NULL );
@ -752,12 +792,16 @@ void Mod_UnloadAliasModel( model_t *mod )
palias = mod->cache.data;
if( !palias ) return; // already freed
// FIXME: check animating groups too?
for( i = 0; i < MAX_SKINS; i++ )
{
if( !palias->gl_texturenum[i][0] )
continue;
GL_FreeTexture( palias->gl_texturenum[i][0] );
break;
for( j = 0; j < 4; j++ )
{
GL_FreeTexture( palias->gl_texturenum[i][j] );
GL_FreeTexture( palias->fb_texturenum[i][j] );
}
}
Mem_FreePool( &mod->mempool );
@ -962,6 +1006,10 @@ void R_AliasSetupLighting( alight_t *plight )
g_alias.shadelight = plight->shadelight;
VectorCopy( plight->plightvec, g_alias.lightvec );
VectorCopy( plight->color, g_alias.lightcolor );
// transform back to local space
Matrix4x4_VectorIRotate( RI.objectMatrix, g_alias.lightvec, g_alias.lightvec_local );
VectorNormalize( g_alias.lightvec_local );
}
/*
@ -975,7 +1023,7 @@ void R_AliasLighting( float *lv, const vec3_t normal )
float illum = g_alias.ambientlight;
float r, lightcos;
lightcos = DotProduct( normal, g_alias.lightvec ); // -1 colinear, 1 opposite
lightcos = DotProduct( normal, g_alias.lightvec_local ); // -1 colinear, 1 opposite
if( lightcos > 1.0f ) lightcos = 1.0f;
illum += g_alias.shadelight;
@ -1010,8 +1058,8 @@ GL_DrawAliasFrame
void GL_DrawAliasFrame( aliashdr_t *paliashdr )
{
float lv_tmp;
mtrivertex_t *verts0;
mtrivertex_t *verts1;
trivertex_t *verts0;
trivertex_t *verts1;
vec3_t vert, norm;
int *order;
int count;
@ -1040,7 +1088,15 @@ void GL_DrawAliasFrame( aliashdr_t *paliashdr )
do
{
// texture coordinates come from the draw list
pglTexCoord2f (((float *)order)[0], ((float *)order)[1]);
if( glState.activeTMU > 0 )
{
GL_MultiTexCoord2f( GL_TEXTURE0, ((float *)order)[0], ((float *)order)[1] );
GL_MultiTexCoord2f( GL_TEXTURE1, ((float *)order)[0], ((float *)order)[1] );
}
else
{
pglTexCoord2f (((float *)order)[0], ((float *)order)[1]);
}
order += 2;
VectorLerp( m_bytenormals[verts0->lightnormalindex], g_alias.lerpfrac, m_bytenormals[verts1->lightnormalindex], norm );
@ -1063,8 +1119,8 @@ GL_DrawAliasShadow
*/
void GL_DrawAliasShadow( aliashdr_t *paliashdr )
{
mtrivertex_t *verts0;
mtrivertex_t *verts1;
trivertex_t *verts0;
trivertex_t *verts1;
float vec_x, vec_y;
vec3_t av, point;
int *order;
@ -1133,50 +1189,87 @@ void GL_DrawAliasShadow( aliashdr_t *paliashdr )
pglDisable( GL_STENCIL_TEST );
}
/*
====================
R_AliasLerpMovement
====================
*/
void R_AliasLerpMovement( cl_entity_t *e )
{
float f = 1.0f;
// don't do it if the goalstarttime hasn't updated in a while.
// NOTE: Because we need to interpolate multiplayer characters, the interpolation time limit
// was increased to 1.0 s., which is 2x the max lag we are accounting for.
if( g_alias.interpolate && ( g_alias.time < e->curstate.animtime + 1.0f ) && ( e->curstate.animtime != e->latched.prevanimtime ))
f = ( g_alias.time - e->curstate.animtime ) / ( e->curstate.animtime - e->latched.prevanimtime );
g_alias.lerpfrac = bound( 0.0f, f, 1.0f );
if( e->player || e->curstate.movetype != MOVETYPE_STEP )
return; // monsters only
// Msg( "%4.2f %.2f %.2f\n", f, e->curstate.animtime, g_studio.time );
VectorLerp( e->latched.prevorigin, f, e->curstate.origin, e->origin );
if( !VectorCompare( e->curstate.angles, e->latched.prevangles ))
{
vec4_t q, q1, q2;
AngleQuaternion( e->curstate.angles, q1, false );
AngleQuaternion( e->latched.prevangles, q2, false );
QuaternionSlerp( q2, q1, f, q );
QuaternionAngle( q, e->angles );
}
else VectorCopy( e->curstate.angles, e->angles );
// NOTE: this completely over control about angles and don't broke interpolation
if( FBitSet( e->model->flags, ALIAS_ROTATE ))
e->angles[1] = anglemod( 100.0f * g_alias.time );
}
/*
=================
R_SetupAliasFrame
=================
*/
void R_SetupAliasFrame( aliashdr_t *paliashdr, float f )
void R_SetupAliasFrame( cl_entity_t *e, aliashdr_t *paliashdr )
{
int newpose, oldpose;
int newframe, oldframe;
int oldnumposes;
int newnumposes;
int numposes, cycle;
float interval;
oldframe = (int)Q_floor( f );
newframe = (int)Q_ceil( f );
g_alias.lerpfrac = ( cl.time * 10 );
g_alias.lerpfrac -= (int)g_alias.lerpfrac;
oldframe = e->latched.prevframe;
newframe = e->curstate.frame;
if(( newframe >= paliashdr->numframes ) || ( newframe < 0 ))
{
MsgDev( D_ERROR, "R_SetupAliasFrame: no such frame %d\n", newframe );
newframe = 0;
}
if(( oldframe >= paliashdr->numframes ) || ( oldframe < 0 ))
oldframe = newframe;
numposes = paliashdr->frames[newframe].numposes;
if( numposes > 1 )
{
MsgDev( D_ERROR, "R_SetupAliasFrame: no such frame %d\n", oldframe );
oldframe = 0;
oldpose = newpose = paliashdr->frames[newframe].firstpose;
interval = 1.0f / paliashdr->frames[newframe].interval;
cycle = (int)(g_alias.time * interval);
oldpose += (cycle + 0) % numposes; // lerpframe from
newpose += (cycle + 1) % numposes; // lerpframe to
g_alias.lerpfrac = ( g_alias.time * interval );
g_alias.lerpfrac -= (int)g_alias.lerpfrac;
}
if( newframe >= paliashdr->numframes )
newframe = oldframe;
oldpose = paliashdr->frames[oldframe].firstpose;
newpose = paliashdr->frames[newframe].firstpose;
oldnumposes = paliashdr->frames[oldframe].numposes;
newnumposes = paliashdr->frames[oldframe].numposes;
// FIXME: group framelerping is incorrect
if( oldnumposes > 1 )
else
{
interval = paliashdr->frames[oldframe].interval;
oldpose += (int)(cl.time / interval) % oldnumposes;
}
if( newnumposes > 1 )
{
interval = paliashdr->frames[newframe].interval;
newpose += (int)(cl.time / interval) % newnumposes;
oldpose = paliashdr->frames[oldframe].firstpose;
newpose = paliashdr->frames[newframe].firstpose;
}
g_alias.oldpose = oldpose;
@ -1185,6 +1278,69 @@ void R_SetupAliasFrame( aliashdr_t *paliashdr, float f )
GL_DrawAliasFrame( paliashdr );
}
/*
===============
R_StudioDrawAbsBBox
===============
*/
static void R_AliasDrawAbsBBox( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
{
vec3_t p[8];
int i;
// looks ugly, skip
if( r_drawentities->value != 5 || e == &clgame.viewent )
return;
// compute a full bounding box
for( i = 0; i < 8; i++ )
{
p[i][0] = ( i & 1 ) ? absmin[0] : absmax[0];
p[i][1] = ( i & 2 ) ? absmin[1] : absmax[1];
p[i][2] = ( i & 4 ) ? absmin[2] : absmax[2];
}
GL_Bind( GL_TEXTURE0, tr.whiteTexture );
TriColor4f( 0.5f, 0.5f, 1.0f, 0.5f );
TriRenderMode( kRenderTransAdd );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
TriBegin( TRI_QUADS );
for( i = 0; i < 6; i++ )
{
TriBrightness( g_alias.shadelight / 255.0f );
TriVertex3fv( p[boxpnt[i][0]] );
TriVertex3fv( p[boxpnt[i][1]] );
TriVertex3fv( p[boxpnt[i][2]] );
TriVertex3fv( p[boxpnt[i][3]] );
}
TriEnd();
TriRenderMode( kRenderNormal );
}
/*
================
R_AliasSetupTimings
init current time for a given model
================
*/
static void R_AliasSetupTimings( void )
{
if( RI.drawWorld )
{
// synchronize with server time
g_alias.time = cl.time;
}
else
{
// menu stuff
g_alias.time = host.realtime;
}
}
/*
=================
R_DrawAliasModel
@ -1197,13 +1353,12 @@ void R_DrawAliasModel( cl_entity_t *e )
vec3_t absmin, absmax;
int anim, skin;
alight_t lighting;
float frame;
vec3_t dir;
vec3_t dir, angles;
clmodel = RI.currententity->model;
VectorAdd( RI.currententity->origin, clmodel->mins, absmin );
VectorAdd( RI.currententity->origin, clmodel->maxs, absmax );
VectorAdd( e->origin, clmodel->mins, absmin );
VectorAdd( e->origin, clmodel->maxs, absmax );
if( R_CullModel( e, absmin, absmax ))
return;
@ -1214,15 +1369,26 @@ void R_DrawAliasModel( cl_entity_t *e )
m_pAliasHeader = (aliashdr_t *)Mod_AliasExtradata( RI.currententity->model );
if( !m_pAliasHeader ) return;
// init time
R_AliasSetupTimings();
// HACKHACK: keep the angles unchanged
VectorCopy( e->angles, angles );
R_AliasLerpMovement( e );
if( !FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
e->angles[PITCH] = -e->angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim
if( e->player ) e->angles[PITCH] = 0.0f;
//
// get lighting information
//
lighting.plightvec = dir;
R_AliasDynamicLight( e, &lighting );
// model and frame independant
R_AliasSetupLighting( &lighting );
r_stats.c_alias_polys += m_pAliasHeader->numtris;
//
@ -1231,28 +1397,47 @@ void R_DrawAliasModel( cl_entity_t *e )
R_RotateForEntity( e );
pglTranslatef( m_pAliasHeader->scale_origin[0], m_pAliasHeader->scale_origin[1], m_pAliasHeader->scale_origin[2] );
pglScalef( m_pAliasHeader->scale[0], m_pAliasHeader->scale[1], m_pAliasHeader->scale[2] );
// model and frame independant
R_AliasSetupLighting( &lighting );
anim = (int)(cl.time * 10) & 3;
pglTranslatef( m_pAliasHeader->scale_origin[0], m_pAliasHeader->scale_origin[1], m_pAliasHeader->scale_origin[2] );
if( tr.fFlipViewModel )
pglScalef( m_pAliasHeader->scale[0], -m_pAliasHeader->scale[1], m_pAliasHeader->scale[2] );
else pglScalef( m_pAliasHeader->scale[0], m_pAliasHeader->scale[1], m_pAliasHeader->scale[2] );
anim = (int)(g_alias.time * 10) & 3;
skin = bound( 0, RI.currententity->curstate.skin, m_pAliasHeader->numskins - 1 );
if( r_lightmap->value && !r_fullbright->value )
GL_Bind( GL_TEXTURE0, tr.whiteTexture );
else GL_Bind( GL_TEXTURE0, m_pAliasHeader->gl_texturenum[skin][anim] );
pglShadeModel( GL_SMOOTH );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
frame = RI.currententity->curstate.frame;
frame = fmod( cl.time * 10, m_pAliasHeader->numframes );
R_SetupAliasFrame( m_pAliasHeader, frame );
if( m_pAliasHeader->fb_texturenum[skin][anim] )
{
GL_Bind( GL_TEXTURE1, m_pAliasHeader->fb_texturenum[skin][anim] );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
}
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
pglShadeModel( GL_SMOOTH );
R_SetupAliasFrame( e, m_pAliasHeader );
if( m_pAliasHeader->fb_texturenum[skin][anim] )
GL_CleanUpTextureUnits( 1 );
pglShadeModel( GL_FLAT );
R_LoadIdentity();
// get lerped origin
VectorAdd( e->origin, clmodel->mins, absmin );
VectorAdd( e->origin, clmodel->maxs, absmax );
R_AliasDrawAbsBBox( e, absmin, absmax );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
if( r_shadows.value )
{
// need to compute transformation matrix
@ -1272,6 +1457,8 @@ void R_DrawAliasModel( cl_entity_t *e )
R_LoadIdentity();
}
// HACKHACK: keep the angles unchanged
VectorCopy( angles, e->angles );
}
//==================================================================================

View File

@ -47,7 +47,7 @@ extern byte *r_temppool;
#define RP_FLIPFRONTFACE BIT( 4 ) // e.g. for mirrors drawing
#define RP_NONVIEWERREF (RP_MIRRORVIEW|RP_ENVVIEW)
#define R_StudioOpaque( rm ) ( rm == kRenderNormal || rm == kRenderTransAlpha )
#define R_ModelOpaque( rm ) ( rm == kRenderNormal || rm == kRenderTransAlpha )
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
#define RP_NORMALPASS() ((RI.params & RP_NONVIEWERREF) == 0 )
@ -205,6 +205,7 @@ typedef struct
qboolean ignore_lightgamma;
qboolean fCustomRendering;
qboolean fResetVis;
qboolean fFlipViewModel;
byte visbytes[(MAX_MAP_LEAFS+7)/8]; // member custom PVS
int lightstylevalue[MAX_LIGHTSTYLES]; // value 0 - 65536
@ -430,6 +431,7 @@ void R_DrawStudioModel( cl_entity_t *e );
//
void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded );
void R_DrawAliasModel( cl_entity_t *e );
void R_AliasInit( void );
//
// gl_warp.c

View File

@ -55,7 +55,6 @@ typedef struct
int framecount; // studio framecount
qboolean interpolate;
int rendermode;
qboolean flipmodel; // viewmodel is flipped
float blend; // blend value
// bones
@ -214,12 +213,12 @@ static void R_StudioSetupTimings( void )
/*
================
R_StudioFlipViewModel
R_AllowFlipViewModel
should a flip the viewmodel if cl_righthand is set to 1
================
*/
static qboolean R_StudioFlipViewModel( cl_entity_t *e )
static qboolean R_AllowFlipViewModel( cl_entity_t *e )
{
if( cl_righthand && cl_righthand->value > 0 )
{
@ -537,7 +536,7 @@ void R_StudioSetUpTransform( cl_entity_t *e )
Matrix3x4_CreateFromEntity( g_studio.rotationmatrix, angles, origin, 1.0f );
if( g_studio.flipmodel )
if( tr.fFlipViewModel )
{
g_studio.rotationmatrix[0][1] = -g_studio.rotationmatrix[0][1];
g_studio.rotationmatrix[1][1] = -g_studio.rotationmatrix[1][1];
@ -1933,7 +1932,7 @@ void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], vec3_t normal, vec3_t color
{
float r, r2;
if( g_studio.flipmodel )
if( tr.fFlipViewModel )
r = DotProduct( normal, light[i] );
else r = -DotProduct( normal, light[i] );
@ -2329,7 +2328,7 @@ static void R_StudioDrawPoints( void )
pglAlphaFunc( GL_GREATER, 0.5f );
pglDepthMask( GL_TRUE );
}
else if( FBitSet( g_nFaceFlags, STUDIO_NF_ADDITIVE ) && R_StudioOpaque( RI.currententity->curstate.rendermode ))
else if( FBitSet( g_nFaceFlags, STUDIO_NF_ADDITIVE ) && R_ModelOpaque( RI.currententity->curstate.rendermode ))
{
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglDepthMask( GL_FALSE );
@ -2349,7 +2348,7 @@ static void R_StudioDrawPoints( void )
pglAlphaFunc( GL_NOTEQUAL, 0.0f );
pglDisable( GL_ALPHA_TEST );
}
else if( FBitSet( g_nFaceFlags, STUDIO_NF_ADDITIVE ) && R_StudioOpaque( RI.currententity->curstate.rendermode ))
else if( FBitSet( g_nFaceFlags, STUDIO_NF_ADDITIVE ) && R_ModelOpaque( RI.currententity->curstate.rendermode ))
{
pglDepthMask( GL_TRUE );
pglDisable( GL_BLEND );
@ -3443,7 +3442,7 @@ void R_RunViewmodelEvents( void )
RI.currententity = &clgame.viewent;
if( !RI.currententity->model )
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
return;
R_StudioSetupTimings();
@ -3478,7 +3477,7 @@ void R_DrawViewModel( void )
return;
tr.blend = CL_FxBlend( view ) / 255.0f;
if( !R_StudioOpaque( view->curstate.rendermode ) && tr.blend <= 0.0f )
if( !R_ModelOpaque( view->curstate.rendermode ) && tr.blend <= 0.0f )
return; // invisible ?
RI.currententity = view;
@ -3486,29 +3485,36 @@ void R_DrawViewModel( void )
if( !RI.currententity->model )
return;
R_StudioSetupTimings();
// hack the depth range to prevent view model from poking into walls
pglDepthRange( gldepthmin, gldepthmin + 0.3f * ( gldepthmax - gldepthmin ));
RI.currentmodel = RI.currententity->model;
// backface culling for left-handed weapons
if( R_StudioFlipViewModel( RI.currententity ) || g_iBackFaceCull )
if( R_AllowFlipViewModel( RI.currententity ) || g_iBackFaceCull )
{
GL_FrontFace( !glState.frontFace );
g_studio.flipmodel = true;
tr.fFlipViewModel = true;
}
R_StudioDrawModelInternal( RI.currententity, STUDIO_RENDER );
switch( RI.currententity->model->type )
{
case mod_alias:
R_DrawAliasModel( RI.currententity );
break;
case mod_studio:
R_StudioSetupTimings();
R_StudioDrawModelInternal( RI.currententity, STUDIO_RENDER );
break;
}
// restore depth range
pglDepthRange( gldepthmin, gldepthmax );
// backface culling for left-handed weapons
if( R_StudioFlipViewModel( RI.currententity ) || g_iBackFaceCull )
if( R_AllowFlipViewModel( RI.currententity ) || g_iBackFaceCull )
{
GL_FrontFace( !glState.frontFace );
g_studio.flipmodel = false;
tr.fFlipViewModel = false;
}
}

View File

@ -1880,6 +1880,7 @@ qboolean R_Init( void )
R_InitImages();
R_SpriteInit();
R_StudioInit();
R_AliasInit();
R_ClearDecals();
R_ClearScene();

View File

@ -1178,7 +1178,7 @@ void Cmd_Init( void )
Cmd_AddCommand( "echo", Cmd_Echo_f, "print a message to the console (useful in scripts)" );
Cmd_AddCommand( "wait", Cmd_Wait_f, "make script execution wait for some rendered frames" );
Cmd_AddCommand( "cmdlist", Cmd_List_f, "display all console commands beginning with the specified prefix" );
Cmd_AddCommand( "stuffcmds", Cmd_StuffCmds_f, va( "execute commandline parameters (must be present in %s.rc script)", SI.ModuleName ));
Cmd_AddCommand( "stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in .rc script)" );
Cmd_AddCommand( "cmd", Cmd_ForwardToServer, "send a console commandline to the server" );
Cmd_AddCommand( "alias", Cmd_Alias_f, "create a script function. Without arguments show the list of all alias" );
Cmd_AddCommand( "unalias", Cmd_UnAlias_f, "remove a script function" );

View File

@ -44,6 +44,7 @@ extern "C" {
#define BIT( n ) (1<<( n ))
#define GAMMA ( 2.2 ) // Valve Software gamma
#define INVGAMMA ( 1.0 / 2.2 ) // back to 1.0
#define TEXGAMMA ( 0.9 ) // compensate dim textures
#define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))
@ -211,7 +212,9 @@ typedef struct gameinfo_s
typedef struct sysinfo_s
{
string ModuleName; // exe.filename
string exeName; // exe.filename
string rcName; // .rc script name
string basedirName; // name of base directory
gameinfo_t *GameInfo; // current GameInfo
gameinfo_t *games[MAX_MODS]; // environment games (founded at each engine start)
int numgames;

View File

@ -863,6 +863,10 @@ void FS_Rescan( void )
if( Q_stricmp( GI->basedir, GI->falldir ) && Q_stricmp( GI->gamedir, GI->falldir ))
FS_AddGameHierarchy( GI->falldir, 0 );
FS_AddGameHierarchy( GI->gamedir, FS_GAMEDIR_PATH );
if( FS_FileExists( va( "%s.rc", SI.basedirName ), false ))
Q_strncpy( SI.rcName, SI.basedirName, sizeof( SI.rcName )); // e.g. valve.rc
else Q_strncpy( SI.rcName, SI.exeName, sizeof( SI.rcName )); // e.g. quake.rc
}
/*
@ -989,7 +993,7 @@ void FS_CreateDefaultGameInfo( const char *filename )
Q_strncpy( defGI.title, "New Game", sizeof( defGI.title ));
Q_strncpy( defGI.gamedir, gs_basedir, sizeof( defGI.gamedir ));
Q_strncpy( defGI.basedir, SI.ModuleName, sizeof( defGI.basedir ));
Q_strncpy( defGI.basedir, SI.basedirName, sizeof( defGI.basedir ));
Q_strncpy( defGI.sp_entity, "info_player_start", sizeof( defGI.sp_entity ));
Q_strncpy( defGI.mp_entity, "info_player_deathmatch", sizeof( defGI.mp_entity ));
Q_strncpy( defGI.dll_path, "cl_dlls", sizeof( defGI.dll_path ));
@ -1025,7 +1029,7 @@ static qboolean FS_ParseLiblistGam( const char *filename, const char *gamedir, g
Q_strncpy( GameInfo->title, "New Game", sizeof( GameInfo->title ));
Q_strncpy( GameInfo->gamedir, gamedir, sizeof( GameInfo->gamedir ));
Q_strncpy( GameInfo->basedir, SI.ModuleName, sizeof( GameInfo->basedir ));
Q_strncpy( GameInfo->basedir, SI.basedirName, sizeof( GameInfo->basedir ));
Q_strncpy( GameInfo->sp_entity, "info_player_start", sizeof( GameInfo->sp_entity ));
Q_strncpy( GameInfo->mp_entity, "info_player_deathmatch", sizeof( GameInfo->mp_entity ));
Q_strncpy( GameInfo->game_dll, "dlls/hl.dll", sizeof( GameInfo->game_dll ));
@ -1409,18 +1413,18 @@ void FS_Init( void )
SI.numgames = 0;
if( !Sys_GetParmFromCmdLine( "-game", gs_basedir ))
Q_strcpy( gs_basedir, SI.ModuleName ); // default dir
Q_strcpy( gs_basedir, SI.basedirName ); // default dir
if( FS_CheckNastyPath( gs_basedir, true ))
{
MsgDev( D_ERROR, "FS_Init: invalid game directory \"%s\"\n", gs_basedir );
Q_strcpy( gs_basedir, SI.ModuleName ); // default dir
Q_strcpy( gs_basedir, SI.basedirName ); // default dir
}
// validate directories
for( i = 0; i < dirs.numstrings; i++ )
{
if( !Q_stricmp( SI.ModuleName, dirs.strings[i] ))
if( !Q_stricmp( SI.basedirName, dirs.strings[i] ))
hasDefaultDir = true;
if( !Q_stricmp( gs_basedir, dirs.strings[i] ))
@ -1430,7 +1434,7 @@ void FS_Init( void )
if( i == dirs.numstrings )
{
MsgDev( D_INFO, "FS_Init: game directory \"%s\" not exist\n", gs_basedir );
if( hasDefaultDir ) Q_strncpy( gs_basedir, SI.ModuleName, sizeof( gs_basedir )); // default dir
if( hasDefaultDir ) Q_strncpy( gs_basedir, SI.basedirName, sizeof( gs_basedir )); // default dir
}
// build list of game directories here

View File

@ -62,7 +62,7 @@ void BuildGammaTable( float lightgamma, float brightness )
for( i = 0; i < 256; i++ )
{
f = 255.0 * pow(( float )i / 255.0f, g1 );
f = 255.0 * pow(( float )i / 255.0f, TEXGAMMA );
inf = (int)(f + 0.5f);
texgammatable[i] = bound( 0, inf, 255 );
}

View File

@ -831,7 +831,7 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame )
// we can specified custom name, from Sys_NewInstance
if( GetModuleFileName( NULL, szTemp, sizeof( szTemp )) && !host.change_game )
FS_FileBase( szTemp, SI.ModuleName );
FS_FileBase( szTemp, SI.exeName );
FS_ExtractFilePath( szTemp, szRootPath );
if( Q_stricmp( host.rootdir, szRootPath ))
@ -840,15 +840,15 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame )
SetCurrentDirectory( host.rootdir );
}
if( SI.ModuleName[0] == '#' ) host.type = HOST_DEDICATED;
if( SI.exeName[0] == '#' ) host.type = HOST_DEDICATED;
// determine host type
if( progname[0] == '#' )
{
Q_strncpy( SI.ModuleName, progname + 1, sizeof( SI.ModuleName ));
Q_strncpy( SI.basedirName, progname + 1, sizeof( SI.basedirName ));
host.type = HOST_DEDICATED;
}
else Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName ));
else Q_strncpy( SI.basedirName, progname, sizeof( SI.basedirName ));
if( Sys_CheckParm( "-dedicated" ))
host.type = HOST_DEDICATED;
@ -996,7 +996,7 @@ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func
case HOST_NORMAL:
Con_ShowConsole( false ); // hide console
// execute startup config and cmdline
Cbuf_AddText( va( "exec %s.rc\n", SI.ModuleName ));
Cbuf_AddText( va( "exec %s.rc\n", SI.rcName ));
Cbuf_Execute();
if( !host.config_executed )
{

View File

@ -37,8 +37,8 @@ keyname_t keynames[] =
{
{"TAB", K_TAB, "" },
{"ENTER", K_ENTER, "" },
{"ESCAPE", K_ESCAPE, "cancelselect" }, // hardcoded
{"SPACE", K_SPACE, "+moveup" },
{"ESCAPE", K_ESCAPE, "escape" }, // hardcoded
{"SPACE", K_SPACE, "+jump" },
{"BACKSPACE", K_BACKSPACE, "" },
{"UPARROW", K_UPARROW, "+forward" },
{"DOWNARROW", K_DOWNARROW, "+back" },
@ -59,7 +59,7 @@ keyname_t keynames[] =
{"F9", K_F9, "" },
{"F10", K_F10, "menu_main" },
{"F11", K_F11, "" },
{"F12", K_F12, "screenshot" },
{"F12", K_F12, "snapshot" },
{"INS", K_INS, "" },
{"DEL", K_DEL, "+lookdown" },
{"PGDN", K_PGDN, "+lookup" },

View File

@ -956,7 +956,7 @@ static void Mod_LoadTextures( const dlump_t *l )
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
if( bmodel_version >= HLBSP_VERSION ) size += sizeof( short ) + 768;
tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_NOMIPMAP|TF_MAKELUMA, NULL );
tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA, NULL );
}
else
{
@ -982,7 +982,7 @@ static void Mod_LoadTextures( const dlump_t *l )
}
// okay, loading it from wad or hi-res version
tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_NOMIPMAP|TF_MAKELUMA, NULL );
tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA, NULL );
if( src ) Mem_Free( src );
if( !tx->fb_texturenum && load_external_luma )

View File

@ -621,6 +621,7 @@ void SV_InitSaveRestore( void );
//
void SV_GetTrueOrigin( sv_client_t *cl, int edictnum, vec3_t origin );
void SV_GetTrueMinMax( sv_client_t *cl, int edictnum, vec3_t mins, vec3_t maxs );
qboolean SV_PlayerIsFrozen( edict_t *pClient );
//
// sv_world.c

View File

@ -2289,7 +2289,7 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
cl->packet_loss = packet_loss;
// check for pause or frozen
if( sv.paused || sv.loadgame || sv.background || !CL_IsInGame() || ( player->v.flags & FL_FROZEN ))
if( sv.paused || sv.loadgame || sv.background || !CL_IsInGame() || SV_PlayerIsFrozen( player ))
{
for( i = 0; i < numcmds; i++ )
{
@ -2299,7 +2299,7 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
cmds[i].upmove = 0;
cmds[i].buttons = 0;
if( player->v.flags & FL_FROZEN || sv.background )
if( SV_PlayerIsFrozen( player ) || sv.background )
cmds[i].impulse = 0;
VectorCopy( cmds[i].viewangles, player->v.v_angle );
@ -2345,8 +2345,11 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
frame->ping_time -= cl->lastcmd.msec * 0.5f / 1000.0f;
frame->ping_time = Q_max( 0.0f, frame->ping_time );
if( player->v.animtime > svgame.globals->time + sv.frametime )
player->v.animtime = svgame.globals->time + sv.frametime;
if( Mod_GetType( player->v.modelindex ) == mod_studio )
{
if( player->v.animtime > svgame.globals->time + sv.frametime )
player->v.animtime = svgame.globals->time + sv.frametime;
}
}
/*

View File

@ -164,7 +164,9 @@ float SV_AngleMod( float ideal, float current, float speed )
{
float move;
if( anglemod( current ) == ideal ) // already there?
current = anglemod( current );
if( current == ideal ) // already there?
return current;
move = ideal - current;
@ -2566,9 +2568,9 @@ void pfnMessageEnd( void )
MSG_Clear( &sv.multicast );
return;
}
}
sv.multicast.pData[svgame.msg_size_index] = svgame.msg_realsize;
sv.multicast.pData[svgame.msg_size_index] = svgame.msg_realsize;
}
}
else if( svgame.msg[svgame.msg_index].size != -1 )
{
@ -2919,15 +2921,30 @@ SV_AllocString
allocate new engine string
=============
*/
string_t SV_AllocString( const char *szValue )
string_t SV_AllocString( const char *szString )
{
const char *newString;
char *out, *out_p;
int i, l;
if( svgame.physFuncs.pfnAllocString != NULL )
return svgame.physFuncs.pfnAllocString( szValue );
return svgame.physFuncs.pfnAllocString( szString );
newString = _copystring( svgame.stringspool, szValue, __FILE__, __LINE__ );
return newString - svgame.globals->pStringBase;
l = Q_strlen( szString ) + 1;
out = out_p = Mem_Alloc( svgame.stringspool, l );
for( i = 0; i < l; i++ )
{
if( szString[i] == '\\' && i < l - 1 )
{
i++;
if( szString[i] == 'n')
*out_p++ = '\n';
else *out_p++ = '\\';
}
else *out_p++ = szString[i];
}
return out - svgame.globals->pStringBase;
}
/*

View File

@ -37,6 +37,16 @@ void SV_ConvertPMTrace( trace_t *out, pmtrace_t *in, edict_t *ent )
out->ent = ent;
}
qboolean SV_PlayerIsFrozen( edict_t *pClient )
{
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
return false;
if( FBitSet( pClient->v.flags, FL_FROZEN ))
return true;
return false;
}
void SV_ClipPMoveToEntity( physent_t *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, pmtrace_t *tr )
{
ASSERT( tr != NULL );
@ -728,14 +738,14 @@ static void SV_FinishPMove( playermove_t *pmove, sv_client_t *cl )
VectorCopy( pmove->vuser3, clent->v.vuser3 );
VectorCopy( pmove->vuser4, clent->v.vuser4 );
if( svgame.pmove->onground == -1 )
if( pmove->onground == -1 )
{
clent->v.flags &= ~FL_ONGROUND;
}
else if( pmove->onground >= 0 && pmove->onground < pmove->numphysent )
{
clent->v.flags |= FL_ONGROUND;
clent->v.groundentity = EDICT_NUM( svgame.pmove->physents[svgame.pmove->onground].info );
clent->v.groundentity = EDICT_NUM( pmove->physents[pmove->onground].info );
}
// angles