28 Feb 2017

This commit is contained in:
g-cont 2017-02-28 00:00:00 +03:00 committed by Alibek Omarov
parent d89c3c956c
commit 6e5939c6be
14 changed files with 249 additions and 278 deletions

View File

@ -3624,26 +3624,26 @@ static efx_api_t gEfxApi =
{ {
R_AllocParticle, R_AllocParticle,
CL_BlobExplosion, CL_BlobExplosion,
CL_Blood, R_Blood,
CL_BloodSprite, CL_BloodSprite,
CL_BloodStream, R_BloodStream,
CL_BreakModel, CL_BreakModel,
CL_Bubbles, CL_Bubbles,
CL_BubbleTrail, CL_BubbleTrail,
R_BulletImpactParticles, R_BulletImpactParticles,
CL_EntityParticles, R_EntityParticles,
CL_Explosion, CL_Explosion,
CL_FizzEffect, CL_FizzEffect,
CL_FireField, CL_FireField,
R_FlickerParticles, R_FlickerParticles,
CL_FunnelSprite, R_FunnelSprite,
R_Implosion, R_Implosion,
CL_Large_Funnel, R_LargeFunnel,
CL_LavaSplash, R_LavaSplash,
CL_MultiGunshot, CL_MultiGunshot,
CL_MuzzleFlash, CL_MuzzleFlash,
R_ParticleBox, R_ParticleBox,
CL_ParticleBurst, R_ParticleBurst,
CL_ParticleExplosion, CL_ParticleExplosion,
CL_ParticleExplosion2, CL_ParticleExplosion2,
R_ParticleLine, R_ParticleLine,
@ -3668,7 +3668,7 @@ static efx_api_t gEfxApi =
R_TracerEffect, R_TracerEffect,
R_UserTracerParticle, R_UserTracerParticle,
R_TracerParticles, R_TracerParticles,
CL_TeleportSplash, R_TeleportSplash,
CL_TempSphereModel, CL_TempSphereModel,
CL_TempModel, CL_TempModel,
CL_DefaultSprite, CL_DefaultSprite,

View File

@ -265,7 +265,7 @@ void NetGraph_DrawTextFields( int x, int y, int count, float avg, int packet_los
rgba_t colors = { 0.9 * 255, 0.9 * 255, 0.7 * 255, 255 }; rgba_t colors = { 0.9 * 255, 0.9 * 255, 0.7 * 255, 255 };
int i = ( cls.netchan.outgoing_sequence - 1 ) & NET_TIMINGS_MASK; int i = ( cls.netchan.outgoing_sequence - 1 ) & NET_TIMINGS_MASK;
float latency = count > 0 ? Q_max( 0, avg / count - 0.5 * host.frametime - 1000.0 / cl_updaterate->value ) : 0; float latency = count > 0 ? Q_max( 0, avg / count - 0.5 * host.frametime - 1000.0 / cl_updaterate->value ) : 0;
float framerate = 1.0 / host.realframetime; float framerate = 1.0 / host.frametime;
Con_DrawString( x, y - net_graphheight->value, va( "%.1f fps" , framerate ), colors ); Con_DrawString( x, y - net_graphheight->value, va( "%.1f fps" , framerate ), colors );
Con_DrawString( x + 75, y - net_graphheight->value, va( "%i ms" , (int)latency ), colors ); Con_DrawString( x + 75, y - net_graphheight->value, va( "%i ms" , (int)latency ), colors );

View File

@ -1456,107 +1456,72 @@ void CL_Sprite_Trail( int type, const vec3_t vecStart, const vec3_t vecEnd, int
/* /*
=============== ===============
CL_Large_Funnel R_FunnelSprite
Create a funnel effect (particles only)
===============
*/
void CL_Large_Funnel( const vec3_t pos, int flags )
{
CL_FunnelSprite( pos, 0, flags );
}
/*
===============
CL_FunnelSprite
Create a funnel effect with custom sprite Create a funnel effect with custom sprite
=============== ===============
*/ */
void CL_FunnelSprite( const vec3_t pos, int spriteIndex, int flags ) void R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
{ {
TEMPENTITY *pTemp = NULL; TEMPENTITY *pTemp;
particle_t *pPart = NULL; model_t *model;
vec3_t dir, dest; vec3_t dir, dest;
vec3_t m_vecPos; float dist, vel;
float flDist, life, vel; int i, j, frameCount;
int i, j, colorIndex;
colorIndex = R_LookupColor( 0, 255, 0 ); // green color if( !modelIndex )
for( i = -256; i <= 256; i += 32 )
{ {
for( j = -256; j <= 256; j += 32 ) MsgDev( D_ERROR, "no modelindex for funnel!\n" );
return;
}
model = Mod_Handle( modelIndex );
if( !model )
{
MsgDev( D_ERROR, "No model %d!\n", modelIndex );
return;
}
frameCount = Mod_FrameCount( model );
for( i = -8; i < 8; i++ )
{
for( j = -8; j < 8; j++ )
{ {
if( flags & SF_FUNNEL_REVERSE ) pTemp = CL_TempEntAlloc( org, model );
if( !pTemp ) return;
dest[0] = (i * 32.0f) + org[0];
dest[1] = (j * 32.0f) + org[1];
dest[2] = org[2] + COM_RandomFloat( 100.0f, 800.0f );
if( reverse )
{ {
VectorCopy( pos, m_vecPos ); VectorCopy( org, pTemp->entity.origin );
VectorSubtract( dest, pTemp->entity.origin, dir );
dest[0] = pos[0] + i;
dest[1] = pos[1] + j;
dest[2] = pos[2] + COM_RandomFloat( 100, 800 );
// send particle heading to dest at a random speed
VectorSubtract( dest, m_vecPos, dir );
// velocity based on how far particle has to travel away from org
vel = dest[2] / 8;
} }
else else
{ {
m_vecPos[0] = pos[0] + i; VectorCopy( dest, pTemp->entity.origin );
m_vecPos[1] = pos[1] + j; VectorSubtract( org, pTemp->entity.origin, dir );
m_vecPos[2] = pos[2] + COM_RandomFloat( 100, 800 );
// send particle heading to org at a random speed
VectorSubtract( pos, m_vecPos, dir );
// velocity based on how far particle starts from org
vel = m_vecPos[2] / 8;
} }
if( pPart && spriteIndex && CL_PointContents( m_vecPos ) == CONTENTS_EMPTY ) pTemp->entity.curstate.rendermode = kRenderGlow;
{ pTemp->entity.curstate.renderfx = kRenderFxNoDissipation;
pTemp = CL_TempEntAlloc( pos, Mod_Handle( spriteIndex )); pTemp->entity.baseline.renderamt = pTemp->entity.curstate.renderamt = 200;
pPart = NULL; pTemp->entity.baseline.angles[2] = COM_RandomFloat( -100.0f, 100.0f );
} pTemp->entity.curstate.framerate = COM_RandomFloat( 0.1f, 0.4f );
else pTemp->flags = FTENT_ROTATE|FTENT_FADEOUT;
{ pTemp->entity.curstate.framerate = 10;
pPart = R_AllocParticle( NULL ); pTemp->frameMax = frameCount;
pTemp = NULL;
}
if( pTemp || pPart ) vel = dest[2] / 8.0f;
{ if( vel < 64.0f ) vel = 64.0f;
flDist = VectorNormalizeLength( dir ); // save the distance dist = VectorNormalizeLength( dir );
if( vel < 64 ) vel = 64; vel += COM_RandomFloat( 64.0f, 128.0f );
VectorScale( dir, vel, pTemp->entity.baseline.origin );
vel += COM_RandomFloat( 64, 128 ); pTemp->die = cl.time + (dist / vel) - 0.5f;
life = ( flDist / vel ); pTemp->fadeSpeed = 2.0f;
if( pTemp )
{
VectorCopy( m_vecPos, pTemp->entity.origin );
VectorScale( dir, vel, pTemp->entity.baseline.origin );
pTemp->entity.curstate.rendermode = kRenderTransAdd;
pTemp->flags |= FTENT_FADEOUT;
pTemp->fadeSpeed = 3.0f;
pTemp->die = cl.time + life - COM_RandomFloat( 0.5f, 0.6f );
pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt = 255;
pTemp->entity.curstate.scale = 0.75f;
}
if( pPart )
{
VectorCopy( m_vecPos, pPart->org );
pPart->color = colorIndex;
pPart->type = pt_static;
VectorScale( dir, vel, pPart->vel );
// die right when you get there
pPart->die += life;
}
}
} }
} }
} }
@ -1822,7 +1787,7 @@ void CL_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_t noise, in
VectorVectors( dir, right, up ); VectorVectors( dir, right, up );
VectorCopy( org, vecSrc ); VectorCopy( org, vecSrc );
for( i = 1; i <= count; i++ ) for( i = 0; i < count; i++ )
{ {
// get circular gaussian spread // get circular gaussian spread
float x, y, z; float x, y, z;
@ -1834,17 +1799,20 @@ void CL_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_t noise, in
for( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
{ {
vecDir[j] = dir[i] + x * noise[0] * right[j] + y * noise[1] * up[j]; vecDir[j] = dir[j] + x * noise[0] * right[j] + y * noise[1] * up[j];
vecEnd[j] = vecSrc[j] + 2048.0f * vecDir[j]; vecEnd[j] = vecSrc[j] + 4096.0f * vecDir[j];
} }
trace = CL_TraceLine( vecSrc, vecEnd, PM_STUDIO_BOX ); trace = CL_TraceLine( vecSrc, vecEnd, PM_STUDIO_IGNORE );
// paint decals // paint decals
if( trace.fraction != 1.0f ) if( trace.fraction != 1.0f )
{ {
physent_t *pe = NULL; physent_t *pe = NULL;
if( i & 2 ) CL_RicochetSound( trace.endpos );
R_BulletImpactParticles( trace.endpos );
if( trace.ent >= 0 && trace.ent < clgame.pmove->numphysent ) if( trace.ent >= 0 && trace.ent < clgame.pmove->numphysent )
pe = &clgame.pmove->physents[trace.ent]; pe = &clgame.pmove->physents[trace.ent];
@ -1977,13 +1945,13 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
pos[1] = MSG_ReadCoord( &buf ); pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf ); pos[2] = MSG_ReadCoord( &buf );
CL_LavaSplash( pos ); R_LavaSplash( pos );
break; break;
case TE_TELEPORT: case TE_TELEPORT:
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
pos[1] = MSG_ReadCoord( &buf ); pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf ); pos[2] = MSG_ReadCoord( &buf );
CL_TeleportSplash( pos ); R_TeleportSplash( pos );
break; break;
case TE_EXPLOSION2: case TE_EXPLOSION2:
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
@ -2124,7 +2092,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[2] = MSG_ReadCoord( &buf ); pos[2] = MSG_ReadCoord( &buf );
modelIndex = MSG_ReadShort( &buf ); modelIndex = MSG_ReadShort( &buf );
flags = MSG_ReadShort( &buf ); flags = MSG_ReadShort( &buf );
CL_FunnelSprite( pos, modelIndex, flags ); R_LargeFunnel( pos, flags );
R_FunnelSprite( pos, modelIndex, flags );
break; break;
case TE_BLOODSTREAM: case TE_BLOODSTREAM:
case TE_BLOOD: case TE_BLOOD:
@ -2136,8 +2105,8 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos2[2] = MSG_ReadCoord( &buf ); pos2[2] = MSG_ReadCoord( &buf );
color = MSG_ReadByte( &buf ); color = MSG_ReadByte( &buf );
vel = (float)MSG_ReadByte( &buf ); vel = (float)MSG_ReadByte( &buf );
if( type == TE_BLOOD ) CL_Blood( pos, pos2, color, vel ); if( type == TE_BLOOD ) R_Blood( pos, pos2, color, vel );
else CL_BloodStream( pos, pos2, color, vel ); else R_BloodStream( pos, pos2, color, vel );
break; break;
case TE_SHOWLINE: case TE_SHOWLINE:
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
@ -2311,7 +2280,7 @@ void CL_ParseTempEntity( sizebuf_t *msg )
scale = (float)MSG_ReadShort( &buf ); scale = (float)MSG_ReadShort( &buf );
color = MSG_ReadByte( &buf ); color = MSG_ReadByte( &buf );
life = (float)(MSG_ReadByte( &buf ) * 0.1f); life = (float)(MSG_ReadByte( &buf ) * 0.1f);
CL_ParticleBurst( pos, scale, color, life ); R_ParticleBurst( pos, scale, color, life );
break; break;
case TE_FIREFIELD: case TE_FIREFIELD:
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
@ -2339,9 +2308,9 @@ void CL_ParseTempEntity( sizebuf_t *msg )
pos[0] = MSG_ReadCoord( &buf ); pos[0] = MSG_ReadCoord( &buf );
pos[1] = MSG_ReadCoord( &buf ); pos[1] = MSG_ReadCoord( &buf );
pos[2] = MSG_ReadCoord( &buf ); pos[2] = MSG_ReadCoord( &buf );
pos2[0] = MSG_ReadCoord( &buf ); pos2[0] = MSG_ReadCoord( &buf ) * 0.1f;
pos2[1] = MSG_ReadCoord( &buf ); pos2[1] = MSG_ReadCoord( &buf ) * 0.1f;
pos2[2] = MSG_ReadCoord( &buf ); pos2[2] = MSG_ReadCoord( &buf ) * 0.1f;
ang[0] = MSG_ReadCoord( &buf ) * 0.01f; ang[0] = MSG_ReadCoord( &buf ) * 0.01f;
ang[1] = MSG_ReadCoord( &buf ) * 0.01f; ang[1] = MSG_ReadCoord( &buf ) * 0.01f;
ang[2] = 0.0f; ang[2] = 0.0f;
@ -2651,7 +2620,7 @@ void CL_AddEntityEffects( cl_entity_t *ent )
{ {
// yellow flies effect 'monster stuck in the wall' // yellow flies effect 'monster stuck in the wall'
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD )) if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ))
CL_EntityParticles( ent ); R_EntityParticles( ent );
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT )) if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
{ {

View File

@ -22,15 +22,15 @@ void CL_Explosion( vec3_t pos, int model, float scale, float framerate, int flag
void CL_ParticleExplosion( const vec3_t org ); void CL_ParticleExplosion( const vec3_t org );
void CL_ParticleExplosion2( const vec3_t org, int colorStart, int colorLength ); void CL_ParticleExplosion2( const vec3_t org, int colorStart, int colorLength );
void R_Implosion( const vec3_t end, float radius, int count, float life ); void R_Implosion( const vec3_t end, float radius, int count, float life );
void CL_Blood( const vec3_t org, const vec3_t dir, int pcolor, int speed ); void R_Blood( const vec3_t org, const vec3_t dir, int pcolor, int speed );
void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed ); void R_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed );
void CL_BlobExplosion( const vec3_t org ); void CL_BlobExplosion( const vec3_t org );
void CL_EntityParticles( cl_entity_t *ent ); void R_EntityParticles( cl_entity_t *ent );
void R_FlickerParticles( const vec3_t org ); void R_FlickerParticles( const vec3_t org );
void R_RunParticleEffect( const vec3_t org, const vec3_t dir, int color, int count ); void R_RunParticleEffect( const vec3_t org, const vec3_t dir, int color, int count );
void CL_ParticleBurst( const vec3_t org, int size, int color, float life ); void R_ParticleBurst( const vec3_t org, int size, int color, float life );
void CL_LavaSplash( const vec3_t org ); void R_LavaSplash( const vec3_t org );
void CL_TeleportSplash( const vec3_t org ); void R_TeleportSplash( const vec3_t org );
void R_RocketTrail( vec3_t start, vec3_t end, int type ); void R_RocketTrail( vec3_t start, vec3_t end, int type );
short R_LookupColor( byte r, byte g, byte b ); short R_LookupColor( byte r, byte g, byte b );
void CL_GetPackedColor( short *packed, short color ); void CL_GetPackedColor( short *packed, short color );
@ -64,8 +64,8 @@ void CL_Sprite_Smoke( struct tempent_s *pTemp, float scale );
void CL_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int iRand, int renderMode ); void CL_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int iRand, int renderMode );
void CL_Sprite_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int iRand ); void CL_Sprite_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, int speed, int iRand );
void CL_Sprite_Trail( int type, const vec3_t vecStart, const vec3_t vecEnd, int modelIndex, int nCount, float flLife, float flSize, float flAmplitude, int nRenderamt, float flSpeed ); void CL_Sprite_Trail( int type, const vec3_t vecStart, const vec3_t vecEnd, int modelIndex, int nCount, float flLife, float flSize, float flAmplitude, int nRenderamt, float flSpeed );
void CL_FunnelSprite( const vec3_t pos, int spriteIndex, int flags ); void R_FunnelSprite( const vec3_t pos, int spriteIndex, int flags );
void CL_Large_Funnel( const vec3_t pos, int flags ); void R_LargeFunnel( const vec3_t pos, int reverse );
void R_SparkEffect( const vec3_t pos, int count, int velocityMin, int velocityMax ); void R_SparkEffect( const vec3_t pos, int count, int velocityMin, int velocityMax );
void R_StreakSplash( const vec3_t pos, const vec3_t dir, int color, int count, float speed, int velMin, int velMax ); void R_StreakSplash( const vec3_t pos, const vec3_t dir, int color, int count, float speed, int velMin, int velMax );
void R_SparkStreaks( const vec3_t pos, int count, int velocityMin, int velocityMax ); void R_SparkStreaks( const vec3_t pos, int count, int velocityMin, int velocityMax );

View File

@ -24,6 +24,8 @@ GNU General Public License for more details.
#include "cl_tent.h" #include "cl_tent.h"
#include "studio.h" #include "studio.h"
#define PART_SIZE 0.5f // because original particle of Quake1 was smaller than this
// particle velocities // particle velocities
static const float cl_avertexnormals[NUMVERTEXNORMALS][3] = static const float cl_avertexnormals[NUMVERTEXNORMALS][3] =
{ {
@ -356,9 +358,9 @@ void CL_DrawParticles( double frametime )
float time1 = 5.0f * frametime; float time1 = 5.0f * frametime;
float dvel = 4.0f * frametime; float dvel = 4.0f * frametime;
float grav = frametime * clgame.movevars.gravity * 0.05f; float grav = frametime * clgame.movevars.gravity * 0.05f;
float size;
vec3_t right, up; vec3_t right, up;
color24 *pColor; color24 *pColor;
float size;
if( !cl_draw_particles->value ) if( !cl_draw_particles->value )
return; return;
@ -376,19 +378,19 @@ void CL_DrawParticles( double frametime )
{ {
if( p->type != pt_blob ) if( p->type != pt_blob )
{ {
size = 1.5f; // get initial size of particle size = PART_SIZE; // get initial size of particle
// HACKHACK a scale up to keep particles from disappearing // HACKHACK a scale up to keep particles from disappearing
size += (p->org[0] - RI.vieworg[0]) * RI.vforward[0]; size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.vforward[1]; size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.vforward[2]; size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
if( size < 20.0f ) size = 1.0f; if( size < 20.0f ) size = PART_SIZE;
else size = 1.0f + size * 0.004f; else size = PART_SIZE + size * 0.004f;
// scale the axes by radius // scale the axes by radius
VectorScale( RI.vright, size, right ); VectorScale( RI.cull_vright, size, right );
VectorScale( RI.vup, size, up ); VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 ); p->color = bound( 0, p->color, 255 );
pColor = &clgame.palette[p->color]; pColor = &clgame.palette[p->color];
@ -419,45 +421,44 @@ void CL_DrawParticles( double frametime )
break; break;
case pt_fire: case pt_fire:
p->ramp += time1; p->ramp += time1;
if( p->ramp >= 6 ) p->die = -1; if( p->ramp >= 6.0f ) p->die = -1.0f;
else p->color = ramp3[(int)p->ramp]; else p->color = ramp3[(int)p->ramp];
p->vel[2] += grav; p->vel[2] += grav;
break; break;
case pt_explode: case pt_explode:
p->ramp += time2; p->ramp += time2;
if( p->ramp >= 8 ) p->die = -1; if( p->ramp >= 8.0f ) p->die = -1.0f;
else p->color = ramp1[(int)p->ramp]; else p->color = ramp1[(int)p->ramp];
VectorMA( p->vel, dvel, p->vel, p->vel ); VectorMA( p->vel, dvel, p->vel, p->vel );
p->vel[2] -= grav; p->vel[2] -= grav;
break; break;
case pt_explode2: case pt_explode2:
p->ramp += time3; p->ramp += time3;
if( p->ramp >= 8 ) p->die = -1; if( p->ramp >= 8.0f ) p->die = -1.0f;
else p->color = ramp2[(int)p->ramp]; else p->color = ramp2[(int)p->ramp];
VectorMA( p->vel, -frametime, p->vel, p->vel ); VectorMA( p->vel,-dvel, p->vel, p->vel );
p->vel[2] -= grav; p->vel[2] -= grav;
break; break;
case pt_blob: case pt_blob:
case pt_blob2: case pt_blob2:
p->ramp += time2; p->ramp += time2;
if( p->ramp >= 9 ) if( p->ramp >= 9.0f ) p->ramp = 0.0f;
p->ramp = 0;
p->color = gSparkRamp[(int)p->ramp]; p->color = gSparkRamp[(int)p->ramp];
VectorMA( p->vel, -frametime * 0.5f, p->vel, p->vel ); VectorMA( p->vel, -frametime * 0.5f, p->vel, p->vel );
p->type = COM_RandomLong( 0, 3 ) ? pt_blob : pt_blob2; p->type = COM_RandomLong( 0, 3 ) ? pt_blob : pt_blob2;
p->vel[2] -= grav * 5.0f; p->vel[2] -= grav * 5.0f;
break; break;
case pt_grav: case pt_grav:
p->vel[2] -= grav * 20; p->vel[2] -= grav * 20.0f;
break; break;
case pt_slowgrav: case pt_slowgrav:
p->vel[2] -= grav; p->vel[2] -= grav;
break; break;
case pt_vox_grav: case pt_vox_grav:
p->vel[2] -= grav * 8; p->vel[2] -= grav * 8.0f;
break; break;
case pt_vox_slowgrav: case pt_vox_slowgrav:
p->vel[2] -= grav * 4; p->vel[2] -= grav * 4.0f;
break; break;
case pt_clientcustom: case pt_clientcustom:
if( p->callback ) if( p->callback )
@ -574,8 +575,8 @@ void CL_DrawTracers( double frametime )
VectorNormalize( tmp ); VectorNormalize( tmp );
// build point along noraml line (normal is -y, x) // build point along noraml line (normal is -y, x)
VectorScale( RI.vup, tmp[0], normal ); VectorScale( RI.cull_vup, tmp[0], normal );
VectorScale( RI.vright, -tmp[1], tmp2 ); VectorScale( RI.cull_vright, -tmp[1], tmp2 );
VectorSubtract( normal, tmp2, normal ); VectorSubtract( normal, tmp2, normal );
// compute four vertexes // compute four vertexes
@ -634,12 +635,12 @@ void CL_DrawParticlesExternal( const float *vieworg, const float *forward, const
/* /*
=============== ===============
CL_EntityParticles R_EntityParticles
set EF_BRIGHTFIELD effect set EF_BRIGHTFIELD effect
=============== ===============
*/ */
void CL_EntityParticles( cl_entity_t *ent ) void R_EntityParticles( cl_entity_t *ent )
{ {
float angle; float angle;
float sr, sp, sy, cr, cp, cy; float sr, sp, sy, cr, cp, cy;
@ -661,13 +662,11 @@ void CL_EntityParticles( cl_entity_t *ent )
VectorSet( forward, cp * cy, cp * sy, -sp ); VectorSet( forward, cp * cy, cp * sy, -sp );
p->die += 0.01f; p->die = cl.time + 0.001f;
p->color = 111; // yellow
p->type = pt_explode; p->type = pt_explode;
p->color = 111; // yellow
p->org[0] = ent->origin[0] + cl_avertexnormals[i][0] * 64.0f + forward[0] * 16.0f; VectorMAMAM( 1.0f, ent->origin, 64.0f, cl_avertexnormals[i], 16.0f, forward, p->org );
p->org[1] = ent->origin[1] + cl_avertexnormals[i][1] * 64.0f + forward[1] * 16.0f;
p->org[2] = ent->origin[2] + cl_avertexnormals[i][2] * 64.0f + forward[2] * 16.0f;
} }
} }
@ -681,13 +680,7 @@ void CL_ParticleExplosion( const vec3_t org )
{ {
particle_t *p; particle_t *p;
int i, j; int i, j;
int hSound;
if( !org ) return;
hSound = S_RegisterSound( "weapons/explode3.wav" );
S_StartSound( org, 0, CHAN_AUTO, hSound, VOL_NORM, ATTN_NORM, PITCH_NORM, 0 );
for( i = 0; i < 1024; i++ ) for( i = 0; i < 1024; i++ )
{ {
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
@ -729,12 +722,6 @@ void CL_ParticleExplosion2( const vec3_t org, int colorStart, int colorLength )
int i, j; int i, j;
int colorMod = 0; int colorMod = 0;
particle_t *p; particle_t *p;
int hSound;
if( !org ) return;
hSound = S_RegisterSound( "weapons/explode3.wav" );
S_StartSound( org, 0, CHAN_AUTO, hSound, VOL_NORM, ATTN_NORM, PITCH_NORM, 0 );
for( i = 0; i < 512; i++ ) for( i = 0; i < 512; i++ )
{ {
@ -765,13 +752,7 @@ void CL_BlobExplosion( const vec3_t org )
{ {
particle_t *p; particle_t *p;
int i, j; int i, j;
int hSound;
if( !org ) return;
hSound = S_RegisterSound( "weapons/explode3.wav" );
S_StartSound( org, 0, CHAN_AUTO, hSound, VOL_NORM, ATTN_NORM, PITCH_NORM, 0 );
for( i = 0; i < 1024; i++ ) for( i = 0; i < 1024; i++ )
{ {
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
@ -814,11 +795,11 @@ PARTICLE_EFFECT on server
void R_RunParticleEffect( const vec3_t org, const vec3_t dir, int color, int count ) void R_RunParticleEffect( const vec3_t org, const vec3_t dir, int color, int count )
{ {
particle_t *p; particle_t *p;
int i, j; int i;
if( count == 1024 ) if( count == 1024 )
{ {
// Quake hack: count == 255 it's a RocketExplode // rocket explosion
CL_ParticleExplosion( org ); CL_ParticleExplosion( org );
return; return;
} }
@ -828,55 +809,59 @@ void R_RunParticleEffect( const vec3_t org, const vec3_t dir, int color, int cou
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
if( !p ) return; if( !p ) return;
p->die += 0.1f * (rand() % 5); p->color = (color & ~7) + COM_RandomLong( 0, 7 );
p->color = (color & ~7) + (rand() & 7); p->die = cl.time + COM_RandomFloat( 0.1f, 0.4f );
p->type = pt_slowgrav; p->type = pt_slowgrav;
for( j = 0; j < 3; j++ ) VectorAddScalar( org, COM_RandomFloat( -8.0f, 8.0f ), p->org );
{ VectorScale( dir, 15.0f, p->vel );
p->org[j] = org[j] + ((rand() & 15) - 8);
p->vel[j] = dir[j] * 15;
}
} }
} }
/* /*
=============== ===============
CL_Blood R_Blood
particle spray particle spray
=============== ===============
*/ */
void CL_Blood( const vec3_t org, const vec3_t dir, int pcolor, int speed ) void R_Blood( const vec3_t org, const vec3_t ndir, int pcolor, int speed )
{ {
particle_t *p; vec3_t pos, dir, vec;
int pspeed = speed * 3;
int i, j; int i, j;
particle_t *p;
for( i = 0; i < speed * 20; i++ ) VectorNormalize2( ndir, dir );
for( i = 0; i < (speed / 2); i++ )
{ {
p = R_AllocParticle( NULL ); VectorAddScalar( org, COM_RandomFloat( -3.0f, 3.0f ), pos );
if( !p ) return; VectorAddScalar( dir, COM_RandomFloat( -0.06f, 0.06f ), vec );
p->die += COM_RandomFloat( 0.1f, 0.5f ); for( j = 0; j < 7; j++ )
p->type = pt_slowgrav;
p->color = pcolor;
for( j = 0; j < 3; j++ )
{ {
p->org[j] = org[j] + COM_RandomFloat( -8.0f, 8.0f ); p = R_AllocParticle( NULL );
p->vel[j] = dir[j] * speed; if( !p ) return;
p->die = cl.time + 1.5f;
p->color = pcolor + COM_RandomLong( 0, 9 );
p->type = pt_vox_grav;
VectorAddScalar( pos, COM_RandomFloat( -1.0f, 1.0f ), p->org );
VectorScale( vec, pspeed, p->vel );
} }
} }
} }
/* /*
=============== ===============
CL_BloodStream R_BloodStream
particle spray 2 particle spray 2
=============== ===============
*/ */
void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed ) void R_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
{ {
particle_t *p; particle_t *p;
int i, j; int i, j;
@ -885,10 +870,9 @@ void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
for( arc = 0.05f, i = 0; i < 100; i++, arc -= 0.005f ) for( arc = 0.05f, i = 0; i < 100; i++, arc -= 0.005f )
{ {
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
if( !p ) return; if( !p ) return;
p->die += 2.0f; p->die = cl.time + 2.0f;
p->type = pt_vox_grav; p->type = pt_vox_grav;
p->color = pcolor + COM_RandomLong( 0, 9 ); p->color = pcolor + COM_RandomLong( 0, 9 );
@ -896,8 +880,6 @@ void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
VectorCopy( dir, p->vel ); VectorCopy( dir, p->vel );
p->vel[2] -= arc; p->vel[2] -= arc;
arc -= 0.005f;
VectorScale( p->vel, speed, p->vel ); VectorScale( p->vel, speed, p->vel );
} }
@ -908,7 +890,7 @@ void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
if( !p ) return; if( !p ) return;
p->die += 3.0f; p->die = cl.time + 3.0f;
p->color = pcolor + COM_RandomLong( 0, 9 ); p->color = pcolor + COM_RandomLong( 0, 9 );
p->type = pt_vox_slowgrav; p->type = pt_vox_slowgrav;
@ -929,7 +911,7 @@ void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
if( !p ) return; if( !p ) return;
p->die += 3.0f; p->die = cl.time + 3.0f;
p->color = pcolor + COM_RandomLong( 0, 9 ); p->color = pcolor + COM_RandomLong( 0, 9 );
p->type = pt_vox_slowgrav; p->type = pt_vox_slowgrav;
@ -948,11 +930,11 @@ void CL_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
/* /*
=============== ===============
CL_LavaSplash R_LavaSplash
=============== ===============
*/ */
void CL_LavaSplash( const vec3_t org ) void R_LavaSplash( const vec3_t org )
{ {
particle_t *p; particle_t *p;
float vel; float vel;
@ -968,20 +950,20 @@ void CL_LavaSplash( const vec3_t org )
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
if( !p ) return; if( !p ) return;
p->die += 2.0f + (rand() & 31) * 0.02f; p->die = cl.time + COM_RandomFloat( 2.0f, 2.62f );
p->color = 224 + (rand() & 7); p->color = COM_RandomLong( 224, 231 );
p->type = pt_slowgrav; p->type = pt_slowgrav;
dir[0] = j * 8.0f + (rand() & 7); dir[0] = j * 8.0f + COM_RandomFloat( 0.0f, 7.0f );
dir[1] = i * 8.0f + (rand() & 7); dir[1] = i * 8.0f + COM_RandomFloat( 0.0f, 7.0f );
dir[2] = 256; dir[2] = 256.0f;
p->org[0] = org[0] + dir[0]; p->org[0] = org[0] + dir[0];
p->org[1] = org[1] + dir[1]; p->org[1] = org[1] + dir[1];
p->org[2] = org[2] + (rand() & 63); p->org[2] = org[2] + COM_RandomFloat( 0.0f, 63.0f );
VectorNormalize( dir ); VectorNormalize( dir );
vel = 50 + (rand() & 63); vel = COM_RandomFloat( 50.0f, 113.0f );
VectorScale( dir, vel, p->vel ); VectorScale( dir, vel, p->vel );
} }
} }
@ -990,56 +972,95 @@ void CL_LavaSplash( const vec3_t org )
/* /*
=============== ===============
CL_ParticleBurst R_ParticleBurst
=============== ===============
*/ */
void CL_ParticleBurst( const vec3_t org, int size, int color, float life ) void R_ParticleBurst( const vec3_t org, int size, int color, float life )
{ {
particle_t *p; particle_t *p;
float vel; vec3_t dir, dest;
vec3_t dir; int i, j;
int i, j, k; float dist;
for( i = -size; i < size; i++ ) for( i = 0; i < 32; i++ )
{ {
for( j = -size; j < size; j++ ) for( j = 0; j < 32; j++ )
{ {
for( k = 0; k < 1; k++ ) p = R_AllocParticle( NULL );
{ if( !p ) return;
p = R_AllocParticle( NULL );
if( !p ) return;
p->die += life + (rand() & 31) * 0.02f; p->die = cl.time + life + COM_RandomFloat( -0.5f, 0.5f );
p->color = color; p->color = color + COM_RandomLong( 0, 10 );
p->type = pt_slowgrav; p->ramp = 1.0f;
dir[0] = j * 8.0f + (rand() & 7);
dir[1] = i * 8.0f + (rand() & 7);
dir[2] = 256;
p->org[0] = org[0] + dir[0]; VectorCopy( org, p->org );
p->org[1] = org[1] + dir[1]; VectorAddScalar( org, COM_RandomFloat( -size, size ), dest );
p->org[2] = org[2] + (rand() & 63); VectorSubtract( dest, p->org, dir );
dist = VectorNormalizeLength( dir );
VectorNormalize( dir ); VectorScale( dir, ( dist / life ), p->vel );
vel = 50 + (rand() & 63);
VectorScale( dir, vel, p->vel );
}
} }
} }
} }
/* /*
=============== ===============
CL_TeleportSplash R_LargeFunnel
=============== ===============
*/ */
void CL_TeleportSplash( const vec3_t org ) void R_LargeFunnel( const vec3_t org, int reverse )
{
particle_t *p;
float vel, dist;
vec3_t dir, dest;
int i, j;
for( i = -8; i < 8; i++ )
{
for( j = -8; j < 8; j++ )
{
p = R_AllocParticle( NULL );
if( !p ) return;
dest[0] = (i * 32.0f) + org[0];
dest[1] = (j * 32.0f) + org[1];
dest[2] = org[2] + COM_RandomFloat( 100.0f, 800.0f );
if( reverse )
{
VectorCopy( org, p->org );
VectorSubtract( dest, p->org, dir );
}
else
{
VectorCopy( dest, p->org );
VectorSubtract( org, p->org, dir );
}
vel = dest[2] / 8.0f;
if( vel < 64.0f ) vel = 64.0f;
dist = VectorNormalizeLength( dir );
vel += COM_RandomFloat( 64.0f, 128.0f );
VectorScale( dir, vel, p->vel );
p->die = cl.time + (dist / vel );
p->color = 244; // green color
}
}
}
/*
===============
R_TeleportSplash
===============
*/
void R_TeleportSplash( const vec3_t org )
{ {
particle_t *p; particle_t *p;
vec3_t dir; vec3_t dir;
float vel;
int i, j, k; int i, j, k;
for( i = -16; i < 16; i += 4 ) for( i = -16; i < 16; i += 4 )
@ -1051,20 +1072,21 @@ void CL_TeleportSplash( const vec3_t org )
p = R_AllocParticle( NULL ); p = R_AllocParticle( NULL );
if( !p ) return; if( !p ) return;
p->die += 0.2f + (rand() & 7) * 0.02f; p->die = cl.time + COM_RandomFloat( 0.2f, 0.34f );
p->color = 7 + (rand() & 7); p->color = COM_RandomLong( 7, 14 );
p->type = pt_slowgrav; p->type = pt_slowgrav;
dir[0] = j * 8.0f; dir[0] = j * 8.0f;
dir[1] = i * 8.0f; dir[1] = i * 8.0f;
dir[2] = k * 8.0f; dir[2] = k * 8.0f;
p->org[0] = org[0] + i + (rand() & 3); p->org[0] = org[0] + i + COM_RandomFloat( 0.0f, 3.0f );
p->org[1] = org[1] + j + (rand() & 3); p->org[1] = org[1] + j + COM_RandomFloat( 0.0f, 3.0f );
p->org[2] = org[2] + k + (rand() & 3); p->org[2] = org[2] + k + COM_RandomFloat( 0.0f, 3.0f );
VectorNormalize( dir ); VectorNormalize( dir );
VectorScale( dir, (50 + (rand() & 63)), p->vel ); vel = COM_RandomFloat( 50.0f, 113.0f );
VectorScale( dir, vel, p->vel );
} }
} }
} }
@ -1102,8 +1124,6 @@ void R_RocketTrail( vec3_t start, vec3_t end, int type )
type -= 128; type -= 128;
} }
if( type == 6 ) Msg( "R_RocketTrail: type 6 is selected\n" );
VectorScale( vec, dec, vec ); VectorScale( vec, dec, vec );
while( len > 0 ) while( len > 0 )
@ -1162,18 +1182,11 @@ void R_RocketTrail( vec3_t start, vec3_t end, int type )
len -= 3.0f; len -= 3.0f;
break; break;
case 6: // voor trail case 6: // voor trail
#if 0
p->ramp = COM_RandomLong( 0, 3 );
p->color = ramp3[(int)p->ramp];
VectorCopy( start, p->org );
p->type = pt_fire;
#else
p->color = COM_RandomLong( 152, 155 ); p->color = COM_RandomLong( 152, 155 );
p->die += 0.3f; p->die += 0.3f;
VectorAddScalar( start, COM_RandomFloat( -8.0f, 8.0f ), p->org ); VectorAddScalar( start, COM_RandomFloat( -8.0f, 8.0f ), p->org );
#endif
break; break;
case 7: // explosion tracer case 7: // explosion tracer
x = COM_RandomLong( 0, 65535 ); x = COM_RandomLong( 0, 65535 );
y = COM_RandomLong( 8, 16 ); y = COM_RandomLong( 8, 16 );
SinCos( x, &s, &c ); SinCos( x, &s, &c );
@ -1351,11 +1364,8 @@ void R_StreakSplash( const vec3_t pos, const vec3_t dir, int color, int count, f
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
{ {
vel2[0] = vel[0] + COM_RandomFloat( velocityMin, velocityMax ); VectorAddScalar( vel, COM_RandomFloat( velocityMin, velocityMax ), vel2 );
vel2[1] = vel[1] + COM_RandomFloat( velocityMin, velocityMax ); p = R_AllocTracer( pos, vel2, COM_RandomFloat( 0.1f, 0.5f ));
vel2[2] = vel[2] + COM_RandomFloat( velocityMin, velocityMax );
p = R_AllocTracer( pos, vel, COM_RandomFloat( 0.1f, 0.5f ));
if( !p ) return; if( !p ) return;
p->type = pt_grav; p->type = pt_grav;

View File

@ -1717,7 +1717,7 @@ void R_RenderInfo_f( void )
} }
Msg( "\n" ); Msg( "\n" );
Msg( "MODE: %i, %i x %i %s\n", vid_mode->value, glState.width, glState.height, vidmode[(int)vid_mode->value].desc ); Msg( "%s [%i x %i]\n", vidmode[(int)vid_mode->value].desc, glState.width, glState.height );
Msg( "GAMMA: %s\n", (glConfig.deviceSupportsGamma) ? "hardware" : "software" ); Msg( "GAMMA: %s\n", (glConfig.deviceSupportsGamma) ? "hardware" : "software" );
Msg( "\n" ); Msg( "\n" );
Msg( "PICMIP: %i\n", gl_picmip->value ); Msg( "PICMIP: %i\n", gl_picmip->value );

View File

@ -2076,7 +2076,7 @@ void Con_RunConsole( void )
else con.showlines = 0; // none visible else con.showlines = 0; // none visible
if( cls.state == ca_connecting || cls.state == ca_connected || cl.first_frame ) if( cls.state == ca_connecting || cls.state == ca_connected || cl.first_frame )
host.realframetime = 0.0; // don't accumulate frametime host.realframetime = 0.000001f; // don't accumulate frametime
lines_per_frame = fabs( scr_conspeed->value ) * host.realframetime; lines_per_frame = fabs( scr_conspeed->value ) * host.realframetime;

View File

@ -774,8 +774,6 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame )
host.state = HOST_INIT; // initialzation started host.state = HOST_INIT; // initialzation started
host.developer = host.old_developer = 0; host.developer = host.old_developer = 0;
srand( time( NULL )); // init random generator
Memory_Init(); // init memory subsystem Memory_Init(); // init memory subsystem
// some commands may turn engine into infinity loop, // some commands may turn engine into infinity loop,

View File

@ -377,8 +377,6 @@ void Host_InputFrame( void )
{ {
qboolean shutdownMouse = false; qboolean shutdownMouse = false;
rand (); // keep the random time dependent
Sys_SendKeyEvents (); Sys_SendKeyEvents ();
Cbuf_Execute (); Cbuf_Execute ();

View File

@ -191,18 +191,14 @@ float VectorNormalizeLength2( const vec3_t v, vec3_t out )
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up ) void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up )
{ {
vec3_t tmp; float d;
// fast case right[0] = forward[2];
if( forward[0] == 0.0f && forward[1] == 0.0f ) right[1] = -forward[0];
{ right[2] = forward[1];
VectorSet( right, 1.0f, 0.0f, 0.0f );
VectorSet( up, -forward[2], 0.0f, 0.0f );
return;
}
VectorSet( tmp, 0.0f, 0.0f, 1.0f ); d = DotProduct( forward, right );
CrossProduct( forward, tmp, right ); VectorMA( right, -d, forward, right );
VectorNormalize( right ); VectorNormalize( right );
CrossProduct( right, forward, up ); CrossProduct( right, forward, up );
VectorNormalize( up ); VectorNormalize( up );

View File

@ -368,11 +368,11 @@ Sends a text message in an out-of-band datagram
*/ */
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, char *format, ... ) void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, char *format, ... )
{ {
va_list argptr; static char string[MAX_PRINT_MSG];
char string[MAX_PRINT_MSG]; va_list argptr;
va_start( argptr, format ); va_start( argptr, format );
Q_vsprintf( string, format, argptr ); Q_vsnprintf( string, sizeof( string ) - 1, format, argptr );
va_end( argptr ); va_end( argptr );
Netchan_OutOfBand( net_socket, adr, Q_strlen( string ), string ); Netchan_OutOfBand( net_socket, adr, Q_strlen( string ), string );

View File

@ -577,11 +577,11 @@ formatted message
*/ */
void Msg( const char *pMsg, ... ) void Msg( const char *pMsg, ... )
{ {
va_list argptr; static char text[MAX_PRINT_MSG];
char text[MAX_PRINT_MSG]; va_list argptr;
va_start( argptr, pMsg ); va_start( argptr, pMsg );
Q_vsnprintf( text, sizeof( text ), pMsg, argptr ); Q_vsnprintf( text, sizeof( text ) - 1, pMsg, argptr );
va_end( argptr ); va_end( argptr );
Sys_Print( text ); Sys_Print( text );
@ -596,13 +596,13 @@ formatted developer message
*/ */
void MsgDev( int level, const char *pMsg, ... ) void MsgDev( int level, const char *pMsg, ... )
{ {
va_list argptr; static char text[MAX_PRINT_MSG];
char text[MAX_PRINT_MSG]; va_list argptr;
if( host.developer < level ) return; if( host.developer < level ) return;
va_start( argptr, pMsg ); va_start( argptr, pMsg );
Q_vsnprintf( text, sizeof( text ), pMsg, argptr ); Q_vsnprintf( text, sizeof( text ) - 1, pMsg, argptr );
va_end( argptr ); va_end( argptr );
switch( level ) switch( level )

View File

@ -76,7 +76,7 @@ void SV_GetChallenge( netadr_t from )
if( i == MAX_CHALLENGES ) if( i == MAX_CHALLENGES )
{ {
// this is the first time this client has asked for a challenge // this is the first time this client has asked for a challenge
svs.challenges[oldest].challenge = (rand()<<16) ^ rand(); svs.challenges[oldest].challenge = (COM_RandomLong( 0, 0xFFFF ) << 16) | COM_RandomLong( 0, 0xFFFF );
svs.challenges[oldest].adr = from; svs.challenges[oldest].adr = from;
svs.challenges[oldest].time = host.realtime; svs.challenges[oldest].time = host.realtime;
svs.challenges[oldest].connected = false; svs.challenges[oldest].connected = false;

View File

@ -711,8 +711,8 @@ void SV_UpdateToReliableMessages( void )
{ {
// just for network debugging (send only for local client) // just for network debugging (send only for local client)
MSG_BeginServerCmd( &sv.reliable_datagram, svc_bad ); MSG_BeginServerCmd( &sv.reliable_datagram, svc_bad );
MSG_WriteLong( &sv.reliable_datagram, rand( )); // send some random data MSG_WriteLong( &sv.reliable_datagram, COM_RandomLong( 1, 65536 )); // send some random data
MSG_WriteString( &sv.reliable_datagram, host.finalmsg ); // send final message MSG_WriteString( &sv.reliable_datagram, host.finalmsg ); // send final message
sv.write_bad_message = false; sv.write_bad_message = false;
} }