22 Feb 2019

This commit is contained in:
g-cont 2019-02-22 00:00:00 +03:00 committed by Alibek Omarov
parent f838d648a7
commit 8e642705a1
28 changed files with 123 additions and 125 deletions

View File

@ -23,7 +23,7 @@ GNU General Public License for more details.
#define ENGINE_PHYSICS_PUSHER_EXT (1<<3) // enable sets of improvements for MOVETYPE_PUSH physics #define ENGINE_PHYSICS_PUSHER_EXT (1<<3) // enable sets of improvements for MOVETYPE_PUSH physics
#define ENGINE_LARGE_LIGHTMAPS (1<<4) // change lightmap sizes from 128x128 to 1024x1024 #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_COMPENSATE_QUAKE_BUG (1<<5) // compensate stupid quake bug (inverse pitch) for mods where this bug is fixed
// reserved #define ENGINE_IMPROVED_LINETRACE (1<<6) // new traceline that tracing through alphatextures
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
#endif//FEATURES_H #endif//FEATURES_H

View File

@ -3124,6 +3124,7 @@ void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
// check for invalid parms // check for invalid parms
if( flEnd <= flStart ) if( flEnd <= flStart )
{ {
glState.isFogEnabled = false;
RI.fogCustom = false; RI.fogCustom = false;
pglDisable( GL_FOG ); pglDisable( GL_FOG );
return; return;

View File

@ -378,7 +378,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, long im
{ {
HIMAGE tx; HIMAGE tx;
if( !szPicName || !*szPicName ) if( !COM_CheckString( szPicName ))
{ {
Con_Reportf( S_ERROR "CL_LoadImage: bad name!\n" ); Con_Reportf( S_ERROR "CL_LoadImage: bad name!\n" );
return 0; return 0;

View File

@ -612,6 +612,7 @@ typedef struct
GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS]; GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS];
GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R
GLint texCoordArrayMode[MAX_TEXTURE_UNITS]; // 0 - disabled, 1 - enabled, 2 - cubemap GLint texCoordArrayMode[MAX_TEXTURE_UNITS]; // 0 - disabled, 1 - enabled, 2 - cubemap
GLint isFogEnabled;
int faceCull; int faceCull;

View File

@ -43,18 +43,14 @@ static int R_RankForRenderMode( int rendermode )
void R_AllowFog( int allowed ) void R_AllowFog( int allowed )
{ {
static int isFogEnabled;
if( allowed ) if( allowed )
{ {
if( isFogEnabled ) if( glState.isFogEnabled )
pglEnable( GL_FOG ); pglEnable( GL_FOG );
} }
else else
{ {
isFogEnabled = pglIsEnabled( GL_FOG ); if( glState.isFogEnabled )
if( isFogEnabled )
pglDisable( GL_FOG ); pglDisable( GL_FOG );
} }
} }
@ -487,6 +483,9 @@ static void R_SetupFrame( void )
// setup viewplane dist // setup viewplane dist
RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward ); RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward );
// NOTE: this request is the fps-killer on some NVidia drivers
glState.isFogEnabled = pglIsEnabled( GL_FOG );
if( !gl_nosort->value ) if( !gl_nosort->value )
{ {
// sort translucents entities by rendermode and distance // sort translucents entities by rendermode and distance
@ -690,7 +689,11 @@ static void R_CheckFog( void )
// in some cases waterlevel jumps from 3 to 1. Catch it // in some cases waterlevel jumps from 3 to 1. Catch it
RI.cached_waterlevel = cl.local.waterlevel; RI.cached_waterlevel = cl.local.waterlevel;
RI.cached_contents = CONTENTS_EMPTY; RI.cached_contents = CONTENTS_EMPTY;
if( !RI.fogCustom ) pglDisable( GL_FOG ); if( !RI.fogCustom )
{
glState.isFogEnabled = false;
pglDisable( GL_FOG );
}
} }
return; return;
} }

View File

@ -178,6 +178,7 @@ void R_NewMap( void )
for( i = 0; i < cl.worldmodel->numleafs; i++ ) for( i = 0; i < cl.worldmodel->numleafs; i++ )
cl.worldmodel->leafs[i+1].efrags = NULL; cl.worldmodel->leafs[i+1].efrags = NULL;
glState.isFogEnabled = false;
tr.skytexturenum = -1; tr.skytexturenum = -1;
tr.max_recursion = 0; tr.max_recursion = 0;
pglDisable( GL_FOG ); pglDisable( GL_FOG );

View File

@ -204,7 +204,7 @@ void GL_SetupFogColorForSurfaces( void )
vec3_t fogColor; vec3_t fogColor;
float factor, div; float factor, div;
if( !pglIsEnabled( GL_FOG )) if( !glState.isFogEnabled )
return; return;
if( RI.currententity && RI.currententity->curstate.rendermode == kRenderTransTexture ) if( RI.currententity && RI.currententity->curstate.rendermode == kRenderTransTexture )
@ -224,7 +224,7 @@ void GL_SetupFogColorForSurfaces( void )
void GL_ResetFogColor( void ) void GL_ResetFogColor( void )
{ {
// restore fog here // restore fog here
if( pglIsEnabled( GL_FOG )) if( glState.isFogEnabled )
pglFogfv( GL_FOG_COLOR, RI.fogColor ); pglFogfv( GL_FOG_COLOR, RI.fogColor );
} }
@ -1081,7 +1081,7 @@ void R_RenderBrushPoly( msurface_t *fa, int cull_type )
if( CVAR_TO_BOOL( r_detailtextures )) if( CVAR_TO_BOOL( r_detailtextures ))
{ {
if( pglIsEnabled( GL_FOG )) if( glState.isFogEnabled )
{ {
// don't apply detail textures for windows in the fog // don't apply detail textures for windows in the fog
if( RI.currententity->curstate.rendermode != kRenderTransTexture ) if( RI.currententity->curstate.rendermode != kRenderTransTexture )

View File

@ -1553,8 +1553,6 @@ StudioCalcAttachments
static void R_StudioCalcAttachments( void ) static void R_StudioCalcAttachments( void )
{ {
mstudioattachment_t *pAtt; mstudioattachment_t *pAtt;
vec3_t forward, bonepos;
vec3_t localOrg, localAng;
int i; int i;
// calculate attachment points // calculate attachment points
@ -1563,11 +1561,6 @@ static void R_StudioCalcAttachments( void )
for( i = 0; i < Q_min( MAXSTUDIOATTACHMENTS, m_pStudioHeader->numattachments ); i++ ) for( i = 0; i < Q_min( MAXSTUDIOATTACHMENTS, m_pStudioHeader->numattachments ); i++ )
{ {
Matrix3x4_VectorTransform( g_studio.lighttransform[pAtt[i].bone], pAtt[i].org, RI.currententity->attachment[i] ); Matrix3x4_VectorTransform( g_studio.lighttransform[pAtt[i].bone], pAtt[i].org, RI.currententity->attachment[i] );
VectorSubtract( RI.currententity->attachment[i], RI.currententity->origin, localOrg );
Matrix3x4_OriginFromMatrix( g_studio.lighttransform[pAtt[i].bone], bonepos );
VectorSubtract( localOrg, bonepos, forward ); // make forward
VectorNormalizeFast( forward );
VectorAngles( forward, localAng );
} }
} }
@ -3803,7 +3796,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
ptexture->index = (int)((byte *)phdr) + ptexture->index; ptexture->index = (int)((byte *)phdr) + ptexture->index;
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768; size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED )) if( FBitSet( host.features, ENGINE_IMPROVED_LINETRACE ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing
// build the texname // build the texname

View File

@ -976,9 +976,8 @@ void Cmd_ExecuteString( char *text )
{ {
Cmd_ForwardToServer(); Cmd_ForwardToServer();
} }
else if( text[0] != '@' && Cvar_VariableInteger( "host_gameloaded" )) else if( Cvar_VariableInteger( "host_gameloaded" ))
{ {
// commands with leading '@' are hidden system commands
Con_Printf( S_WARN "Unknown command \"%s\"\n", text ); Con_Printf( S_WARN "Unknown command \"%s\"\n", text );
} }
} }

View File

@ -22,16 +22,16 @@ GNU General Public License for more details.
const char *file_exts[10] = const char *file_exts[10] =
{ {
".cfg", "cfg",
".lst", "lst",
".exe", "exe",
".vbs", "vbs",
".com", "com",
".bat", "bat",
".dll", "dll",
".ini", "ini",
".log", "log",
".sys", "sys",
}; };
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -891,7 +891,6 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
void SV_StartMusic( const char *curtrack, const char *looptrack, long position ); void SV_StartMusic( const char *curtrack, const char *looptrack, long position );
void SV_CreateDecal( struct sizebuf_s *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale ); void SV_CreateDecal( struct sizebuf_s *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale );
void Log_Printf( const char *fmt, ... ); void Log_Printf( const char *fmt, ... );
struct sizebuf_s *SV_GetReliableDatagram( void );
void SV_BroadcastCommand( const char *fmt, ... ); void SV_BroadcastCommand( const char *fmt, ... );
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
void SV_BroadcastPrintf( struct sv_client_s *ignore, char *fmt, ... ); void SV_BroadcastPrintf( struct sv_client_s *ignore, char *fmt, ... );

View File

@ -154,7 +154,7 @@ void Con_SetColor_f( void )
{ {
vec3_t color; vec3_t color;
switch( Cmd_Argc() ) switch( Cmd_Argc( ))
{ {
case 1: case 1:
Con_Printf( "\"con_color\" is %i %i %i\n", g_color_table[7][0], g_color_table[7][1], g_color_table[7][2] ); Con_Printf( "\"con_color\" is %i %i %i\n", g_color_table[7][0], g_color_table[7][1], g_color_table[7][2] );

View File

@ -411,6 +411,7 @@ double Host_CalcFPS( void )
else else
{ {
fps = host_maxfps->value; fps = host_maxfps->value;
if( fps == 0.0 ) fps = MAX_FPS;
fps = bound( MIN_FPS, fps, MAX_FPS ); fps = bound( MIN_FPS, fps, MAX_FPS );
} }

View File

@ -1632,7 +1632,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
{ {
byte *entpatch = NULL; byte *entpatch = NULL;
char token[MAX_TOKEN]; char token[MAX_TOKEN];
char wadstring[2048]; char wadstring[MAX_TOKEN];
string keyname; string keyname;
char *pfile; char *pfile;
@ -1640,7 +1640,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
{ {
char entfilename[MAX_QPATH]; char entfilename[MAX_QPATH];
long entpatchsize; long entpatchsize;
size_t ft1, ft2; long ft1, ft2;
// world is check for entfile too // world is check for entfile too
Q_strncpy( entfilename, loadmodel->name, sizeof( entfilename )); Q_strncpy( entfilename, loadmodel->name, sizeof( entfilename ));
@ -1960,7 +1960,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
tx->width = mt->width; tx->width = mt->width;
tx->height = mt->height; tx->height = mt->height;
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ) && mt->name[0] == '{' ) if( FBitSet( host.features, ENGINE_IMPROVED_LINETRACE ) && mt->name[0] == '{' )
SetBits( txFlags, TF_KEEP_SOURCE ); // Paranoia2 texture alpha-tracing SetBits( txFlags, TF_KEEP_SOURCE ); // Paranoia2 texture alpha-tracing
if( mt->offsets[0] > 0 ) if( mt->offsets[0] > 0 )

View File

@ -507,6 +507,8 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float *
{ {
mstudioattachment_t *pAtt; mstudioattachment_t *pAtt;
vec3_t angles2; vec3_t angles2;
matrix3x4 localPose;
matrix3x4 worldPose;
model_t *mod; model_t *mod;
mod = SV_ModelHandle( e->v.modelindex ); mod = SV_ModelHandle( e->v.modelindex );
@ -534,19 +536,15 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float *
pBlendAPI->SV_StudioSetupBones( mod, e->v.frame, e->v.sequence, angles2, e->v.origin, e->v.controller, e->v.blending, pAtt->bone, e ); pBlendAPI->SV_StudioSetupBones( mod, e->v.frame, e->v.sequence, angles2, e->v.origin, e->v.controller, e->v.blending, pAtt->bone, e );
// compute pos and angles Matrix3x4_LoadIdentity( localPose );
if( origin != NULL ) Matrix3x4_SetOrigin( localPose, pAtt->org[0], pAtt->org[1], pAtt->org[2] );
Matrix3x4_VectorTransform( studio_bones[pAtt->bone], pAtt->org, origin ); Matrix3x4_ConcatTransforms( worldPose, studio_bones[pAtt->bone], localPose );
if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ) && origin != NULL && angles != NULL ) if( origin != NULL ) // origin is used always
{ Matrix3x4_OriginFromMatrix( worldPose, origin );
vec3_t forward, bonepos;
Matrix3x4_OriginFromMatrix( studio_bones[pAtt->bone], bonepos ); if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ) && angles != NULL )
VectorSubtract( origin, bonepos, forward ); // make forward Matrix3x4_AnglesFromMatrix( worldPose, angles );
VectorNormalizeFast( forward );
VectorAngles( forward, angles );
}
} }
/* /*
@ -565,7 +563,7 @@ void Mod_GetBonePosition( const edict_t *e, int iBone, float *origin, float *ang
pBlendAPI->SV_StudioSetupBones( mod, e->v.frame, e->v.sequence, e->v.angles, e->v.origin, e->v.controller, e->v.blending, iBone, e ); pBlendAPI->SV_StudioSetupBones( mod, e->v.frame, e->v.sequence, e->v.angles, e->v.origin, e->v.controller, e->v.blending, iBone, e );
if( origin ) Matrix3x4_OriginFromMatrix( studio_bones[iBone], origin ); if( origin ) Matrix3x4_OriginFromMatrix( studio_bones[iBone], origin );
if( angles ) VectorAngles( studio_bones[iBone][0], angles ); // bone forward to angles if( angles ) Matrix3x4_AnglesFromMatrix( studio_bones[iBone], angles );
} }
/* /*

View File

@ -137,6 +137,11 @@ static void Mod_FreeModel( model_t *mod )
=============================================================================== ===============================================================================
*/ */
/*
================
Mod_Init
================
*/
void Mod_Init( void ) void Mod_Init( void )
{ {
com_studiocache = Mem_AllocPool( "Studio Cache" ); com_studiocache = Mem_AllocPool( "Studio Cache" );

View File

@ -616,7 +616,6 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa )
fa[2] = MSG_ReadBitAngle( sb, 16 ); fa[2] = MSG_ReadBitAngle( sb, 16 );
} }
long MSG_ReadLong( sizebuf_t *sb ) long MSG_ReadLong( sizebuf_t *sb )
{ {
return MSG_ReadSBitLong( sb, sizeof( long ) << 3 ); return MSG_ReadSBitLong( sb, sizeof( long ) << 3 );

View File

@ -308,7 +308,7 @@ delta_info_t *Delta_FindStruct( const char *name )
{ {
int i; int i;
if( !name || !name[0] ) if( !COM_CheckString( name ))
return NULL; return NULL;
for( i = 0; i < NUM_FIELDS( dt_info ); i++ ) for( i = 0; i < NUM_FIELDS( dt_info ); i++ )
@ -427,8 +427,12 @@ qboolean Delta_AddField( const char *pStructName, const char *pName, int flags,
{ {
if( !Q_strcmp( pField->name, pName )) if( !Q_strcmp( pField->name, pName ))
{ {
Con_Reportf( "Delta_Add: %s->%s already existing\n", pStructName, pName ); // update existed field
return false; // field already exist pField->flags = flags;
pField->bits = bits;
pField->multiplier = mul;
pField->post_multiplier = post_mul;
return true;
} }
} }
@ -470,7 +474,7 @@ void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pFiel
Assert( pField != NULL ); Assert( pField != NULL );
if( !pField->name || !*pField->name ) if( !COM_CheckString( pField->name ))
return; // not initialized ? return; // not initialized ?
dt = Delta_FindStructByIndex( tableIndex ); dt = Delta_FindStructByIndex( tableIndex );
@ -480,7 +484,7 @@ void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pFiel
Assert( nameIndex >= 0 && nameIndex < dt->maxFields ); Assert( nameIndex >= 0 && nameIndex < dt->maxFields );
MSG_BeginServerCmd( msg, svc_deltatable ); MSG_BeginServerCmd( msg, svc_deltatable );
MSG_WriteUBitLong( msg, tableIndex, 4 ); // assume we support 16 network tables MSG_WriteUBitLong( msg, tableIndex, 4 ); // assume we support 16 network tables
MSG_WriteUBitLong( msg, nameIndex, 8 ); // 255 fields by struct should be enough MSG_WriteUBitLong( msg, nameIndex, 8 ); // 255 fields by struct should be enough
MSG_WriteUBitLong( msg, pField->flags, 10 ); // flags are indicated various input types MSG_WriteUBitLong( msg, pField->flags, 10 ); // flags are indicated various input types
MSG_WriteUBitLong( msg, pField->bits - 1, 5 ); // max received value is 32 (32 bit) MSG_WriteUBitLong( msg, pField->bits - 1, 5 ); // max received value is 32 (32 bit)
@ -526,10 +530,10 @@ void Delta_ParseTableField( sizebuf_t *msg )
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))
post_mul = MSG_ReadFloat( msg ); post_mul = MSG_ReadFloat( msg );
#if 0
// delta encoders it's already initialized on this machine (local game) // delta encoders it's already initialized on this machine (local game)
if( delta_init ) return; if( delta_init ) return;
#endif
// add field to table // add field to table
Delta_AddField( dt->pName, pName, flags, bits, mul, post_mul ); Delta_AddField( dt->pName, pName, flags, bits, mul, post_mul );
} }
@ -610,7 +614,6 @@ qboolean Delta_ParseField( char **delta_script, const delta_field_t *pInfo, delt
} }
// read delta-bits // read delta-bits
if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL ) if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL )
{ {
Con_DPrintf( S_ERROR "Delta_ReadField: %s field bits argument is missing\n", pField->name ); Con_DPrintf( S_ERROR "Delta_ReadField: %s field bits argument is missing\n", pField->name );
@ -765,13 +768,8 @@ void Delta_InitFields( void )
Delta_ParseTable( &pfile, dt, encodeDll, encodeFunc ); Delta_ParseTable( &pfile, dt, encodeDll, encodeFunc );
} }
Mem_Free( afile ); Mem_Free( afile );
#if 0
// adding some required fields that user may forget or don't know how to specified
Delta_AddField( "event_t", "velocity[0]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f );
Delta_AddField( "event_t", "velocity[1]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f );
Delta_AddField( "event_t", "velocity[2]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f );
#endif
} }
void Delta_Init( void ) void Delta_Init( void )
@ -1193,7 +1191,7 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to
else if( pField->flags & DT_TIMEWINDOW_8 ) else if( pField->flags & DT_TIMEWINDOW_8 )
{ {
flValue = *(float *)((byte *)to + pField->offset ); flValue = *(float *)((byte *)to + pField->offset );
flTime = Q_rint( timebase * 100.0f ) - Q_rint(flValue * 100.0f); flTime = Q_rint( timebase * 100.0f ) - Q_rint( flValue * 100.0f );
iValue = (uint)abs( flTime ); iValue = (uint)abs( flTime );
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned ); MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );

View File

@ -58,10 +58,10 @@ GNU General Public License for more details.
// { // {
// byte (on/off) // byte (on/off)
// int (fragment id) // int (fragment id)
// short (startpos) // int (startpos)
// short (length) // int (length)
// } // }
#define HEADER_BYTES ( 8 + MAX_STREAMS * 9 ) #define HEADER_BYTES ( 8 + MAX_STREAMS * 13 )
// Pad this to next higher 16 byte boundary // Pad this to next higher 16 byte boundary
// This is the largest packet that can come in/out over the wire, before processing the header // This is the largest packet that can come in/out over the wire, before processing the header

View File

@ -256,7 +256,7 @@ qboolean Mem_IsAllocatedExt( byte *poolptr, void *data )
void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline ) void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline )
{ {
memheader_t *mem; memheader_t *mem;
if( data == NULL ) if( data == NULL )
Sys_Error( "Mem_CheckSentinels: data == NULL (sentinel check at %s:%i)\n", filename, fileline ); Sys_Error( "Mem_CheckSentinels: data == NULL (sentinel check at %s:%i)\n", filename, fileline );
@ -269,7 +269,7 @@ void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline )
Sys_Error( "Mem_CheckSentinels: trashed header sentinel 1 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline ); Sys_Error( "Mem_CheckSentinels: trashed header sentinel 1 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline );
} }
if( *((byte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2 ) if( *((byte *)mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2 )
{ {
mem->filename = Mem_CheckFilename( mem->filename ); // make sure what we don't crash var_args mem->filename = Mem_CheckFilename( mem->filename ); // make sure what we don't crash var_args
Sys_Error( "Mem_CheckSentinels: trashed header sentinel 2 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline ); Sys_Error( "Mem_CheckSentinels: trashed header sentinel 2 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline );

View File

@ -263,7 +263,6 @@ typedef struct sv_client_s
a program error, like an overflowed reliable buffer a program error, like an overflowed reliable buffer
============================================================================= =============================================================================
*/ */
// MAX_CHALLENGES is made large to prevent a denial // MAX_CHALLENGES is made large to prevent a denial
// of service attack that could cycle all of them // of service attack that could cycle all of them
// out before legitimate users connected // out before legitimate users connected

View File

@ -869,6 +869,7 @@ void SV_EntityInfo_f( void )
Con_Printf( "\n" ); Con_Printf( "\n" );
} }
} }
/* /*
================== ==================
SV_InitHostCommands SV_InitHostCommands

View File

@ -155,7 +155,7 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_
if( fullvis ) continue; // portal ents will be added anyway, ignore recursion if( fullvis ) continue; // portal ents will be added anyway, ignore recursion
// if its a portal entity, add everything visible from its camera position // if it's a portal entity, add everything visible from its camera position
if( from_client && FBitSet( ent->v.effects, EF_MERGE_VISIBILITY )) if( from_client && FBitSet( ent->v.effects, EF_MERGE_VISIBILITY ))
{ {
SetBits( sv.hostflags, SVF_MERGE_VISIBILITY ); SetBits( sv.hostflags, SVF_MERGE_VISIBILITY );
@ -658,7 +658,7 @@ void SV_WriteEntitiesToClient( sv_client_t *cl, sizebuf_t *msg )
if( c_notsend > 0 ) if( c_notsend > 0 )
Con_Printf( S_ERROR "Too many entities in visible packet list. Ignored %d entities\n", c_notsend ); Con_Printf( S_ERROR "Too many entities in visible packet list. Ignored %d entities\n", c_notsend );
cl->ignored_ents = c_notsend; cl->ignored_ents = c_notsend;
} }
// if there were portals visible, there may be out of order entities // if there were portals visible, there may be out of order entities
// in the list which will need to be resorted for the delta compression // in the list which will need to be resorted for the delta compression
@ -809,33 +809,18 @@ void SV_UpdateToReliableMessages( void )
continue; // reliables go to all connected or spawned continue; // reliables go to all connected or spawned
if( MSG_GetNumBytesWritten( &sv.reliable_datagram ) < MSG_GetNumBytesLeft( &cl->netchan.message )) if( MSG_GetNumBytesWritten( &sv.reliable_datagram ) < MSG_GetNumBytesLeft( &cl->netchan.message ))
{
MSG_WriteBits( &cl->netchan.message, MSG_GetBuf( &sv.reliable_datagram ), MSG_GetNumBitsWritten( &sv.reliable_datagram )); MSG_WriteBits( &cl->netchan.message, MSG_GetBuf( &sv.reliable_datagram ), MSG_GetNumBitsWritten( &sv.reliable_datagram ));
} else Netchan_CreateFragments( &cl->netchan, &sv.reliable_datagram );
else
{
Netchan_CreateFragments( &cl->netchan, &sv.reliable_datagram );
}
if( MSG_GetNumBytesWritten( &sv.datagram ) < MSG_GetNumBytesLeft( &cl->datagram )) if( MSG_GetNumBytesWritten( &sv.datagram ) < MSG_GetNumBytesLeft( &cl->datagram ))
{
MSG_WriteBits( &cl->datagram, MSG_GetBuf( &sv.datagram ), MSG_GetNumBitsWritten( &sv.datagram )); MSG_WriteBits( &cl->datagram, MSG_GetBuf( &sv.datagram ), MSG_GetNumBitsWritten( &sv.datagram ));
} else Con_DPrintf( S_WARN "Ignoring unreliable datagram for %s, would overflow\n", cl->name );
else
{
Con_DPrintf( S_WARN "Ignoring unreliable datagram for %s, would overflow\n", cl->name );
}
if( FBitSet( cl->flags, FCL_HLTV_PROXY )) if( FBitSet( cl->flags, FCL_HLTV_PROXY ))
{ {
if( MSG_GetNumBytesWritten( &sv.spec_datagram ) < MSG_GetNumBytesLeft( &cl->datagram )) if( MSG_GetNumBytesWritten( &sv.spec_datagram ) < MSG_GetNumBytesLeft( &cl->datagram ))
{
MSG_WriteBits( &cl->datagram, MSG_GetBuf( &sv.spec_datagram ), MSG_GetNumBitsWritten( &sv.spec_datagram )); MSG_WriteBits( &cl->datagram, MSG_GetBuf( &sv.spec_datagram ), MSG_GetNumBitsWritten( &sv.spec_datagram ));
} else Con_DPrintf( S_WARN "Ignoring spectator datagram for %s, would overflow\n", cl->name );
else
{
Con_DPrintf( S_WARN "Ignoring spectator datagram for %s, would overflow\n", cl->name );
}
} }
} }

View File

@ -752,18 +752,18 @@ Create entity patch for selected map
*/ */
void SV_WriteEntityPatch( const char *filename ) void SV_WriteEntityPatch( const char *filename )
{ {
int ver = -1, lumpofs = 0, lumplen = 0; int lumpofs = 0, lumplen = 0;
byte buf[MAX_SYSPATH]; // 1 kb byte buf[MAX_TOKEN]; // 1 kb
string bspfilename; string bspfilename;
dheader_t *header; dheader_t *header;
file_t *f; file_t *f;
Q_strncpy( bspfilename, va( "maps/%s.bsp", filename ), sizeof( bspfilename )); Q_strncpy( bspfilename, va( "maps/%s.bsp", filename ), sizeof( bspfilename ));
f = FS_Open( bspfilename, "rb", false ); f = FS_Open( bspfilename, "rb", false );
if( !f ) return; if( !f ) return;
memset( buf, 0, MAX_SYSPATH ); memset( buf, 0, MAX_TOKEN );
FS_Read( f, buf, MAX_SYSPATH ); FS_Read( f, buf, MAX_TOKEN );
header = (dheader_t *)buf; header = (dheader_t *)buf;
// check all the lumps and some other errors // check all the lumps and some other errors
@ -801,9 +801,9 @@ pfnMapIsValid use this
static char *SV_ReadEntityScript( const char *filename, int *flags ) static char *SV_ReadEntityScript( const char *filename, int *flags )
{ {
string bspfilename, entfilename; string bspfilename, entfilename;
int ver = -1, lumpofs = 0, lumplen = 0; int lumpofs = 0, lumplen = 0;
byte buf[MAX_TOKEN];
char *ents = NULL; char *ents = NULL;
byte buf[1024];
dheader_t *header; dheader_t *header;
size_t ft1, ft2; size_t ft1, ft2;
file_t *f; file_t *f;
@ -815,8 +815,8 @@ static char *SV_ReadEntityScript( const char *filename, int *flags )
if( !f ) return NULL; if( !f ) return NULL;
SetBits( *flags, MAP_IS_EXIST ); SetBits( *flags, MAP_IS_EXIST );
memset( buf, 0, MAX_SYSPATH ); memset( buf, 0, MAX_TOKEN );
FS_Read( f, buf, MAX_SYSPATH ); FS_Read( f, buf, MAX_TOKEN );
header = (dheader_t *)buf; header = (dheader_t *)buf;
// check all the lumps and some other errors // check all the lumps and some other errors
@ -834,7 +834,7 @@ static char *SV_ReadEntityScript( const char *filename, int *flags )
// check for entfile too // check for entfile too
Q_strncpy( entfilename, va( "maps/%s.ent", filename ), sizeof( entfilename )); Q_strncpy( entfilename, va( "maps/%s.ent", filename ), sizeof( entfilename ));
// make sure what entity patch is never than bsp // make sure what entity patch is newer than bsp
ft1 = FS_FileTime( bspfilename, false ); ft1 = FS_FileTime( bspfilename, false );
ft2 = FS_FileTime( entfilename, true ); ft2 = FS_FileTime( entfilename, true );
@ -875,7 +875,7 @@ int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *l
if( ents ) if( ents )
{ {
qboolean need_landmark = Q_strlen( landmark_name ) > 0 ? true : false; qboolean need_landmark = Q_strlen( landmark_name ) > 0 ? true : false;
char token[2048]; char token[MAX_TOKEN];
string check_name; string check_name;
// g-cont. in-dev mode we can entering on map even without "info_player_start" // g-cont. in-dev mode we can entering on map even without "info_player_start"
@ -1280,6 +1280,7 @@ pfnSetModel
void pfnSetModel( edict_t *e, const char *m ) void pfnSetModel( edict_t *e, const char *m )
{ {
char name[MAX_QPATH]; char name[MAX_QPATH];
qboolean found = false;
model_t *mod; model_t *mod;
int i; int i;
@ -1296,10 +1297,13 @@ void pfnSetModel( edict_t *e, const char *m )
for( i = 1; i < MAX_MODELS && sv.model_precache[i][0]; i++ ) for( i = 1; i < MAX_MODELS && sv.model_precache[i][0]; i++ )
{ {
if( !Q_stricmp( sv.model_precache[i], name )) if( !Q_stricmp( sv.model_precache[i], name ))
{
found = true;
break; break;
}
} }
if( i == MAX_MODELS ) if( !found )
{ {
Con_Printf( S_ERROR "no precache: %s\n", name ); Con_Printf( S_ERROR "no precache: %s\n", name );
return; return;
@ -2780,7 +2784,7 @@ void pfnWriteString( const char *src )
{ {
static char string[MAX_USERMSG_LENGTH]; static char string[MAX_USERMSG_LENGTH];
int len = Q_strlen( src ) + 1; int len = Q_strlen( src ) + 1;
int rem = rem = sizeof( string ) - 1; int rem = sizeof( string ) - 1;
char *dst; char *dst;
if( len == 1 ) if( len == 1 )

View File

@ -135,7 +135,6 @@ int SV_SoundIndex( const char *filename )
char name[MAX_QPATH]; char name[MAX_QPATH];
int i; int i;
// don't precache sentence names!
if( !COM_CheckString( filename )) if( !COM_CheckString( filename ))
return 0; return 0;
@ -263,7 +262,7 @@ int SV_GenericIndex( const char *filename )
================ ================
SV_ModelHandle SV_ModelHandle
register unique model for a server and client get model by handle
================ ================
*/ */
model_t *SV_ModelHandle( int modelindex ) model_t *SV_ModelHandle( int modelindex )
@ -273,6 +272,13 @@ model_t *SV_ModelHandle( int modelindex )
return sv.models[modelindex]; return sv.models[modelindex];
} }
/*
================
SV_CreateGenericResources
loads external resource list
================
*/
void SV_CreateGenericResources( void ) void SV_CreateGenericResources( void )
{ {
string filename, token; string filename, token;
@ -303,6 +309,13 @@ void SV_CreateGenericResources( void )
Mem_Free( afile ); Mem_Free( afile );
} }
/*
================
SV_CreateResourceList
add resources to common list
================
*/
void SV_CreateResourceList( void ) void SV_CreateResourceList( void )
{ {
qboolean ffirstsent = false; qboolean ffirstsent = false;

View File

@ -260,6 +260,13 @@ void SV_CheckCmdTimes( void )
} }
} }
/*
=================
SV_ProcessFile
process incoming file (customization)
=================
*/
void SV_ProcessFile( sv_client_t *cl, const char *filename ) void SV_ProcessFile( sv_client_t *cl, const char *filename )
{ {
customization_t *pList; customization_t *pList;
@ -548,11 +555,6 @@ qboolean SV_IsSimulating( void )
return false; return false;
} }
/*
=================
SV_RunGameFrame
=================
*/
/* /*
================= =================
SV_RunGameFrame SV_RunGameFrame
@ -874,7 +876,7 @@ to totally exit after returning from this function.
*/ */
void SV_FinalMessage( const char *message, qboolean reconnect ) void SV_FinalMessage( const char *message, qboolean reconnect )
{ {
byte msg_buf[64]; byte msg_buf[1024];
sv_client_t *cl; sv_client_t *cl;
sizebuf_t msg; sizebuf_t msg;
int i; int i;

View File

@ -304,7 +304,7 @@ void SV_AddLaddersToPmove( areanode_t *node, const vec3_t pmove_mins, const vec3
model_t *mod; model_t *mod;
physent_t *pe; physent_t *pe;
// get water edicts // get ladder edicts
for( l = node->solid_edicts.next; l != &node->solid_edicts; l = next ) for( l = node->solid_edicts.next; l != &node->solid_edicts; l = next )
{ {
next = l->next; next = l->next;
@ -760,11 +760,11 @@ static void SV_FinishPMove( playermove_t *pmove, sv_client_t *cl )
if( pmove->onground == -1 ) if( pmove->onground == -1 )
{ {
clent->v.flags &= ~FL_ONGROUND; ClearBits( clent->v.flags, FL_ONGROUND );
} }
else if( pmove->onground >= 0 && pmove->onground < pmove->numphysent ) else if( pmove->onground >= 0 && pmove->onground < pmove->numphysent )
{ {
clent->v.flags |= FL_ONGROUND; SetBits( clent->v.flags, FL_ONGROUND );
clent->v.groundentity = EDICT_NUM( pmove->physents[pmove->onground].info ); clent->v.groundentity = EDICT_NUM( pmove->physents[pmove->onground].info );
} }
@ -885,10 +885,7 @@ void SV_SetupMoveInterpolant( sv_client_t *cl )
if( SV_UnlagCheckTeleport( state->origin, lerp->finalpos )) if( SV_UnlagCheckTeleport( state->origin, lerp->finalpos ))
lerp->nointerp = true; lerp->nointerp = true;
} }
else else lerp->firstframe = true;
{
lerp->firstframe = true;
}
VectorCopy( state->origin, lerp->finalpos ); VectorCopy( state->origin, lerp->finalpos );
} }
@ -986,10 +983,10 @@ void SV_RestoreMoveInterpolant( sv_client_t *cl )
oldlerp = &svgame.interp[i]; oldlerp = &svgame.interp[i];
if( VectorCompare( oldlerp->oldpos, oldlerp->newpos ) || !oldlerp->moving ) if( VectorCompareEpsilon( oldlerp->oldpos, oldlerp->newpos, ON_EPSILON ))
continue; // they didn't actually move. continue; // they didn't actually move.
if( !oldlerp->active ) if( !oldlerp->moving || !oldlerp->active )
continue; continue;
if( VectorCompare( oldlerp->curpos, check->edict->v.origin )) if( VectorCompare( oldlerp->curpos, check->edict->v.origin ))
@ -1039,9 +1036,7 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed )
} }
if( !FBitSet( cl->flags, FCL_FAKECLIENT )) if( !FBitSet( cl->flags, FCL_FAKECLIENT ))
{
SV_SetupMoveInterpolant( cl ); SV_SetupMoveInterpolant( cl );
}
svgame.dllFuncs.pfnCmdStart( cl->edict, ucmd, random_seed ); svgame.dllFuncs.pfnCmdStart( cl->edict, ucmd, random_seed );

View File

@ -1113,6 +1113,7 @@ or custom physics implementation
*/ */
void SV_CustomClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, trace_t *trace ) void SV_CustomClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, trace_t *trace )
{ {
// initialize custom trace
memset( trace, 0, sizeof( trace_t )); memset( trace, 0, sizeof( trace_t ));
VectorCopy( end, trace->endpos ); VectorCopy( end, trace->endpos );
trace->allsolid = true; trace->allsolid = true;
@ -1256,7 +1257,7 @@ static void SV_ClipToLinks( areanode_t *node, moveclip_t *clip )
if( !SV_ClipToEntity( touch, clip )) if( !SV_ClipToEntity( touch, clip ))
return; // trace.allsoild return; // trace.allsoild
} }
// recurse down both sides // recurse down both sides
if( node->axis == -1 ) return; if( node->axis == -1 ) return;
@ -1288,7 +1289,7 @@ static void SV_ClipToPortals( areanode_t *node, moveclip_t *clip )
if( !SV_ClipToEntity( touch, clip )) if( !SV_ClipToEntity( touch, clip ))
return; // trace.allsoild return; // trace.allsoild
} }
// recurse down both sides // recurse down both sides
if( node->axis == -1 ) return; if( node->axis == -1 ) return;