(float) atof() -> strtof(), which computes in float instead of computing in
double and casting to float, which is silly
This commit is contained in:
@@ -15,7 +15,7 @@ void IncorrectActorParametersWarning( const ParsedCommand &command, int iMaxInde
|
||||
void ParsedCommandToken::Set( const CString &sToken )
|
||||
{
|
||||
s = sToken;
|
||||
f = (float) atof( sToken );
|
||||
f = strtof( sToken, NULL );
|
||||
i = atoi( sToken );
|
||||
b = i != 0;
|
||||
bColorIsValid = c.FromString( sToken );
|
||||
|
||||
@@ -119,11 +119,11 @@ void Course::LoadFromCRSFile( CString sPath )
|
||||
TrimLeft( sBits[0] );
|
||||
TrimRight( sBits[0] );
|
||||
if( !sBits[0].CompareNoCase("TIME") )
|
||||
attack.fStartSecond = (float) atof( sBits[1] );
|
||||
attack.fStartSecond = strtof( sBits[1], NULL );
|
||||
else if( !sBits[0].CompareNoCase("LEN") )
|
||||
attack.fSecsRemaining = (float) atof( sBits[1] );
|
||||
attack.fSecsRemaining = strtof( sBits[1], NULL );
|
||||
else if( !sBits[0].CompareNoCase("END") )
|
||||
end = (float) atof( sBits[1] );
|
||||
end = strtof( sBits[1], NULL );
|
||||
else if( !sBits[0].CompareNoCase("MODS") )
|
||||
{
|
||||
if( end != -9999 )
|
||||
|
||||
@@ -160,7 +160,7 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData,
|
||||
attack.level = ATTACK_LEVEL_1;
|
||||
attack.sModifier = asBits[1];
|
||||
attack.sModifier.Replace( '.', ',' ); // we couldn't use comma here because the map item separator is a comma
|
||||
attack.fSecsRemaining = (float) atof( asBits[2] );
|
||||
attack.fSecsRemaining = strtof( asBits[2], NULL );
|
||||
|
||||
out.GetAttackMap()[tn] = attack;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ int NoteSkinManager::GetMetricI( CString sNoteSkinName, CString sButtonName, CSt
|
||||
|
||||
float NoteSkinManager::GetMetricF( CString sNoteSkinName, CString sButtonName, CString sValueName )
|
||||
{
|
||||
return (float)atof( GetMetric(sNoteSkinName,sButtonName,sValueName) );
|
||||
return strtof( GetMetric(sNoteSkinName,sButtonName,sValueName), NULL );
|
||||
}
|
||||
|
||||
bool NoteSkinManager::GetMetricB( CString sNoteSkinName, CString sButtonName, CString sValueName )
|
||||
|
||||
@@ -533,7 +533,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
}
|
||||
else if( value_name == "#bpm" )
|
||||
{
|
||||
BPMSegment newSeg( 0, (float)atof(value_data) );
|
||||
BPMSegment newSeg( 0, strtof(value_data, NULL) );
|
||||
out.AddBPMSegment( newSeg );
|
||||
|
||||
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", newSeg.m_fStartBeat, newSeg.m_fBPM );
|
||||
@@ -640,7 +640,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
|
||||
if( 0==stricmp(value_name, sTagToLookFor) )
|
||||
{
|
||||
fBPM = (float)atof( value_data );
|
||||
fBPM = strtof( value_data, NULL );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -716,7 +716,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
if( fBPM == -1 )
|
||||
fBPM = out.m_Timing.m_BPMSegments[out.m_Timing.m_BPMSegments.size()-1].m_fBPM;
|
||||
|
||||
fFreezeSecs = (float)atof(value_data)/(fBPM*0.81f); // I have no idea what units these are in, so I experimented until finding this factor.
|
||||
fFreezeSecs = strtof(value_data,NULL)/(fBPM*0.81f); // I have no idea what units these are in, so I experimented until finding this factor.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,9 +318,9 @@ float DWILoader::ParseBrokenDWITimestamp(const CString &arg1, const CString &arg
|
||||
{
|
||||
/* If the value contains a period, treat it as seconds; otherwise ms. */
|
||||
if(arg1.find_first_of(".") != arg1.npos)
|
||||
return (float)atof(arg1.c_str());
|
||||
return strtof( arg1, NULL );
|
||||
else
|
||||
return float(atof(arg1.c_str())) / 1000.f;
|
||||
return strtof( arg1, NULL ) / 1000.f;
|
||||
}
|
||||
|
||||
/* 2+ args */
|
||||
@@ -376,7 +376,7 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
||||
out.m_sCDTitleFile = sParams[1];
|
||||
|
||||
else if( 0==stricmp(sValueName,"BPM") )
|
||||
out.AddBPMSegment( BPMSegment(0, (float)atof(sParams[1])) );
|
||||
out.AddBPMSegment( BPMSegment(0, strtof(sParams[1], NULL)) );
|
||||
|
||||
else if( 0==stricmp(sValueName,"DISPLAYBPM") )
|
||||
{
|
||||
@@ -426,9 +426,9 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
||||
LOG->Warn( "Invalid FREEZE in '%s': '%s'", m_sLoadingFile.c_str(), arrayFreezeExpressions[f].c_str() );
|
||||
continue;
|
||||
}
|
||||
float fIndex = (float)atof( arrayFreezeValues[0] ) * ROWS_PER_BEAT / 4.0f;
|
||||
float fIndex = strtof( arrayFreezeValues[0],NULL ) * ROWS_PER_BEAT / 4.0f;
|
||||
float fFreezeBeat = NoteRowToBeat( fIndex );
|
||||
float fFreezeSeconds = (float)atof( arrayFreezeValues[1] ) / 1000.0f;
|
||||
float fFreezeSeconds = strtof( arrayFreezeValues[1], NULL ) / 1000.0f;
|
||||
|
||||
out.AddStopSegment( StopSegment(fFreezeBeat, fFreezeSeconds) );
|
||||
// LOG->Trace( "Adding a freeze segment: beat: %f, seconds = %f", fFreezeBeat, fFreezeSeconds );
|
||||
@@ -449,9 +449,9 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
||||
LOG->Warn( "Invalid CHANGEBPM in '%s': '%s'", m_sLoadingFile.c_str(), arrayBPMChangeExpressions[b].c_str() );
|
||||
continue;
|
||||
}
|
||||
float fIndex = (float)atof( arrayBPMChangeValues[0] ) * ROWS_PER_BEAT / 4.0f;
|
||||
float fIndex = strtof( arrayBPMChangeValues[0], NULL ) * ROWS_PER_BEAT / 4.0f;
|
||||
float fBeat = NoteRowToBeat( fIndex );
|
||||
float fNewBPM = (float)atof( arrayBPMChangeValues[1] );
|
||||
float fNewBPM = strtof( arrayBPMChangeValues[1], NULL );
|
||||
|
||||
out.AddBPMSegment( BPMSegment(fBeat, fNewBPM) );
|
||||
}
|
||||
|
||||
@@ -274,17 +274,17 @@ bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out )
|
||||
if( 0==stricmp(sValueName,"TITLE") )
|
||||
LoadTags(sParams[1], out);
|
||||
else if( 0==stricmp(sValueName,"BPM") )
|
||||
out.AddBPMSegment( BPMSegment(0, (float)atof(sParams[1])) );
|
||||
out.AddBPMSegment( BPMSegment(0, strtof(sParams[1], NULL)) );
|
||||
else if( 0==stricmp(sValueName,"BPM2") )
|
||||
BPM2 = float(atof(sParams[1]));
|
||||
BPM2 = strtof( sParams[1], NULL );
|
||||
else if( 0==stricmp(sValueName,"BPM3") )
|
||||
BPM3 = float(atof(sParams[1]));
|
||||
BPM3 = strtof( sParams[1], NULL );
|
||||
else if( 0==stricmp(sValueName,"BUNKI") )
|
||||
BPMPos2 = float(atof(sParams[1])) / 100.0f;
|
||||
BPMPos2 = strtof( sParams[1], NULL ) / 100.0f;
|
||||
else if( 0==stricmp(sValueName,"BUNKI2") )
|
||||
BPMPos3 = float(atof(sParams[1])) / 100.0f;
|
||||
BPMPos3 = strtof( sParams[1], NULL ) / 100.0f;
|
||||
else if( 0==stricmp(sValueName,"STARTTIME") )
|
||||
out.m_Timing.m_fBeat0OffsetInSeconds = -(float)atof(sParams[1])/100;
|
||||
out.m_Timing.m_fBeat0OffsetInSeconds = -strtof( sParams[1], NULL )/100;
|
||||
else if( 0==stricmp(sValueName,"TICKCOUNT") ||
|
||||
0==stricmp(sValueName,"STEP") ||
|
||||
0==stricmp(sValueName,"DIFFICULTY"))
|
||||
|
||||
@@ -51,7 +51,7 @@ void SMLoader::LoadFromSMTokens(
|
||||
{
|
||||
RadarValues v;
|
||||
FOREACH_RadarCategory(rc)
|
||||
v[rc] = (float)atof(saValues[rc]);
|
||||
v[rc] = strtof( saValues[rc], NULL );
|
||||
out.SetRadarValues( v );
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
|
||||
const CString sValueName = sParams[0];
|
||||
|
||||
if( 0==stricmp(sValueName,"OFFSET") )
|
||||
out.m_fBeat0OffsetInSeconds = (float)atof( sParams[1] );
|
||||
out.m_fBeat0OffsetInSeconds = strtof( sParams[1], NULL );
|
||||
else if( 0==stricmp(sValueName,"STOPS") || 0==stricmp(sValueName,"FREEZES") )
|
||||
{
|
||||
CStringArray arrayFreezeExpressions;
|
||||
@@ -110,8 +110,8 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
|
||||
continue;
|
||||
}
|
||||
|
||||
const float fFreezeBeat = (float)atof( arrayFreezeValues[0] );
|
||||
const float fFreezeSeconds = (float)atof( arrayFreezeValues[1] );
|
||||
const float fFreezeBeat = strtof( arrayFreezeValues[0], NULL );
|
||||
const float fFreezeSeconds = strtof( arrayFreezeValues[1], NULL );
|
||||
|
||||
StopSegment new_seg;
|
||||
new_seg.m_fStartBeat = fFreezeBeat;
|
||||
@@ -141,8 +141,8 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
|
||||
continue;
|
||||
}
|
||||
|
||||
const float fBeat = (float)atof( arrayBPMChangeValues[0] );
|
||||
const float fNewBPM = (float)atof( arrayBPMChangeValues[1] );
|
||||
const float fBeat = strtof( arrayBPMChangeValues[0], NULL );
|
||||
const float fNewBPM = strtof( arrayBPMChangeValues[1], NULL );
|
||||
|
||||
BPMSegment new_seg;
|
||||
new_seg.m_fStartBeat = fBeat;
|
||||
@@ -162,13 +162,13 @@ bool LoadFromBGChangesString( BackgroundChange &change, const CString &sBGChange
|
||||
switch( aBGChangeValues.size() )
|
||||
{
|
||||
case 6:
|
||||
change.m_fRate = (float)atof( aBGChangeValues[2] );
|
||||
change.m_fRate = strtof( aBGChangeValues[2], NULL );
|
||||
change.m_bFadeLast = atoi( aBGChangeValues[3] ) != 0;
|
||||
change.m_bRewindMovie = atoi( aBGChangeValues[4] ) != 0;
|
||||
change.m_bLoop = atoi( aBGChangeValues[5] ) != 0;
|
||||
// fall through
|
||||
case 2:
|
||||
change.m_fStartBeat = (float)atof( aBGChangeValues[0] );
|
||||
change.m_fStartBeat = strtof( aBGChangeValues[0], NULL );
|
||||
change.m_sBGName = aBGChangeValues[1];
|
||||
return true;
|
||||
default:
|
||||
@@ -238,7 +238,7 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
|
||||
{
|
||||
if(!FromCache)
|
||||
continue;
|
||||
out.m_fMusicLengthSeconds = (float)atof( sParams[1] );
|
||||
out.m_fMusicLengthSeconds = strtof( sParams[1], NULL );
|
||||
}
|
||||
|
||||
else if( 0==stricmp(sValueName,"MUSICBYTES") )
|
||||
@@ -250,14 +250,14 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
|
||||
{
|
||||
if(!FromCache)
|
||||
continue;
|
||||
out.m_fFirstBeat = (float)atof( sParams[1] );
|
||||
out.m_fFirstBeat = strtof( sParams[1], NULL );
|
||||
}
|
||||
|
||||
else if( 0==stricmp(sValueName,"LASTBEAT") )
|
||||
{
|
||||
if(!FromCache)
|
||||
LOG->Trace("Ignored #LASTBEAT (cache only)");
|
||||
out.m_fLastBeat = (float)atof( sParams[1] );
|
||||
out.m_fLastBeat = strtof( sParams[1], NULL );
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"SONGFILENAME") )
|
||||
{
|
||||
@@ -289,11 +289,11 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
|
||||
else
|
||||
{
|
||||
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
|
||||
out.m_fSpecifiedBPMMin = (float)atof( sParams[1] );
|
||||
out.m_fSpecifiedBPMMin = strtof( sParams[1], NULL );
|
||||
if( sParams[2].empty() )
|
||||
out.m_fSpecifiedBPMMax = out.m_fSpecifiedBPMMin;
|
||||
else
|
||||
out.m_fSpecifiedBPMMax = (float)atof( sParams[2] );
|
||||
out.m_fSpecifiedBPMMax = strtof( sParams[2], NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ void PaneDisplay::SetContent( PaneContents c )
|
||||
if( spec.size() < 2 )
|
||||
RageException::Throw( "Metric '%s' malformed", metric.c_str() );
|
||||
|
||||
const float n = (float) atof( spec[0] );
|
||||
const float n = strtof( spec[0], NULL );
|
||||
if( val >= n )
|
||||
continue;
|
||||
spec.erase( spec.begin(), spec.begin()+1 );
|
||||
|
||||
@@ -617,11 +617,11 @@ static void CheckReversePackedPixels()
|
||||
|
||||
void SetupExtensions()
|
||||
{
|
||||
const float fGLVersion = (float) atof( (const char *) glGetString(GL_VERSION) );
|
||||
const float fGLVersion = strtof( (const char *) glGetString(GL_VERSION), NULL );
|
||||
g_glVersion = int(roundf(fGLVersion * 10));
|
||||
GetGLExtensions(g_glExts);
|
||||
|
||||
const float fGLUVersion = (float) atof( (const char *) gluGetString(GLU_VERSION) );
|
||||
const float fGLUVersion = strtof( (const char *) gluGetString(GLU_VERSION), NULL );
|
||||
g_gluVersion = int(roundf(fGLUVersion * 10));
|
||||
|
||||
/* Reset extensions. */
|
||||
|
||||
@@ -236,7 +236,7 @@ void RageMatrixCommand( CString sCommandString, RageMatrix &mat )
|
||||
int iMaxIndexAccessed = 0;
|
||||
|
||||
#define sParam(i) (GetParam(asTokens,i,iMaxIndexAccessed))
|
||||
#define fParam(i) ((float)atof(sParam(i)))
|
||||
#define fParam(i) (strtof(sParam(i),NULL))
|
||||
#define iParam(i) (atoi(sParam(i)))
|
||||
#define bParam(i) (iParam(i)!=0)
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ float HHMMSSToSeconds( const CString &sHHMMSS )
|
||||
float fSeconds = 0;
|
||||
fSeconds += atoi( arrayBits[0] ) * 60 * 60;
|
||||
fSeconds += atoi( arrayBits[1] ) * 60;
|
||||
fSeconds += (float)atof( arrayBits[2] );
|
||||
fSeconds += strtof( arrayBits[2], NULL );
|
||||
|
||||
return fSeconds;
|
||||
}
|
||||
@@ -1232,7 +1232,7 @@ bool FileRead(RageFile& f, float& fOut)
|
||||
CString s;
|
||||
if (!FileRead(f, s))
|
||||
return false;
|
||||
fOut = (float)atof(s);
|
||||
fOut = strtof( s, NULL );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1380,7 +1380,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
case SM_BackFromInsertAttack:
|
||||
{
|
||||
int iDurationChoice = ScreenMiniMenu::s_iLastAnswers[0];
|
||||
g_fLastInsertAttackDurationSeconds = (float) atof( g_InsertAttackItems[0].choices[iDurationChoice] );
|
||||
g_fLastInsertAttackDurationSeconds = strtof( g_InsertAttackItems[0].choices[iDurationChoice], NULL );
|
||||
GAMESTATE->StoreSelectedOptions(); // save so that we don't lose the options chosen for edit and playback
|
||||
SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions", SM_BackFromInsertAttackModifiers );
|
||||
}
|
||||
@@ -2142,7 +2142,7 @@ void ScreenEdit::HandleBGChangeChoice( BGChangeChoice c, int* iAnswers )
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
};
|
||||
|
||||
change.m_fRate = (float)atof( g_BGChange.rows[rate].choices[iAnswers[rate]] )/100.f;
|
||||
change.m_fRate = strtof( g_BGChange.rows[rate].choices[iAnswers[rate]], NULL )/100.f;
|
||||
change.m_bFadeLast = !!iAnswers[fade_last];
|
||||
change.m_bRewindMovie = !!iAnswers[rewind_movie];
|
||||
change.m_bLoop = !!iAnswers[loop];
|
||||
|
||||
@@ -564,7 +564,7 @@ int ThemeManager::GetMetricI( CString sClassName, CString sValueName )
|
||||
|
||||
float ThemeManager::GetMetricF( CString sClassName, CString sValueName )
|
||||
{
|
||||
return (float)atof( GetMetricRaw(sClassName,sValueName) );
|
||||
return strtof( GetMetricRaw(sClassName,sValueName), NULL );
|
||||
}
|
||||
|
||||
// #include "LuaHelpers.h"
|
||||
|
||||
@@ -293,7 +293,7 @@ bool UnlockSystem::Load()
|
||||
|
||||
LOG->Trace("UnlockTypes line: %s", UnlockTypes[j].c_str() );
|
||||
|
||||
const float fVal = (float) atof( readparam[1] );
|
||||
const float fVal = strtof( readparam[1], NULL );
|
||||
const int iVal = atoi( readparam[1] );
|
||||
|
||||
const UnlockType ut = StringToUnlockType( unlock_type );
|
||||
|
||||
@@ -596,14 +596,14 @@ bool XNode::GetXML( RageFile &f, DISP_OPT *opt /*= &optDefault*/ )
|
||||
//========================================================
|
||||
void XNode::GetValue(CString &out) const { out = value; }
|
||||
void XNode::GetValue(int &out) const { out = atoi(value); }
|
||||
void XNode::GetValue(float &out) const { out = (float) atof(value); }
|
||||
void XNode::GetValue(float &out) const { out = strtof(value, NULL); }
|
||||
void XNode::GetValue(bool &out) const { out = atoi(value) != 0; }
|
||||
void XNode::GetValue(unsigned &out) const { out = (unsigned)atoi(value) != 0; }
|
||||
void XNode::GetValue(DateTime &out) const { out.FromString( value ); }
|
||||
|
||||
void XAttr::GetValue(CString &out) const { out = value; }
|
||||
void XAttr::GetValue(int &out) const { out = atoi(value); }
|
||||
void XAttr::GetValue(float &out) const { out = (float) atof(value); }
|
||||
void XAttr::GetValue(float &out) const { out = strtof(value, NULL); }
|
||||
void XAttr::GetValue(bool &out) const { out = atoi(value) != 0; }
|
||||
void XAttr::GetValue(unsigned &out) const { out = (unsigned)atoi(value) != 0; }
|
||||
void XAttr::GetValue(DateTime &out) const { out.FromString( value ); }
|
||||
|
||||
Reference in New Issue
Block a user