public virtual void Clear( ) { prev = next = null; sfx = null; volume = attenuation = begin = entnum = entchannel = 0; fixed_origin = false; Math3D.VectorClear(origin); }
static void FreePlaysound(playsound_t ps) { ps.prev.next = ps.next; ps.next.prev = ps.prev; ps.next = s_freeplays.next; s_freeplays.next.prev = ps; ps.prev = s_freeplays; s_freeplays.next = ps; }
static SND_DMA( ) { for (var i = 0; i < known_sfx.Length; i++) { known_sfx[i] = new sfx_t(); } for (var i = 0; i < MAX_PLAYSOUNDS; i++) { s_playsounds[i] = new playsound_t(); } }
public static void IssuePlaysound(playsound_t ps) { channel_t ch; sfxcache_t sc; if (s_show.value != 0F) { Com.Printf("Issue " + ps.begin + "\\n"); } ch = PickChannel(ps.entnum, ps.entchannel); if (ch == null) { FreePlaysound(ps); return; } if (ps.attenuation == ATTN_STATIC) { ch.dist_mult = ps.attenuation * 0.001F; } else { ch.dist_mult = ps.attenuation * 0.0005F; } ch.master_vol = ( Int32 )ps.volume; ch.entnum = ps.entnum; ch.entchannel = ps.entchannel; ch.sfx = ps.sfx; Math3D.VectorCopy(ps.origin, ch.origin); ch.fixed_origin = ps.fixed_origin; Spatialize(ch); ch.pos = 0; sc = WaveLoader.LoadSound(ch.sfx); ch.end = paintedtime + sc.length; FreePlaysound(ps); }
public static void StartSound(Single[] origin, Int32 entnum, Int32 entchannel, sfx_t sfx, Single fvol, Single attenuation, Single timeofs) { if (!sound_started) { return; } if (sfx == null) { return; } if (sfx.name[0] == '*') { sfx = RegisterSexedSound(cl_entities[entnum].current, sfx.name); } sfxcache_t sc = WaveLoader.LoadSound(sfx); if (sc == null) { return; } var vol = ( Int32 )(fvol * 255); playsound_t ps = AllocPlaysound(); if (ps == null) { return; } if (origin != null) { Math3D.VectorCopy(origin, ps.origin); ps.fixed_origin = true; } else { ps.fixed_origin = false; } ps.entnum = entnum; ps.entchannel = entchannel; ps.attenuation = attenuation; ps.volume = vol; ps.sfx = sfx; var start = ( Int32 )(cl.frame.servertime * 0.001F * dma.speed + s_beginofs); if (start < paintedtime) { start = paintedtime; s_beginofs = ( Int32 )(start - (cl.frame.servertime * 0.001F * dma.speed)); } else if (start > paintedtime + 0.3F * dma.speed) { start = ( Int32 )(paintedtime + 0.1F * dma.speed); s_beginofs = ( Int32 )(start - (cl.frame.servertime * 0.001F * dma.speed)); } else { s_beginofs -= 10; } if (timeofs == 0F) { ps.begin = paintedtime; } else { ps.begin = ( Int64 )(start + timeofs * dma.speed); } playsound_t sort = new playsound_t(); ps.next = sort; ps.prev = sort.prev; ps.next.prev = ps; ps.prev.next = ps; }