Standardize conversion processes.

Too many arguments for or against the many methods:
stick to one inside a common function.

This commit will force recompilation of many files.
This commit is contained in:
Jason Felds
2011-05-11 15:58:31 -04:00
parent 212a3b971f
commit da51e26d07
29 changed files with 125 additions and 104 deletions
+4 -4
View File
@@ -388,7 +388,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
pNode->GetAttrValue( "Stretch", bStretch ); pNode->GetAttrValue( "Stretch", bStretch );
// Check for string match first, then do integer match. // Check for string match first, then do integer match.
// "if(atoi(type)==0)" was matching against all string matches. // "if(StringType(type)==0)" was matching against all string matches.
// -Chris // -Chris
if( stricmp(type,"sprite")==0 ) if( stricmp(type,"sprite")==0 )
{ {
@@ -402,16 +402,16 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
{ {
m_Type = TYPE_TILES; m_Type = TYPE_TILES;
} }
else if( atoi(type) == 1 ) else if( StringToInt(type) == 1 )
{ {
m_Type = TYPE_SPRITE; m_Type = TYPE_SPRITE;
bStretch = true; bStretch = true;
} }
else if( atoi(type) == 2 ) else if( StringToInt(type) == 2 )
{ {
m_Type = TYPE_PARTICLES; m_Type = TYPE_PARTICLES;
} }
else if( atoi(type) == 3 ) else if( StringToInt(type) == 3 )
{ {
m_Type = TYPE_TILES; m_Type = TYPE_TILES;
} }
+10 -10
View File
@@ -85,7 +85,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
} }
else if( 0 == stricmp(sValueName, "LIVES") ) else if( 0 == stricmp(sValueName, "LIVES") )
{ {
out.m_iLives = max( atoi(sParams[1]), 0 ); out.m_iLives = max( StringToInt(sParams[1]), 0 );
} }
else if( 0 == stricmp(sValueName, "GAINSECONDS") ) else if( 0 == stricmp(sValueName, "GAINSECONDS") )
{ {
@@ -95,7 +95,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
{ {
if( sParams.params.size() == 2 ) if( sParams.params.size() == 2 )
{ {
out.m_iCustomMeter[Difficulty_Medium] = max( atoi(sParams[1]), 0 ); /* compat */ out.m_iCustomMeter[Difficulty_Medium] = max( StringToInt(sParams[1]), 0 ); /* compat */
} }
else if( sParams.params.size() == 3 ) else if( sParams.params.size() == 3 )
{ {
@@ -105,7 +105,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
LOG->UserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() ); LOG->UserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() );
continue; continue;
} }
out.m_iCustomMeter[cd] = max( atoi(sParams[2]), 0 ); out.m_iCustomMeter[cd] = max( StringToInt(sParams[2]), 0 );
} }
} }
// todo: add COMBO and COMBOMODE from DWI CRS files? -aj // todo: add COMBO and COMBOMODE from DWI CRS files? -aj
@@ -167,28 +167,28 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
// most played // most played
if( sParams[1].Left(strlen("BEST")) == "BEST" ) if( sParams[1].Left(strlen("BEST")) == "BEST" )
{ {
new_entry.iChooseIndex = atoi( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1; new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1;
CLAMP( new_entry.iChooseIndex, 0, 500 ); CLAMP( new_entry.iChooseIndex, 0, 500 );
new_entry.songSort = SongSort_MostPlays; new_entry.songSort = SongSort_MostPlays;
} }
// least played // least played
else if( sParams[1].Left(strlen("WORST")) == "WORST" ) else if( sParams[1].Left(strlen("WORST")) == "WORST" )
{ {
new_entry.iChooseIndex = atoi( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1; new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1;
CLAMP( new_entry.iChooseIndex, 0, 500 ); CLAMP( new_entry.iChooseIndex, 0, 500 );
new_entry.songSort = SongSort_FewestPlays; new_entry.songSort = SongSort_FewestPlays;
} }
// best grades // best grades
else if( sParams[1].Left(strlen("GRADEBEST")) == "GRADEBEST" ) else if( sParams[1].Left(strlen("GRADEBEST")) == "GRADEBEST" )
{ {
new_entry.iChooseIndex = atoi( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1; new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1;
CLAMP( new_entry.iChooseIndex, 0, 500 ); CLAMP( new_entry.iChooseIndex, 0, 500 );
new_entry.songSort = SongSort_TopGrades; new_entry.songSort = SongSort_TopGrades;
} }
// worst grades // worst grades
else if( sParams[1].Left(strlen("GRADEWORST")) == "GRADEWORST" ) else if( sParams[1].Left(strlen("GRADEWORST")) == "GRADEWORST" )
{ {
new_entry.iChooseIndex = atoi( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1; new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1;
CLAMP( new_entry.iChooseIndex, 0, 500 ); CLAMP( new_entry.iChooseIndex, 0, 500 );
new_entry.songSort = SongSort_LowestGrades; new_entry.songSort = SongSort_LowestGrades;
} }
@@ -284,7 +284,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
else if( !sMod.CompareNoCase("nodifficult") ) else if( !sMod.CompareNoCase("nodifficult") )
new_entry.bNoDifficult = true; new_entry.bNoDifficult = true;
else if( sMod.length() > 5 && !sMod.Left(5).CompareNoCase("award") ) else if( sMod.length() > 5 && !sMod.Left(5).CompareNoCase("award") )
new_entry.iGainLives = atoi( sMod.substr(5).c_str() ); new_entry.iGainLives = StringToInt( sMod.substr(5) );
else else
continue; continue;
mods.erase( mods.begin() + j ); mods.erase( mods.begin() + j );
@@ -306,8 +306,8 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
else if( bFromCache && !stricmp(sValueName, "RADAR") ) else if( bFromCache && !stricmp(sValueName, "RADAR") )
{ {
StepsType st = (StepsType) atoi(sParams[1]); StepsType st = (StepsType) StringToInt(sParams[1]);
CourseDifficulty cd = (CourseDifficulty) atoi( sParams[2] ); CourseDifficulty cd = (CourseDifficulty) StringToInt( sParams[2] );
RadarValues rv; RadarValues rv;
rv.FromString( sParams[3] ); rv.FromString( sParams[3] );
+3 -3
View File
@@ -272,14 +272,14 @@ void FileTransfer::HTTPUpdate()
m_sResponseName = "Malformed response."; m_sResponseName = "Malformed response.";
return; return;
} }
m_iResponseCode = atoi(m_sBUFFER.substr(i+1,j-i).c_str()); m_iResponseCode = StringToInt(m_sBUFFER.substr(i+1,j-i));
m_sResponseName = m_sBUFFER.substr( j+1, k-j ); m_sResponseName = m_sBUFFER.substr( j+1, k-j );
i = m_sBUFFER.find("Content-Length:"); i = m_sBUFFER.find("Content-Length:");
j = m_sBUFFER.find("\n", i+1 ); j = m_sBUFFER.find("\n", i+1 );
if( i != string::npos ) if( i != string::npos )
m_iTotalBytes = atoi(m_sBUFFER.substr(i+16,j-i).c_str()); m_iTotalBytes = StringToInt(m_sBUFFER.substr(i+16,j-i));
else else
m_iTotalBytes = -1; // We don't know, so go until disconnect m_iTotalBytes = -1; // We don't know, so go until disconnect
@@ -350,7 +350,7 @@ bool FileTransfer::ParseHTTPAddress( const RString &URL, RString &sProto, RStrin
sServer = asMatches[1]; sServer = asMatches[1];
if( asMatches[3] != "" ) if( asMatches[3] != "" )
{ {
iPort = atoi(asMatches[3]); iPort = StringToInt(asMatches[3]);
if( iPort == 0 ) if( iPort == 0 )
return false; return false;
} }
+2 -2
View File
@@ -414,7 +414,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
// If val is an integer, it's a width, eg. "10=27". // If val is an integer, it's a width, eg. "10=27".
if( IsAnInt(sName) ) if( IsAnInt(sName) )
{ {
cfg.m_mapGlyphWidths[atoi(sName)] = pValue->GetValue<int>(); cfg.m_mapGlyphWidths[StringToInt(sName)] = pValue->GetValue<int>();
continue; continue;
} }
@@ -516,7 +516,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
TrimLeft( sRowStr ); TrimLeft( sRowStr );
ASSERT( IsAnInt(sRowStr) ); ASSERT( IsAnInt(sRowStr) );
const int iRow = atoi( sRowStr.c_str() ); const int iRow = StringToInt( sRowStr );
const int iFirstFrame = iRow * iNumFramesWide; const int iFirstFrame = iRow * iNumFramesWide;
if( iRow > iNumFramesHigh ) if( iRow > iNumFramesHigh )
+2 -2
View File
@@ -335,12 +335,12 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "weight" ) else if( sName == "weight" )
{ {
m_iWeightPounds = atoi( sValue ); m_iWeightPounds = StringToInt( sValue );
} }
else if( sName == "goalcalories" ) else if( sName == "goalcalories" )
{ {
m_iGoalCalories = atoi( sValue ); m_iGoalCalories = StringToInt( sValue );
} }
else if( sName == "goaltype" ) else if( sName == "goaltype" )
+1 -1
View File
@@ -209,7 +209,7 @@ void GameState::ApplyCmdline()
RString sPlayer; RString sPlayer;
for( int i = 0; GetCommandlineArgument( "player", &sPlayer, i ); ++i ) for( int i = 0; GetCommandlineArgument( "player", &sPlayer, i ); ++i )
{ {
int pn = atoi( sPlayer )-1; int pn = StringToInt( sPlayer )-1;
if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS ) if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS )
RageException::Throw( "Invalid argument \"--player=%s\".", sPlayer.c_str() ); RageException::Throw( "Invalid argument \"--player=%s\".", sPlayer.c_str() );
+1 -1
View File
@@ -11,7 +11,7 @@
#include "Command.h" #include "Command.h"
#include "RageTypes.h" #include "RageTypes.h"
#include <sstream> #include <sstream> // conversion for lua functions.
#include <csetjmp> #include <csetjmp>
#include <cassert> #include <cassert>
#include <map> #include <map>
+3 -2
View File
@@ -251,7 +251,7 @@ RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &s
int NoteSkinManager::GetMetricI( const RString &sButtonName, const RString &sValueName ) int NoteSkinManager::GetMetricI( const RString &sButtonName, const RString &sValueName )
{ {
return atoi( GetMetric(sButtonName,sValueName) ); return StringToInt( GetMetric(sButtonName,sValueName) );
} }
float NoteSkinManager::GetMetricF( const RString &sButtonName, const RString &sValueName ) float NoteSkinManager::GetMetricF( const RString &sButtonName, const RString &sValueName )
@@ -261,7 +261,8 @@ float NoteSkinManager::GetMetricF( const RString &sButtonName, const RString &sV
bool NoteSkinManager::GetMetricB( const RString &sButtonName, const RString &sValueName ) bool NoteSkinManager::GetMetricB( const RString &sButtonName, const RString &sValueName )
{ {
return atoi( GetMetric(sButtonName,sValueName) ) != 0; // Could also call GetMetricI here...hmm.
return StringToInt( GetMetric(sButtonName,sValueName) ) != 0;
} }
apActorCommands NoteSkinManager::GetMetricA( const RString &sButtonName, const RString &sValueName ) apActorCommands NoteSkinManager::GetMetricA( const RString &sButtonName, const RString &sValueName )
+8 -8
View File
@@ -398,8 +398,8 @@ static void ReadTimeSigs( const NameToData_t &mapNameToData, MeasureToTimeSig_t
if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) ) if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) )
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
int iMeasureNo = atoi( sName.substr(1, 3).c_str() ); int iMeasureNo = StringToInt( sName.substr(1, 3) );
int iBMSTrackNo = atoi( sName.substr(4, 2).c_str() ); int iBMSTrackNo = StringToInt( sName.substr(4, 2) );
RString nData = it->second; RString nData = it->second;
int totalPairs = nData.size() / 2; int totalPairs = nData.size() / 2;
if( iBMSTrackNo != BMS_TRACK_TIME_SIG && iBMSTrackNo != 7 ) if( iBMSTrackNo != BMS_TRACK_TIME_SIG && iBMSTrackNo != 7 )
@@ -423,10 +423,10 @@ static void ReadTimeSigs( const NameToData_t &mapNameToData, MeasureToTimeSig_t
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
const RString &sData = it->second; const RString &sData = it->second;
int iMeasureNo = atoi( sName.substr(1, 3).c_str() ); int iMeasureNo = StringToInt( sName.substr(1, 3) );
if( iMeasureNo < iStartMeasureNo ) if( iMeasureNo < iStartMeasureNo )
continue; continue;
int iBMSTrackNo = atoi( sName.substr(4, 2).c_str() ); int iBMSTrackNo = StringToInt( sName.substr(4, 2) );
if( iBMSTrackNo == BMS_TRACK_TIME_SIG ) if( iBMSTrackNo == BMS_TRACK_TIME_SIG )
out[iMeasureNo] = StringToFloat( sData ); out[iMeasureNo] = StringToFloat( sData );
} }
@@ -446,9 +446,9 @@ static bool LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNameTo
int iPlayer = -1; int iPlayer = -1;
RString sData; RString sData;
if( GetTagFromMap( mapNameToData, "#player", sData ) ) if( GetTagFromMap( mapNameToData, "#player", sData ) )
iPlayer = atoi(sData); iPlayer = StringToInt(sData);
if( GetTagFromMap( mapNameToData, "#playlevel", sData ) ) if( GetTagFromMap( mapNameToData, "#playlevel", sData ) )
out.SetMeter( atoi(sData) ); out.SetMeter( StringToInt(sData) );
NoteData ndNotes; NoteData ndNotes;
ndNotes.SetNumTracks( NUM_BMS_TRACKS ); ndNotes.SetNumTracks( NUM_BMS_TRACKS );
@@ -475,8 +475,8 @@ static bool LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNameTo
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
int iMeasureNo = atoi( sName.substr(1,3).c_str() ); int iMeasureNo = StringToInt( sName.substr(1,3) );
int iRawTrackNum = atoi( sName.substr(4,2).c_str() ); int iRawTrackNum = StringToInt( sName.substr(4,2) );
int iRowNo = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo, sigAdjustments ); int iRowNo = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo, sigAdjustments );
float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo, sigAdjustments ); float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo, sigAdjustments );
const RString &sNoteData = it->second; const RString &sNoteData = it->second;
+2 -2
View File
@@ -206,7 +206,7 @@ static bool LoadFromDWITokens(
DEFAULT_FAIL( out.m_StepsType ); DEFAULT_FAIL( out.m_StepsType );
} }
int iNumFeet = atoi(sNumFeet); int iNumFeet = StringToInt(sNumFeet);
// out.SetDescription(sDescription); // Don't put garbage in the description. // out.SetDescription(sDescription); // Don't put garbage in the description.
out.SetMeter(iNumFeet); out.SetMeter(iNumFeet);
out.SetDifficulty( DwiCompatibleStringToDifficulty(sDescription) ); out.SetDifficulty( DwiCompatibleStringToDifficulty(sDescription) );
@@ -517,7 +517,7 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
else if( 0==stricmp(sValueName,"GAP") ) else if( 0==stricmp(sValueName,"GAP") )
// the units of GAP is 1/1000 second // the units of GAP is 1/1000 second
out.m_Timing.m_fBeat0OffsetInSeconds = -atoi( sParams[1] ) / 1000.0f; out.m_Timing.m_fBeat0OffsetInSeconds = -StringToInt( sParams[1] ) / 1000.0f;
else if( 0==stricmp(sValueName,"SAMPLESTART") ) else if( 0==stricmp(sValueName,"SAMPLESTART") )
out.m_fMusicSampleStartSeconds = ParseBrokenDWITimestamp(sParams[1], sParams[2], sParams[3]); out.m_fMusicSampleStartSeconds = ParseBrokenDWITimestamp(sParams[1], sParams[2], sParams[3]);
+4 -4
View File
@@ -35,7 +35,7 @@ static bool LoadFromKSFFile( const RString &sPath, Steps &out, const Song &song,
// handle the data // handle the data
if( sValueName=="TICKCOUNT" ) if( sValueName=="TICKCOUNT" )
{ {
iTickCount = atoi( sParams[1] ); iTickCount = StringToInt( sParams[1] );
if( iTickCount <= 0 ) if( iTickCount <= 0 )
{ {
LOG->UserLog( "Song file", sPath, "has an invalid tick count: %d.", iTickCount ); LOG->UserLog( "Song file", sPath, "has an invalid tick count: %d.", iTickCount );
@@ -50,7 +50,7 @@ static bool LoadFromKSFFile( const RString &sPath, Steps &out, const Song &song,
} }
else if( sValueName=="DIFFICULTY" ) else if( sValueName=="DIFFICULTY" )
{ {
out.SetMeter( max(atoi(sParams[1]), 0) ); out.SetMeter( max(StringToInt(sParams[1]), 0) );
} }
// new cases from Aldo_MX's fork: // new cases from Aldo_MX's fork:
else if( sValueName=="PLAYER" ) else if( sValueName=="PLAYER" )
@@ -190,7 +190,7 @@ static bool LoadFromKSFFile( const RString &sPath, Steps &out, const Song &song,
else if ( BeginsWith(sRowString, "|T") ) else if ( BeginsWith(sRowString, "|T") )
{ {
RString temp = sRowString.substr(2,sRowString.size()-3); RString temp = sRowString.substr(2,sRowString.size()-3);
newTick = atoi(temp); newTick = StringToInt(temp);
bTickChangeNeeded = true; bTickChangeNeeded = true;
continue; continue;
} }
@@ -401,7 +401,7 @@ static bool LoadGlobalData( const RString &sPath, Song &out, bool &bKIUCompliant
/* TICKCOUNT will be used below if there are DM compliant BPM changes /* TICKCOUNT will be used below if there are DM compliant BPM changes
* and stops. It will be called again in LoadFromKSFFile for the * and stops. It will be called again in LoadFromKSFFile for the
* actual steps. */ * actual steps. */
iTickCount = atoi( sParams[1] ); iTickCount = StringToInt( sParams[1] );
iTickCount = iTickCount > 0 ? iTickCount : 2; // again, Direct Move uses 4 as a default. iTickCount = iTickCount > 0 ? iTickCount : 2; // again, Direct Move uses 4 as a default.
// add a tickcount for those using the [Player] // add a tickcount for those using the [Player]
// CheckpointsUseTimeSignatures metric. -aj // CheckpointsUseTimeSignatures metric. -aj
+8 -8
View File
@@ -346,8 +346,8 @@ static void ReadTimeSigs( const NameToData_t &mapNameToData, MeasureToTimeSig_t
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
const RString &sData = it->second; const RString &sData = it->second;
int iMeasureNo = atoi( sName.substr(1, 3).c_str() ); int iMeasureNo = StringToInt( sName.substr(1, 3) );
int iPMSTrackNo = atoi( sName.substr(4, 2).c_str() ); int iPMSTrackNo = StringToInt( sName.substr(4, 2) );
if( iPMSTrackNo == PMS_TRACK_TIME_SIG ) if( iPMSTrackNo == PMS_TRACK_TIME_SIG )
out[iMeasureNo] = StringToFloat( sData ); out[iMeasureNo] = StringToFloat( sData );
} }
@@ -367,9 +367,9 @@ static bool LoadFromPMSFile( const RString &sPath, const NameToData_t &mapNameTo
int iPlayer = -1; int iPlayer = -1;
RString sData; RString sData;
if( GetTagFromMap( mapNameToData, "#player", sData ) ) if( GetTagFromMap( mapNameToData, "#player", sData ) )
iPlayer = atoi(sData); iPlayer = StringToInt(sData);
if( GetTagFromMap( mapNameToData, "#playlevel", sData ) ) if( GetTagFromMap( mapNameToData, "#playlevel", sData ) )
out.SetMeter( atoi(sData) ); out.SetMeter( StringToInt(sData) );
NoteData ndNotes; NoteData ndNotes;
ndNotes.SetNumTracks( NUM_PMS_TRACKS ); ndNotes.SetNumTracks( NUM_PMS_TRACKS );
@@ -396,8 +396,8 @@ static bool LoadFromPMSFile( const RString &sPath, const NameToData_t &mapNameTo
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
int iMeasureNo = atoi( sName.substr(1,3).c_str() ); int iMeasureNo = StringToInt( sName.substr(1,3) );
int iRawTrackNum = atoi( sName.substr(4,2).c_str() ); int iRawTrackNum = StringToInt( sName.substr(4,2) );
int iRowNo = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo, sigAdjustments ); int iRowNo = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo, sigAdjustments );
float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo, sigAdjustments ); float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo, sigAdjustments );
const RString &sNoteData = it->second; const RString &sNoteData = it->second;
@@ -649,8 +649,8 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) ) if( sName.size() != 6 || sName[0] != '#' || !IsAnInt( sName.substr(1,5) ) )
continue; continue;
// this is step or offset data. Looks like "#00705" // this is step or offset data. Looks like "#00705"
int iMeasureNo = atoi( sName.substr(1, 3).c_str() ); int iMeasureNo = StringToInt( sName.substr(1, 3) );
int iPMSTrackNo = atoi( sName.substr(4, 2).c_str() ); int iPMSTrackNo = StringToInt( sName.substr(4, 2) );
int iStepIndex = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo, sigAdjustmentsOut ); int iStepIndex = GetMeasureStartRow( mapMeasureToTimeSig, iMeasureNo, sigAdjustmentsOut );
float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo, sigAdjustmentsOut ); float fBeatsPerMeasure = GetBeatsPerMeasure( mapMeasureToTimeSig, iMeasureNo, sigAdjustmentsOut );
int iRowsPerMeasure = BeatToNoteRow( fBeatsPerMeasure ); int iRowsPerMeasure = BeatToNoteRow( fBeatsPerMeasure );
+10 -10
View File
@@ -60,7 +60,7 @@ void SMLoader::LoadFromSMTokens(
out.SetDifficulty( Difficulty_Challenge ); out.SetDifficulty( Difficulty_Challenge );
} }
out.SetMeter( atoi(sMeter) ); out.SetMeter( StringToInt(sMeter) );
vector<RString> saValues; vector<RString> saValues;
split( sRadarValues, ",", saValues, true ); split( sRadarValues, ",", saValues, true );
int categories = NUM_RadarCategory - 1; // Fakes aren't counted in the radar values. int categories = NUM_RadarCategory - 1; // Fakes aren't counted in the radar values.
@@ -309,8 +309,8 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
TimeSignatureSegment seg; TimeSignatureSegment seg;
seg.m_iStartRow = BeatToNoteRow(fBeat); seg.m_iStartRow = BeatToNoteRow(fBeat);
seg.m_iNumerator = atoi( vs2[1] ); seg.m_iNumerator = StringToInt( vs2[1] );
seg.m_iDenominator = atoi( vs2[2] ); seg.m_iDenominator = StringToInt( vs2[2] );
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -352,7 +352,7 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
} }
const float fTickcountBeat = StringToFloat( arrayTickcountValues[0] ); const float fTickcountBeat = StringToFloat( arrayTickcountValues[0] );
int iTicks = atoi( arrayTickcountValues[1] ); int iTicks = StringToInt( arrayTickcountValues[1] );
// you're lazy, let SM do the work for you... -DaisuMaster // you're lazy, let SM do the work for you... -DaisuMaster
if( iTicks < 1) iTicks = 1; if( iTicks < 1) iTicks = 1;
if( iTicks > ROWS_PER_BEAT ) iTicks = ROWS_PER_BEAT; if( iTicks > ROWS_PER_BEAT ) iTicks = ROWS_PER_BEAT;
@@ -411,7 +411,7 @@ bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString
// Backward compatibility: // Backward compatibility:
if( change.m_def.m_sEffect.empty() ) if( change.m_def.m_sEffect.empty() )
{ {
bool bLoop = atoi( aBGChangeValues[5] ) != 0; bool bLoop = StringToInt( aBGChangeValues[5] ) != 0;
if( !bLoop ) if( !bLoop )
change.m_def.m_sEffect = SBE_StretchNoLoop; change.m_def.m_sEffect = SBE_StretchNoLoop;
} }
@@ -421,7 +421,7 @@ bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString
// Backward compatibility: // Backward compatibility:
if( change.m_def.m_sEffect.empty() ) if( change.m_def.m_sEffect.empty() )
{ {
bool bRewindMovie = atoi( aBGChangeValues[4] ) != 0; bool bRewindMovie = StringToInt( aBGChangeValues[4] ) != 0;
if( bRewindMovie ) if( bRewindMovie )
change.m_def.m_sEffect = SBE_StretchRewind; change.m_def.m_sEffect = SBE_StretchRewind;
} }
@@ -430,7 +430,7 @@ bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString
// param 9 overrides this. // param 9 overrides this.
// Backward compatibility: // Backward compatibility:
if( change.m_sTransition.empty() ) if( change.m_sTransition.empty() )
change.m_sTransition = (atoi( aBGChangeValues[3] ) != 0) ? "CrossFade" : ""; change.m_sTransition = (StringToInt( aBGChangeValues[3] ) != 0) ? "CrossFade" : "";
// fall through // fall through
case 3: case 3:
change.m_fRate = StringToFloat( aBGChangeValues[2] ); change.m_fRate = StringToFloat( aBGChangeValues[2] );
@@ -560,12 +560,12 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
else if( sValueName=="HASMUSIC" ) else if( sValueName=="HASMUSIC" )
{ {
if( bFromCache ) if( bFromCache )
out.m_bHasMusic = atoi( sParams[1] ) != 0; out.m_bHasMusic = StringToInt( sParams[1] ) != 0;
} }
else if( sValueName=="HASBANNER" ) else if( sValueName=="HASBANNER" )
{ {
if( bFromCache ) if( bFromCache )
out.m_bHasBanner = atoi( sParams[1] ) != 0; out.m_bHasBanner = StringToInt( sParams[1] ) != 0;
} }
else if( sValueName=="SAMPLESTART" ) else if( sValueName=="SAMPLESTART" )
@@ -609,7 +609,7 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
* used 3.9+ features are not excluded here */ * used 3.9+ features are not excluded here */
else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES")) else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if( atoi(sParams[1]) > 0 ) else if( StringToInt(sParams[1]) > 0 )
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else else
LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() ); LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() );
+4 -4
View File
@@ -59,7 +59,7 @@ void SMALoader::LoadFromSMATokens(
out.SetDifficulty( Difficulty_Challenge ); out.SetDifficulty( Difficulty_Challenge );
} }
out.SetMeter( atoi(sMeter) ); out.SetMeter( StringToInt(sMeter) );
vector<RString> saValues; vector<RString> saValues;
split( sRadarValues, ",", saValues, true ); split( sRadarValues, ",", saValues, true );
int categories = NUM_RadarCategory - 1; // Fakes aren't counted in the radar values. int categories = NUM_RadarCategory - 1; // Fakes aren't counted in the radar values.
@@ -257,7 +257,7 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out )
* used 3.9+ features are not excluded here */ * used 3.9+ features are not excluded here */
else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES")) else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if( atoi(sParams[1]) > 0 ) else if( StringToInt(sParams[1]) > 0 )
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else else
LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() ); LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() );
@@ -430,13 +430,13 @@ void SMALoader::LoadTimingFromSMAFile( const MsdFile &msd, TimingData &out )
break; break;
} }
encountered = true; encountered = true;
rowsPerMeasure = atoi( sParams[1] ); rowsPerMeasure = StringToInt( sParams[1] );
} }
else if( sValueName=="BEATSPERMEASURE" ) else if( sValueName=="BEATSPERMEASURE" )
{ {
TimeSignatureSegment new_seg; TimeSignatureSegment new_seg;
new_seg.m_iStartRow = 0; new_seg.m_iStartRow = 0;
new_seg.m_iNumerator = atoi( sParams[1] ); new_seg.m_iNumerator = StringToInt( sParams[1] );
new_seg.m_iDenominator = 4; new_seg.m_iDenominator = 4;
out.AddTimeSignatureSegment( new_seg ); out.AddTimeSignatureSegment( new_seg );
} }
+12 -12
View File
@@ -61,7 +61,7 @@ bool LoadFromBGSSCChangesString( BackgroundChange &change, const RString &sBGCha
// Backward compatibility: // Backward compatibility:
if( change.m_def.m_sEffect.empty() ) if( change.m_def.m_sEffect.empty() )
{ {
bool bLoop = atoi( aBGChangeValues[5] ) != 0; bool bLoop = StringToInt( aBGChangeValues[5] ) != 0;
if( !bLoop ) if( !bLoop )
change.m_def.m_sEffect = SBE_StretchNoLoop; change.m_def.m_sEffect = SBE_StretchNoLoop;
} }
@@ -71,7 +71,7 @@ bool LoadFromBGSSCChangesString( BackgroundChange &change, const RString &sBGCha
// Backward compatibility: // Backward compatibility:
if( change.m_def.m_sEffect.empty() ) if( change.m_def.m_sEffect.empty() )
{ {
bool bRewindMovie = atoi( aBGChangeValues[4] ) != 0; bool bRewindMovie = StringToInt( aBGChangeValues[4] ) != 0;
if( bRewindMovie ) if( bRewindMovie )
change.m_def.m_sEffect = SBE_StretchRewind; change.m_def.m_sEffect = SBE_StretchRewind;
} }
@@ -80,7 +80,7 @@ bool LoadFromBGSSCChangesString( BackgroundChange &change, const RString &sBGCha
// param 9 overrides this. // param 9 overrides this.
// Backward compatibility: // Backward compatibility:
if( change.m_sTransition.empty() ) if( change.m_sTransition.empty() )
change.m_sTransition = (atoi( aBGChangeValues[3] ) != 0) ? "CrossFade" : ""; change.m_sTransition = (StringToInt( aBGChangeValues[3] ) != 0) ? "CrossFade" : "";
// fall through // fall through
case 3: case 3:
change.m_fRate = StringToFloat( aBGChangeValues[2] ); change.m_fRate = StringToFloat( aBGChangeValues[2] );
@@ -287,7 +287,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
* used 3.9+ features are not excluded here */ * used 3.9+ features are not excluded here */
else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES")) else if(!stricmp(sParams[1],"ES") || !stricmp(sParams[1],"OMES"))
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else if( atoi(sParams[1]) > 0 ) else if( StringToInt(sParams[1]) > 0 )
out.m_SelectionDisplay = out.SHOW_ALWAYS; out.m_SelectionDisplay = out.SHOW_ALWAYS;
else else
LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() ); LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() );
@@ -570,8 +570,8 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
TimeSignatureSegment seg; TimeSignatureSegment seg;
seg.m_iStartRow = BeatToNoteRow(fBeat); seg.m_iStartRow = BeatToNoteRow(fBeat);
seg.m_iNumerator = atoi( vs2[1] ); seg.m_iNumerator = StringToInt( vs2[1] );
seg.m_iDenominator = atoi( vs2[2] ); seg.m_iDenominator = StringToInt( vs2[2] );
if( fBeat < 0 ) if( fBeat < 0 )
{ {
@@ -613,7 +613,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
} }
const float fTickcountBeat = StringToFloat( arrayTickcountValues[0] ); const float fTickcountBeat = StringToFloat( arrayTickcountValues[0] );
const int iTicks = atoi( arrayTickcountValues[1] ); const int iTicks = StringToInt( arrayTickcountValues[1] );
TickcountSegment new_seg( BeatToNoteRow(fTickcountBeat), iTicks ); TickcountSegment new_seg( BeatToNoteRow(fTickcountBeat), iTicks );
if(iTicks >= 1 && iTicks <= ROWS_PER_BEAT ) // Constants if(iTicks >= 1 && iTicks <= ROWS_PER_BEAT ) // Constants
@@ -644,7 +644,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
continue; continue;
} }
const float fComboBeat = StringToFloat( arrayComboValues[0] ); const float fComboBeat = StringToFloat( arrayComboValues[0] );
const int iCombos = atoi( arrayComboValues[1] ); const int iCombos = StringToInt( arrayComboValues[1] );
ComboSegment new_seg( BeatToNoteRow( fComboBeat ), iCombos ); ComboSegment new_seg( BeatToNoteRow( fComboBeat ), iCombos );
out.m_Timing.AddComboSegment( new_seg ); out.m_Timing.AddComboSegment( new_seg );
} }
@@ -673,13 +673,13 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
else if( sValueName=="HASMUSIC" ) else if( sValueName=="HASMUSIC" )
{ {
if( bFromCache ) if( bFromCache )
out.m_bHasMusic = atoi( sParams[1] ) != 0; out.m_bHasMusic = StringToInt( sParams[1] ) != 0;
} }
else if( sValueName=="HASBANNER" ) else if( sValueName=="HASBANNER" )
{ {
if( bFromCache ) if( bFromCache )
out.m_bHasBanner = atoi( sParams[1] ) != 0; out.m_bHasBanner = StringToInt( sParams[1] ) != 0;
} }
// This tag will get us to the next section. // This tag will get us to the next section.
@@ -714,7 +714,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
else if( sValueName=="METER" ) else if( sValueName=="METER" )
{ {
pNewNotes->SetMeter( atoi( sParams[1] ) ); pNewNotes->SetMeter( StringToInt( sParams[1] ) );
} }
else if( sValueName=="RADARVALUES" ) else if( sValueName=="RADARVALUES" )
@@ -986,7 +986,7 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
else if( sValueName=="METER" ) else if( sValueName=="METER" )
{ {
pNewNotes->SetMeter( atoi( sParams[1] ) ); pNewNotes->SetMeter( StringToInt( sParams[1] ) );
bSSCFormat = true; bSSCFormat = true;
} }
+3 -3
View File
@@ -154,7 +154,7 @@ public:
RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() ); RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() );
m_Def.m_bOneChoiceForAllPlayers = false; m_Def.m_bOneChoiceForAllPlayers = false;
const int NumCols = atoi( lCmds.v[0].m_vsArgs[0] ); const int NumCols = StringToInt( lCmds.v[0].m_vsArgs[0] );
for( unsigned i=1; i<lCmds.v.size(); i++ ) for( unsigned i=1; i<lCmds.v.size(); i++ )
{ {
const Command &cmd = lCmds.v[i]; const Command &cmd = lCmds.v[i];
@@ -165,7 +165,7 @@ public:
else if( sName == "selectone" ) m_Def.m_selectType = SELECT_ONE; else if( sName == "selectone" ) m_Def.m_selectType = SELECT_ONE;
else if( sName == "selectnone" ) m_Def.m_selectType = SELECT_NONE; else if( sName == "selectnone" ) m_Def.m_selectType = SELECT_NONE;
else if( sName == "showoneinrow" ) m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; else if( sName == "showoneinrow" ) m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
else if( sName == "default" ) m_Def.m_iDefault = atoi( cmd.GetArg(1).s ) - 1; // match ENTRY_MODE else if( sName == "default" ) m_Def.m_iDefault = StringToInt( cmd.GetArg(1).s ) - 1; // match ENTRY_MODE
else if( sName == "reloadrowmessages" ) else if( sName == "reloadrowmessages" )
{ {
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ ) for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
@@ -177,7 +177,7 @@ public:
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ ) for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
{ {
RString sArg = cmd.m_vsArgs[a]; RString sArg = cmd.m_vsArgs[a];
PlayerNumber pn = (PlayerNumber)(atoi(sArg)-1); PlayerNumber pn = (PlayerNumber)(StringToInt(sArg)-1);
ASSERT( pn >= 0 && pn < NUM_PLAYERS ); ASSERT( pn >= 0 && pn < NUM_PLAYERS );
m_Def.m_vEnabledForPlayers.insert( pn ); m_Def.m_vEnabledForPlayers.insert( pn );
} }
+1 -1
View File
@@ -299,7 +299,7 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
{ {
/* XXX We know what they want, is there any reason not to handle it? */ /* XXX We know what they want, is there any reason not to handle it? */
/* Yes. We should be strict in handling the format. -Chris */ /* Yes. We should be strict in handling the format. -Chris */
sErrorOut = ssprintf("Invalid player options \"%s\"; did you mean '*%d'?", s->c_str(), atoi(*s) ); sErrorOut = ssprintf("Invalid player options \"%s\"; did you mean '*%d'?", s->c_str(), StringToInt(*s) );
return false; return false;
} }
else else
+1 -1
View File
@@ -1922,7 +1922,7 @@ RString Profile::MakeUniqueFileNameNoExtension( RString sDir, RString sFileNameB
continue; continue;
ASSERT( matches.size() == 1 ); ASSERT( matches.size() == 1 );
iIndex = atoi( matches[0] )+1; iIndex = StringToInt( matches[0] )+1;
break; break;
} }
+1 -1
View File
@@ -429,7 +429,7 @@ bool ProfileManager::CreateLocalProfile( RString sName, RString &sProfileIDOut )
vector<RString> vs; vector<RString> vs;
GetLocalProfileIDs( vs ); GetLocalProfileIDs( vs );
FOREACH_CONST( RString, vs, s ) FOREACH_CONST( RString, vs, s )
iMaxProfileNumber = atoi( *s ); iMaxProfileNumber = StringToInt( *s );
int iProfileNumber = iMaxProfileNumber + 1; int iProfileNumber = iMaxProfileNumber + 1;
RString sProfileID = ssprintf( "%08d", iProfileNumber ); RString sProfileID = ssprintf( "%08d", iProfileNumber );
+2 -2
View File
@@ -26,8 +26,8 @@ static void GetResolutionFromFileName( RString sPath, int &iWidth, int &iHeight
if( !re.Compare(sPath, asMatches) ) if( !re.Compare(sPath, asMatches) )
return; return;
iWidth = atoi( asMatches[0].c_str() ); iWidth = StringToInt( asMatches[0] );
iHeight = atoi( asMatches[1].c_str() ); iHeight = StringToInt( asMatches[1] );
} }
RageBitmapTexture::RageBitmapTexture( RageTextureID name ) : RageBitmapTexture::RageBitmapTexture( RageTextureID name ) :
+2 -2
View File
@@ -51,8 +51,8 @@ void RageTexture::GetFrameDimensionsFromFileName( RString sPath, int* piFramesWi
*piFramesWide = *piFramesHigh = 1; *piFramesWide = *piFramesHigh = 1;
return; return;
} }
*piFramesWide = atoi(asMatch[0]); *piFramesWide = StringToInt(asMatch[0]);
*piFramesHigh = atoi(asMatch[1]); *piFramesHigh = StringToInt(asMatch[1]);
} }
const RectF *RageTexture::GetTextureCoordRect( int iFrameNo ) const const RectF *RageTexture::GetTextureCoordRect( int iFrameNo ) const
+18 -3
View File
@@ -10,6 +10,7 @@
#include <numeric> #include <numeric>
#include <ctime> #include <ctime>
#include <sstream>
#include <map> #include <map>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -193,8 +194,8 @@ float HHMMSSToSeconds( const RString &sHHMMSS )
arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits
float fSeconds = 0; float fSeconds = 0;
fSeconds += atoi( arrayBits[0] ) * 60 * 60; fSeconds += StringToInt( arrayBits[0] ) * 60 * 60;
fSeconds += atoi( arrayBits[1] ) * 60; fSeconds += StringToInt( arrayBits[1] ) * 60;
fSeconds += StringToFloat( arrayBits[2] ); fSeconds += StringToFloat( arrayBits[2] );
return fSeconds; return fSeconds;
@@ -1695,6 +1696,20 @@ void MakeLower( wchar_t *p, size_t iLen )
UnicodeUpperLower( p, iLen, g_LowerCase ); UnicodeUpperLower( p, iLen, g_LowerCase );
} }
int StringToInt( const RString &sString )
{
int ret;
istringstream ( sString ) >> ret;
return ret;
}
RString IntToString( const int &iNum )
{
stringstream ss;
ss << iNum;
return ss.str();
}
float StringToFloat( const RString &sString ) float StringToFloat( const RString &sString )
{ {
float ret = strtof( sString, NULL ); float ret = strtof( sString, NULL );
@@ -2141,7 +2156,7 @@ namespace StringConversion
if( sValue.size() == 0 ) if( sValue.size() == 0 )
return false; return false;
out = (atoi(sValue) != 0); out = (StringToInt(sValue) != 0);
return true; return true;
} }
+10
View File
@@ -405,6 +405,16 @@ void MakeUpper( char *p, size_t iLen );
void MakeLower( char *p, size_t iLen ); void MakeLower( char *p, size_t iLen );
void MakeUpper( wchar_t *p, size_t iLen ); void MakeUpper( wchar_t *p, size_t iLen );
void MakeLower( wchar_t *p, size_t iLen ); void MakeLower( wchar_t *p, size_t iLen );
/**
* @brief Have a standard way of converting Strings to integers.
* @param sString the string to convert.
* @return the integer we are after. */
int StringToInt( const RString &sString );
/**
* @brief Have a standard way of converting integers to Strings.
* @param iNum the integer to convert.
* @return the string we are after. */
RString IntToString( const int &iNum );
float StringToFloat( const RString &sString ); float StringToFloat( const RString &sString );
bool StringToFloat( const RString &sString, float &fOut ); bool StringToFloat( const RString &sString, float &fOut );
+5 -7
View File
@@ -2617,9 +2617,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
} }
else if( SM == SM_BackFromDifficultyMeterChange ) else if( SM == SM_BackFromDifficultyMeterChange )
{ {
int i; int i = StringToInt( ScreenTextEntry::s_sLastAnswer );
std::istringstream ss( ScreenTextEntry::s_sLastAnswer );
ss >> i;
GAMESTATE->m_pCurSteps[PLAYER_1]->SetMeter(i); GAMESTATE->m_pCurSteps[PLAYER_1]->SetMeter(i);
SetDirty( true ); SetDirty( true );
} }
@@ -2646,7 +2644,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
} }
else if( SM == SM_BackFromTimeSignatureNumeratorChange ) else if( SM == SM_BackFromTimeSignatureNumeratorChange )
{ {
int iNum = atoi( ScreenTextEntry::s_sLastAnswer ); int iNum = StringToInt( ScreenTextEntry::s_sLastAnswer );
if( iNum > 0 ) if( iNum > 0 )
{ {
m_pSong->m_Timing.SetTimeSignatureNumeratorAtBeat( GAMESTATE->m_fSongBeat, iNum ); m_pSong->m_Timing.SetTimeSignatureNumeratorAtBeat( GAMESTATE->m_fSongBeat, iNum );
@@ -2655,7 +2653,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
} }
else if ( SM == SM_BackFromTimeSignatureDenominatorChange ) else if ( SM == SM_BackFromTimeSignatureDenominatorChange )
{ {
int iDen = atoi( ScreenTextEntry::s_sLastAnswer ); int iDen = StringToInt( ScreenTextEntry::s_sLastAnswer );
if( iDen > 0) if( iDen > 0)
{ {
m_pSong->m_Timing.SetTimeSignatureDenominatorAtBeat( GAMESTATE->m_fSongBeat, iDen ); m_pSong->m_Timing.SetTimeSignatureDenominatorAtBeat( GAMESTATE->m_fSongBeat, iDen );
@@ -2664,7 +2662,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
} }
else if ( SM == SM_BackFromTickcountChange ) else if ( SM == SM_BackFromTickcountChange )
{ {
int iTick = atoi( ScreenTextEntry::s_sLastAnswer ); int iTick = StringToInt( ScreenTextEntry::s_sLastAnswer );
if ( iTick >= 0 && iTick <= ROWS_PER_BEAT ) if ( iTick >= 0 && iTick <= ROWS_PER_BEAT )
{ {
m_pSong->m_Timing.SetTickcountAtBeat( GAMESTATE->m_fSongBeat, iTick ); m_pSong->m_Timing.SetTickcountAtBeat( GAMESTATE->m_fSongBeat, iTick );
@@ -2673,7 +2671,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
} }
else if ( SM == SM_BackFromComboChange ) else if ( SM == SM_BackFromComboChange )
{ {
int iCombo = atoi( ScreenTextEntry::s_sLastAnswer ); int iCombo = StringToInt( ScreenTextEntry::s_sLastAnswer );
if ( iCombo >= 0 ) if ( iCombo >= 0 )
{ {
m_pSong->m_Timing.SetComboAtBeat( GAMESTATE->m_fSongBeat, iCombo ); m_pSong->m_Timing.SetComboAtBeat( GAMESTATE->m_fSongBeat, iCombo );
+1 -1
View File
@@ -2757,7 +2757,7 @@ void ScreenGameplay::SaveReplay()
continue; continue;
ASSERT( matches.size() == 1 ); ASSERT( matches.size() == 1 );
iIndex = atoi( matches[0] )+1; iIndex = StringToInt( matches[0] )+1;
break; break;
} }
+1 -4
View File
@@ -4,7 +4,6 @@
#define SCREEN_MINI_MENU_H #define SCREEN_MINI_MENU_H
#include "ScreenOptions.h" #include "ScreenOptions.h"
#include <sstream>
#include "GameConstantsAndTypes.h" #include "GameConstantsAndTypes.h"
typedef bool (*MenuRowUpdateEnabled)(); typedef bool (*MenuRowUpdateEnabled)();
@@ -86,9 +85,7 @@ struct MenuRowDef
{ {
for ( int i = low; i <= high; i++ ) for ( int i = low; i <= high; i++ )
{ {
std::stringstream ss; choices.push_back(IntToString(i).c_str());
ss << i;
choices.push_back(ss.str().c_str());
} }
} }
+3 -3
View File
@@ -622,14 +622,14 @@ void ScreenPackages::HTTPUpdate()
m_sResponseName = "Malformed response."; m_sResponseName = "Malformed response.";
return; return;
} }
m_iResponseCode = atoi(m_sBUFFER.substr(i+1,j-i).c_str()); m_iResponseCode = StringToInt(m_sBUFFER.substr(i+1,j-i));
m_sResponseName = m_sBUFFER.substr( j+1, k-j ); m_sResponseName = m_sBUFFER.substr( j+1, k-j );
i = m_sBUFFER.find("Content-Length:"); i = m_sBUFFER.find("Content-Length:");
j = m_sBUFFER.find("\n", i+1 ); j = m_sBUFFER.find("\n", i+1 );
if( i != string::npos ) if( i != string::npos )
m_iTotalBytes = atoi(m_sBUFFER.substr(i+16,j-i).c_str()); m_iTotalBytes = StringToInt(m_sBUFFER.substr(i+16,j-i));
else else
m_iTotalBytes = -1; //We don't know, so go until disconnect m_iTotalBytes = -1; //We don't know, so go until disconnect
@@ -696,7 +696,7 @@ bool ScreenPackages::ParseHTTPAddress( const RString &URL, RString &sProto, RStr
sServer = asMatches[1]; sServer = asMatches[1];
if( asMatches[3] != "" ) if( asMatches[3] != "" )
{ {
iPort = atoi(asMatches[3]); iPort = StringToInt(asMatches[3]);
if( iPort == 0 ) if( iPort == 0 )
return false; return false;
} }
+1 -1
View File
@@ -173,7 +173,7 @@ bool SongOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut )
Regex lives("^([0-9]+) ?(lives|life)$"); Regex lives("^([0-9]+) ?(lives|life)$");
if( lives.Compare(sBit, matches) ) if( lives.Compare(sBit, matches) )
{ {
m_iBatteryLives = atoi( matches[0] ); m_iBatteryLives = StringToInt( matches[0] );
return true; return true;
} }
+2 -2
View File
@@ -50,9 +50,9 @@ void XNode::Free()
} }
void XNodeStringValue::GetValue( RString &out ) const { out = m_sValue; } void XNodeStringValue::GetValue( RString &out ) const { out = m_sValue; }
void XNodeStringValue::GetValue( int &out ) const { out = atoi(m_sValue); } void XNodeStringValue::GetValue( int &out ) const { out = StringToInt(m_sValue); }
void XNodeStringValue::GetValue( float &out ) const { out = StringToFloat(m_sValue); } void XNodeStringValue::GetValue( float &out ) const { out = StringToFloat(m_sValue); }
void XNodeStringValue::GetValue( bool &out ) const { out = atoi(m_sValue) != 0; } void XNodeStringValue::GetValue( bool &out ) const { out = StringToInt(m_sValue) != 0; }
void XNodeStringValue::GetValue( unsigned &out ) const { out = strtoul(m_sValue,NULL,0); } void XNodeStringValue::GetValue( unsigned &out ) const { out = strtoul(m_sValue,NULL,0); }
void XNodeStringValue::PushValue( lua_State *L ) const void XNodeStringValue::PushValue( lua_State *L ) const
{ {