diff options
author | Andrey Nazarov <skuller@skuller.net> | 2011-04-24 18:02:00 +0400 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2011-04-25 12:24:24 +0400 |
commit | 3a9ab3115025e8e3f21881c16f65e4cd3e978774 (patch) | |
tree | 3cc55cb3019925ad97e89cd0042fd4054f7e726a /src/cl_parse.c | |
parent | 3414e162ba75ac8042522d1b5717139c321bda85 (diff) |
Split sound parsing/starting code.
Diffstat (limited to 'src/cl_parse.c')
-rw-r--r-- | src/cl_parse.c | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/src/cl_parse.c b/src/cl_parse.c index 64ed68a..3866a76 100644 --- a/src/cl_parse.c +++ b/src/cl_parse.c @@ -681,6 +681,7 @@ ACTION MESSAGES tent_params_t te; mz_params_t mz; +snd_params_t snd; static void CL_ParseTEntParams( void ) { te.type = MSG_ReadByte(); @@ -845,71 +846,51 @@ CL_ParseStartSoundPacket ================== */ static void CL_ParseStartSoundPacket( void ) { - vec3_t pos_v; - float *pos; - int channel, ent; - int sound_num; - float volume; - float attenuation; - int flags; - float ofs; + int flags, channel, entity; flags = MSG_ReadByte(); - sound_num = MSG_ReadByte(); - if( sound_num == -1 ) { + if( ( flags & (SND_ENT|SND_POS) ) == 0 ) + Com_Error( ERR_DROP, "%s: neither SND_ENT nor SND_POS set", __func__ ); + + snd.index = MSG_ReadByte(); + if( snd.index == -1 ) Com_Error( ERR_DROP, "%s: read past end of message", __func__ ); - } if( flags & SND_VOLUME ) - volume = MSG_ReadByte() / 255.0; + snd.volume = MSG_ReadByte() / 255.0f; else - volume = DEFAULT_SOUND_PACKET_VOLUME; + snd.volume = DEFAULT_SOUND_PACKET_VOLUME; if( flags & SND_ATTENUATION ) - attenuation = MSG_ReadByte() / 64.0; + snd.attenuation = MSG_ReadByte() / 64.0f; else - attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; + snd.attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; if( flags & SND_OFFSET ) - ofs = MSG_ReadByte() / 1000.0; + snd.timeofs = MSG_ReadByte() / 1000.0f; else - ofs = 0; + snd.timeofs = 0; if( flags & SND_ENT ) { // entity relative channel = MSG_ReadShort(); - ent = channel >> 3; - if( ent < 0 || ent >= MAX_EDICTS ) - Com_Error( ERR_DROP, "%s: bad ent: %d", __func__, ent ); - channel &= 7; + entity = channel >> 3; + if( entity < 0 || entity >= MAX_EDICTS ) + Com_Error( ERR_DROP, "%s: bad entity: %d", __func__, entity ); + snd.entity = entity; + snd.channel = channel & 7; } else { - ent = 0; - channel = 0; + snd.entity = 0; + snd.channel = 0; } - if( flags & SND_POS ) { - // positioned in space - MSG_ReadPos( pos_v ); - pos = pos_v; - } else { - if( !( flags & SND_ENT ) ) { - Com_Error( ERR_DROP, "%s: neither SND_ENT nor SND_POS set", __func__ ); - } -#ifdef _DEBUG - if( developer->integer ) { - CL_CheckEntityPresent( ent, "sound" ); - } -#endif - // use entity number - pos = NULL; - } + // positioned in space + if( flags & SND_POS ) + MSG_ReadPos( snd.pos ); - SHOWNET( 2, " %s\n", cl.configstrings[CS_SOUNDS+sound_num] ); + snd.flags = flags; - if( cl.sound_precache[sound_num] ) { - S_StartSound( pos, ent, channel, cl.sound_precache[sound_num], - volume, attenuation, ofs ); - } + SHOWNET( 2, " %s\n", cl.configstrings[ CS_SOUNDS + snd.index ] ); } /* @@ -1271,6 +1252,7 @@ void CL_ParseServerMessage( void ) { case svc_sound: CL_ParseStartSoundPacket(); + S_ParseStartSound(); break; case svc_spawnbaseline: |