cl_dll/cl_animation.cpp
// ripped from xash
// required for event sounds to play correctly after changlevel animation fix
ripped from xash
required for event sounds to play correctly after changlevel animation fix
ripped from xash required for event sounds to play correctly after changlevel animation fix
void animutils_s::DispatchAnimEvents(cl_entity_s* e, float flInterval)
{
	mstudioseqdesc_t* pseqdesc;
	mstudioevent_t* pevent;
	studiohdr_t* pstudiohdr = nullptr;
	int frame = 0;
	if (!e || !e->model)
		return;
	pstudiohdr = (studiohdr_t*)IEngineStudio.Mod_Extradata(e->model);
	if (!pstudiohdr)
		return;
	int i, sequence;
	float end, start;
	if (pstudiohdr->numattachments < 1)
	{
		for (int i = 0; i < 4; i++)
			e->attachment[i] = e->origin;
	}
	if ((e->curstate.effects & EF_MUZZLEFLASH) == 1)
	{
		dlight_t* el = gEngfuncs.pEfxAPI->CL_AllocElight(0);
		e->curstate.effects &= ~EF_MUZZLEFLASH;
		VectorCopy(e->attachment[0], el->origin);
		el->die = gEngfuncs.GetClientTime() + 0.05f;
		el->color.r = 255;
		el->color.g = 192;
		el->color.b = 64;
		el->decay = 320;
		el->radius = 24;
	}
	sequence = clamp(0, e->curstate.sequence, pstudiohdr->numseq - 1);
	pseqdesc = (mstudioseqdesc_t*)((byte*)pstudiohdr + pstudiohdr->seqindex) + sequence;
	if (pseqdesc->numevents == 0)
		return;
	end = StudioEstimateFrame(e, pseqdesc);
	start = end - e->curstate.framerate * flInterval * pseqdesc->fps;
	pevent = (mstudioevent_t*)((byte*)pstudiohdr + pseqdesc->eventindex);
	if (e->latched.sequencetime == e->curstate.animtime)
	{
		if ((pseqdesc->flags & STUDIO_LOOPING) == 1)
			start = -0.01f;
	}
	for (i = 0; i < pseqdesc->numevents; i++)
	{
		if (pevent[i].event < 5000)
			continue;
		frame = pevent[i].frame;
		if (frame < 1)
			frame = 1;
		if ((float)frame > start && (float)frame <= end)
		{
			StudioEvent(&pevent[i], e);	
		}
	}
}
void animutils_s :: DispatchAnimEvents ( cl_entity_s * e , float flInterval ) { mstudioseqdesc_t * pseqdesc ; mstudioevent_t * pevent ; studiohdr_t * pstudiohdr = nullptr ; int frame = 0 ; if ( ! e || ! e -> model ) return ; pstudiohdr = ( studiohdr_t * ) IEngineStudio . Mod_Extradata ( e -> model ) ; if ( ! pstudiohdr ) return ; int i , sequence ; float end , start ; if ( pstudiohdr -> numattachments < 1 ) { for ( int i = 0 ; i < 4 ; i ++ ) e -> attachment [ i ] = e -> origin ; } if ( ( e -> curstate . effects & EF_MUZZLEFLASH ) == 1 ) { dlight_t * el = gEngfuncs . pEfxAPI -> CL_AllocElight ( 0 ) ; e -> curstate . effects &= ~ EF_MUZZLEFLASH ; VectorCopy ( e -> attachment [ 0 ] , el -> origin ) ; el -> die = gEngfuncs . GetClientTime ( ) + 0.05f ; el -> color . r = 255 ; el -> color . g = 192 ; el -> color . b = 64 ; el -> decay = 320 ; el -> radius = 24 ; } sequence = clamp ( 0 , e -> curstate . sequence , pstudiohdr -> numseq - 1 ) ; pseqdesc = ( mstudioseqdesc_t * ) ( ( byte * ) pstudiohdr + pstudiohdr -> seqindex ) + sequence ; if ( pseqdesc -> numevents == 0 ) return ; end = StudioEstimateFrame ( e , pseqdesc ) ; start = end - e -> curstate . framerate * flInterval * pseqdesc -> fps ; pevent = ( mstudioevent_t * ) ( ( byte * ) pstudiohdr + pseqdesc -> eventindex ) ; if ( e -> latched . sequencetime == e -> curstate . animtime ) { if ( ( pseqdesc -> flags & STUDIO_LOOPING ) == 1 ) start = -0.01f ; } for ( i = 0 ; i < pseqdesc -> numevents ; i ++ ) { if ( pevent [ i ] . event < 5000 ) continue ; frame = pevent [ i ] . frame ; if ( frame < 1 ) frame = 1 ; if ( ( float ) frame > start && ( float ) frame <= end ) { StudioEvent ( & pevent [ i ] , e ) ; } } }
ripped from xash
required for event sounds to play correctly after changlevel animation fix
ripped from xash required for event sounds to play correctly after changlevel animation fix
// no events for this animation // ignore all non-client-side events