Browse Source

engine: client: fix sentence word splitted by contents inside parentheses

pull/2/head
Alibek Omarov 3 years ago
parent
commit
e07417aead
  1. 12
      engine/client/s_vox.c

12
engine/client/s_vox.c

@ -230,7 +230,8 @@ static int VOX_ParseString( char *psz, char *rgpparseword[CVOXWORDMAX] )
for( ; *psz && for( ; *psz &&
*psz != ' ' && *psz != ' ' &&
*psz != '.' && *psz != '.' &&
*psz != ','; psz++ ); *psz != ',' &&
*psz != '('; psz++ );
// skip anything in between ( and ) // skip anything in between ( and )
if( *psz == '(' ) if( *psz == '(' )
@ -549,8 +550,8 @@ static void Test_VOX_ParseString( void )
char *rgpparseword[CVOXWORDMAX]; char *rgpparseword[CVOXWORDMAX];
const char *data[] = const char *data[] =
{ {
"(p100) my ass is, heavy!(p80) clik.", "(p100) my ass is, heavy!(p80 t20) clik.",
"(p100)", "my", "ass", "is", "_comma", "heavy!(p80)", "clik", NULL, "(p100)", "my", "ass", "is", "_comma", "heavy!(p80 t20)", "clik", NULL,
"freeman...", "freeman...",
"freeman", "_period", NULL, "freeman", "_period", NULL,
}; };
@ -586,19 +587,22 @@ static void Test_VOX_ParseWordParams( void )
Q_strncpy( buffer, "heavy!(p80)", sizeof( buffer )); Q_strncpy( buffer, "heavy!(p80)", sizeof( buffer ));
ret = VOX_ParseWordParams( buffer, &word, true ); ret = VOX_ParseWordParams( buffer, &word, true );
TASSERT_STR( buffer, "heavy!" );
TASSERT( word.pitch == 80 ); TASSERT( word.pitch == 80 );
TASSERT( ret ); TASSERT( ret );
Q_strncpy( buffer, "(p105)", sizeof( buffer )); Q_strncpy( buffer, "(p105)", sizeof( buffer ));
ret = VOX_ParseWordParams( buffer, &word, false ); ret = VOX_ParseWordParams( buffer, &word, false );
TASSERT_STR( buffer, "" );
TASSERT( word.pitch == 105 ); TASSERT( word.pitch == 105 );
TASSERT( !ret ); TASSERT( !ret );
Q_strncpy( buffer, "quiet(v50)", sizeof( buffer )); Q_strncpy( buffer, "quiet(v50)", sizeof( buffer ));
ret = VOX_ParseWordParams( buffer, &word, false ); ret = VOX_ParseWordParams( buffer, &word, false );
TASSERT_STR( buffer, "quiet" );
TASSERT( word.pitch == 105 ); // defaulted TASSERT( word.pitch == 105 ); // defaulted
TASSERT( word.volume == 50 ); TASSERT( word.volume == 50 );
TASSERT( !ret ); TASSERT( ret );
} }
void Test_RunVOX( void ) void Test_RunVOX( void )

Loading…
Cancel
Save