From 4db2aaffc44992d8f2d9d0f7567cff427dcf35fe Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 9 Mar 2021 23:34:12 +0300 Subject: [PATCH] client: port fix of spk/speak commands from old engine --- engine/client/s_main.c | 23 +++++++++++++++++++---- engine/client/s_vox.c | 5 ++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/engine/client/s_main.c b/engine/client/s_main.c index 05354a34..c6246832 100644 --- a/engine/client/s_main.c +++ b/engine/client/s_main.c @@ -1679,26 +1679,41 @@ void S_PlayVol_f( void ) S_StartLocalSound( Cmd_Argv( 1 ), Q_atof( Cmd_Argv( 2 )), false ); } +static void S_Say( const char *name, qboolean reliable ) +{ + char sentence[1024]; + + // predefined vox sentence + if( name[0] == '!' ) + { + S_StartLocalSound( name, 1.0f, reliable ); + return; + } + + Q_snprintf( sentence, sizeof( sentence ), "!#%s", name ); + S_StartLocalSound( sentence, 1.0f, reliable ); +} + void S_Say_f( void ) { if( Cmd_Argc() == 1 ) { - Con_Printf( S_USAGE "speak \n" ); + Con_Printf( S_USAGE "speak \n" ); return; } - S_StartLocalSound( Cmd_Argv( 1 ), 1.0f, false ); + S_Say( Cmd_Argv( 1 ), false ); } void S_SayReliable_f( void ) { if( Cmd_Argc() == 1 ) { - Con_Printf( S_USAGE "spk \n" ); + Con_Printf( S_USAGE "spk \n" ); return; } - S_StartLocalSound( Cmd_Argv( 1 ), 1.0f, true ); + S_Say( Cmd_Argv( 1 ), true ); } /* diff --git a/engine/client/s_vox.c b/engine/client/s_vox.c index 4f7d5f81..b421fe35 100644 --- a/engine/client/s_vox.c +++ b/engine/client/s_vox.c @@ -469,7 +469,10 @@ void VOX_LoadSound( channel_t *pchan, const char *pszin ) // lookup actual string in g_Sentences, // set pointer to string data - psz = VOX_LookupString( pszin, NULL ); + if( pszin[0] == '#' ) + psz = (char *)pszin + 1; + else + psz = VOX_LookupString( pszin, NULL ); if( !psz ) {