allow negative mod percentages

This commit is contained in:
Chris Danford
2005-04-20 09:08:22 +00:00
parent 7caea1e41a
commit 6640b3fed6
+13 -9
View File
@@ -230,23 +230,27 @@ void PlayerOptions::FromString( CString sOptions, bool bWarnOnInvalid )
CStringArray asParts; CStringArray asParts;
split( sBit, " ", asParts, true ); split( sBit, " ", asParts, true );
for( unsigned j = 0; j < asParts.size()-1; ++j ) FOREACH_CONST( CString, asParts, s )
{ {
if( asParts[j] == "no" ) if( *s == "no" )
{
level = 0; level = 0;
else if( isdigit(asParts[j][0]) ) }
else if( isdigit((*s)[0]) || (*s)[0] == '-' )
{ {
/* If the last character is a *, they probably said "123*" when /* If the last character is a *, they probably said "123*" when
* they meant "*123". */ * they meant "*123". */
if( asParts[j].Right(1) == "*" ) if( s->Right(1) == "*" )
RageException::Throw("Invalid player options '%i*'; did you mean '*%i'?", RageException::Throw("Invalid player options '%i*'; did you mean '*%i'?",
atoi(asParts[j]), atoi(asParts[j]) ); atoi(*s), atoi(*s) );
level = strtof( asParts[j], NULL ) / 100.0f; level = strtof( *s, NULL ) / 100.0f;
}
else if( *s[0]=='*' )
{
sscanf( *s, "*%f", &speed );
} }
else if( asParts[j][0]=='*' )
sscanf( asParts[j], "*%f", &speed );
} }
sBit = asParts[asParts.size()-1]; sBit = asParts.back();
#define SET_FLOAT( opt ) { m_ ## opt = level; m_Speed ## opt = speed; } #define SET_FLOAT( opt ) { m_ ## opt = level; m_Speed ## opt = speed; }
const bool on = (level > 0.5f); const bool on = (level > 0.5f);