From 439ab6c58a519faae5c63aa5a2bf8c04d7b3726e Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 12 Jun 2006 07:59:32 +0000 Subject: [PATCH] Simplify. --- stepmania/src/Model.cpp | 9 ++++----- stepmania/src/SongOptions.cpp | 13 +++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index e889a6b1b9..65e099c126 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -222,17 +222,16 @@ void Model::LoadMaterialsFromMilkshapeAscii( RString sPath ) // shininess if( f.GetLine( sLine ) <= 0 ) THROW; - char *p; - float fShininess = strtof( sLine, &p ); - if( p == sLine ) + float fShininess; + if( !FromString(sLine, fShininess) ) THROW; Material.fShininess = fShininess; // transparency if( f.GetLine( sLine ) <= 0 ) THROW; - float fTransparency = strtof( sLine, &p ); - if( p == sLine ) + float fTransparency; + if( !FromString(sLine, fTransparency) ) THROW; Material.fTransparency = fTransparency; diff --git a/stepmania/src/SongOptions.cpp b/stepmania/src/SongOptions.cpp index 78294d6d5f..3d8c6946e3 100644 --- a/stepmania/src/SongOptions.cpp +++ b/stepmania/src/SongOptions.cpp @@ -107,19 +107,12 @@ void SongOptions::FromString( const RString &sOptions ) Regex mult("^([0-9]+(\\.[0-9]+)?)xmusic$"); vector matches; if( mult.Compare(sBit, matches) ) - { - char *p = NULL; - m_fMusicRate = strtof( matches[0], &p ); - ASSERT( p != matches[0] ); - } + ::FromString( matches[0], m_fMusicRate ); matches.clear(); Regex lives("^([0-9]+) ?(lives|life)$"); if( lives.Compare(sBit, matches) ) - { - int ret = sscanf( matches[0], "%i", &m_iBatteryLives ); - ASSERT( ret == 1 ); - } + ::FromString( matches[0], m_iBatteryLives ); vector asParts; split( sBit, " ", asParts, true ); @@ -132,7 +125,7 @@ void SongOptions::FromString( const RString &sOptions ) on = false; } - if( sBit == "norecover" ) m_DrainType = DRAIN_NO_RECOVER; + if( sBit == "norecover" ) m_DrainType = DRAIN_NO_RECOVER; else if( sBit == "suddendeath" ) m_DrainType = DRAIN_SUDDEN_DEATH; else if( sBit == "power-drop" ) m_DrainType = DRAIN_NO_RECOVER; else if( sBit == "death" ) m_DrainType = DRAIN_SUDDEN_DEATH;