22 Apr 2011

This commit is contained in:
g-cont 2011-04-22 00:00:00 +04:00 committed by Alibek Omarov
parent 98a6e67ffd
commit 3efa573411
9 changed files with 47 additions and 42 deletions

View File

@ -1865,7 +1865,7 @@ client_textmessage_t *CL_TextMessageGet( const char *pName )
// find desired message
for( i = 0; i < clgame.numTitles; i++ )
{
if( !Q_strcmp( pName, clgame.titles[i].pName ))
if( !Q_stricmp( pName, clgame.titles[i].pName ))
return clgame.titles + i;
}
return NULL; // found nothing

View File

@ -2397,9 +2397,9 @@ void CL_UpdateFlashlight( cl_entity_t *pEnt )
falloff *= falloff;
// update flashlight endpos
dl = CL_AllocDlight( cl.playernum + 1 );
dl = CL_AllocDlight( pEnt->index );
VectorCopy( trace.endpos, dl->origin );
dl->die = cl.time; // die on next frame
dl->die = cl.time + 0.01f; // die on next frame
dl->color.r = 255 * falloff;
dl->color.g = 255 * falloff;
dl->color.b = 255 * falloff;

View File

@ -418,6 +418,8 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
channel_t *target_chan, *check;
int vol, ch_idx;
if( pitch <= 1 ) pitch = PITCH_NORM; // Invasion issues
if( !dma.initialized ) return;
sfx = S_GetSfxByHandle( handle );
if( !sfx ) return;

View File

@ -331,6 +331,7 @@ typedef struct
// used to check late spawns
sv_client_t *clients; // [sv_maxclients->integer]
sv_client_t *currentPlayer; // current client who network message sending on
int currentPlayerNum; // for esay acess to some global arrays
int num_client_entities; // sv_maxclients->integer*UPDATE_BACKUP*MAX_PACKET_ENTITIES
int next_client_entities; // next client_entity to use
entity_state_t *packet_entities; // [num_client_entities]

View File

@ -196,7 +196,8 @@ gotnewcl:
Q_strncpy( newcl->physinfo, physinfo, sizeof( physinfo ));
svs.currentPlayer = newcl;
edictnum = (newcl - svs.clients) + 1;
svs.currentPlayerNum = (newcl - svs.clients);
edictnum = svs.currentPlayerNum + 1;
ent = EDICT_NUM( edictnum );
newcl->edict = ent;
@ -292,7 +293,8 @@ edict_t *SV_FakeConnect( const char *netname )
// this is the only place a sv_client_t is ever initialized
*newcl = temp;
svs.currentPlayer = newcl;
edictnum = (newcl - svs.clients) + 1;
svs.currentPlayerNum = (newcl - svs.clients);
edictnum = svs.currentPlayerNum + 1;
if( newcl->frames )
Mem_Free( newcl->frames ); // fakeclients doesn't have frames
@ -1693,6 +1695,8 @@ void SV_ExecuteClientCommand( sv_client_t *cl, char *s )
ucmd_t *u;
svs.currentPlayer = cl;
svs.currentPlayerNum = (cl - svs.clients);
Cmd_TokenizeString( s );
for( u = ucmds; u->name; u++ )

View File

@ -148,6 +148,7 @@ qboolean SV_SetPlayer( void )
{
// special case for local client
svs.currentPlayer = svs.clients;
svs.currentPlayerNum = 0;
return true;
}
@ -164,6 +165,8 @@ qboolean SV_SetPlayer( void )
}
svs.currentPlayer = &svs.clients[idnum];
svs.currentPlayerNum = idnum;
if( !svs.currentPlayer->state )
{
Msg( "Client %i is not active\n", idnum );
@ -179,12 +182,14 @@ qboolean SV_SetPlayer( void )
if( !Q_strcmp( cl->name, s ))
{
svs.currentPlayer = cl;
svs.currentPlayerNum = (cl - svs.clients);
return true;
}
}
Msg( "Userid %s is not on the server\n", s );
svs.currentPlayer = NULL;
svs.currentPlayerNum = 0;
return false;
}

View File

@ -503,6 +503,7 @@ void SV_SendClientDatagram( sv_client_t *cl )
sizebuf_t msg;
svs.currentPlayer = cl;
svs.currentPlayerNum = (cl - svs.clients);
BF_Init( &msg, "Datagram", msg_buf, sizeof( msg_buf ));
@ -617,6 +618,7 @@ void SV_SendClientMessages( void )
int i;
svs.currentPlayer = NULL;
svs.currentPlayerNum = 0;
if( sv.state == ss_dead )
return;
@ -703,6 +705,7 @@ void SV_SendClientMessages( void )
// reset current client
svs.currentPlayer = NULL;
svs.currentPlayerNum = 0;
}
/*

View File

@ -14,8 +14,8 @@
#define DEBUG_NEW_CLIENTPVS_CHECK
// fatpvs stuff
static byte fatpvs[MAX_MAP_LEAFS/8];
static byte fatphs[MAX_MAP_LEAFS/8];
static byte fatpvs[MAX_CLIENTS][MAX_MAP_LEAFS/8];
static byte fatphs[MAX_CLIENTS][MAX_MAP_LEAFS/8];
static byte *bitvector;
static int fatbytes;
@ -215,14 +215,12 @@ MSG_PHS send to clients potentially hearable from org
*/
qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
{
byte *mask = NULL;
int j, numclients = sv_maxclients->integer;
sv_client_t *cl, *current = svs.clients;
qboolean reliable = false;
qboolean specproxy = false;
float *viewOrg = NULL;
qboolean use_mask = false;
int numsends = 0;
mleaf_t *leaf;
switch( dest )
{
@ -246,16 +244,14 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
// intentional fallthrough
case MSG_PAS:
if( origin == NULL ) return false;
leaf = Mod_PointInLeaf( origin, sv.worldmodel->nodes );
mask = Mod_LeafPHS( leaf, sv.worldmodel );
use_mask = true;
break;
case MSG_PVS_R:
reliable = true;
// intentional fallthrough
case MSG_PVS:
if( origin == NULL ) return false;
leaf = Mod_PointInLeaf( origin, sv.worldmodel->nodes );
mask = Mod_LeafPVS( leaf, sv.worldmodel );
use_mask = true;
break;
case MSG_ONE:
reliable = true;
@ -296,34 +292,24 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
continue;
}
// simple PAS checking in singleplayer (QW legacy)
if( sv_maxclients->integer == 1 && ( dest == MSG_PAS_R || dest == MSG_PAS ))
if( use_mask )
{
vec3_t delta;
if( SV_IsValidEdict( cl->pViewEntity ))
viewOrg = cl->pViewEntity->v.origin;
else viewOrg = cl->edict->v.origin;
VectorSubtract( origin, viewOrg, delta );
if( VectorLength( delta ) <= 1534.0f )
goto inrange;
}
if( mask )
{
int leafnum;
if( SV_IsValidEdict( cl->pViewEntity ))
viewOrg = cl->pViewEntity->v.origin;
else viewOrg = cl->edict->v.origin;
int leafnum, clientnum;
byte *mask;
// -1 is because pvs rows are 1 based, not 0 based like leafs
leafnum = Mod_PointLeafnum( viewOrg ) - 1;
if( mask && (!(mask[leafnum>>3] & (1<<( leafnum & 7 )))))
leafnum = Mod_PointLeafnum( origin ) - 1;
clientnum = cl - svs.clients;
if( dest == MSG_PAS_R || dest == MSG_PAS )
mask = fatphs[clientnum];
else if( dest == MSG_PVS_R || dest == MSG_PVS )
mask = fatpvs[clientnum];
if( !(mask[leafnum>>3] & (1<<( leafnum & 7 ))))
continue;
}
inrange:
if( specproxy ) BF_WriteBits( &sv.spectator_datagram, BF_GetData( &sv.multicast ), BF_GetNumBitsWritten( &sv.multicast ));
else if( reliable ) BF_WriteBits( &cl->netchan.message, BF_GetData( &sv.multicast ), BF_GetNumBitsWritten( &sv.multicast ));
else BF_WriteBits( &cl->datagram, BF_GetData( &sv.multicast ), BF_GetNumBitsWritten( &sv.multicast ));
@ -3595,7 +3581,9 @@ byte *pfnSetFatPVS( const float *org )
if( !sv.worldmodel->visdata || sv_novis->integer || !org )
return Mod_DecompressVis( NULL );
bitvector = fatpvs;
ASSERT( svs.currentPlayerNum >= 0 && svs.currentPlayerNum < MAX_CLIENTS );
bitvector = fatpvs[svs.currentPlayerNum];
fatbytes = (sv.worldmodel->numleafs+31)>>3;
if(!( sv.hostflags & SVF_PORTALPASS ))
Q_memset( bitvector, 0, fatbytes );
@ -3617,7 +3605,9 @@ byte *pfnSetFatPAS( const float *org )
if( !sv.worldmodel->visdata || sv_novis->integer || !org )
return Mod_DecompressVis( NULL );
bitvector = fatphs;
ASSERT( svs.currentPlayerNum >= 0 && svs.currentPlayerNum < MAX_CLIENTS );
bitvector = fatphs[svs.currentPlayerNum];
fatbytes = (sv.worldmodel->numleafs+31)>>3;
if(!( sv.hostflags & SVF_PORTALPASS ))
Q_memset( bitvector, 0, fatbytes );

View File

@ -1119,7 +1119,7 @@ static void SV_ClipToLinks( areanode_t *node, moveclip_t *clip )
// never collide items and player (because call "give" always stuck item in player
// and total trace returns fail (old half-life bug)
// items touch should be done in SV_TouchLinks not here
if( touch->v.flags & ( FL_CLIENT|FL_FAKECLIENT|FL_MONSTER ))
if( touch->v.flags & ( FL_CLIENT|FL_FAKECLIENT ))
continue;
}
@ -1247,7 +1247,7 @@ trace_t SV_MoveHull( const vec3_t start, int hullNumber, const vec3_t end, int t
clip.type = (type & 0xFF);
clip.flags = (type & 0xFF00);
clip.passedict = e;
clip.hull = hullNumber = bound( 0, hullNumber, 3 );
clip.hull = bound( 0, hullNumber, 3 );
clip.mins = sv.worldmodel->hulls[clip.hull].clip_mins;
clip.maxs = sv.worldmodel->hulls[clip.hull].clip_maxs;
clip.flags |= FMOVE_SIMPLEBOX; // completely ignore hitboxes, trace hulls only