Replace StringToInt with the std version.
Again, RageUtil isn't the right home.
This commit is contained in:
@@ -402,16 +402,16 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
m_Type = TYPE_TILES;
|
||||
}
|
||||
else if( StringToInt(type) == 1 )
|
||||
else if( std::stoi(type) == 1 )
|
||||
{
|
||||
m_Type = TYPE_SPRITE;
|
||||
bStretch = true;
|
||||
}
|
||||
else if( StringToInt(type) == 2 )
|
||||
else if( std::stoi(type) == 2 )
|
||||
{
|
||||
m_Type = TYPE_PARTICLES;
|
||||
}
|
||||
else if( StringToInt(type) == 3 )
|
||||
else if( std::stoi(type) == 3 )
|
||||
{
|
||||
m_Type = TYPE_TILES;
|
||||
}
|
||||
|
||||
+10
-10
@@ -87,7 +87,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
}
|
||||
else if( sValueName.EqualsNoCase("LIVES") )
|
||||
{
|
||||
out.m_iLives = max( StringToInt(sParams[1]), 0 );
|
||||
out.m_iLives = max( std::stoi(sParams[1]), 0 );
|
||||
}
|
||||
else if( sValueName.EqualsNoCase("GAINSECONDS") )
|
||||
{
|
||||
@@ -97,7 +97,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
{
|
||||
if( sParams.params.size() == 2 )
|
||||
{
|
||||
out.m_iCustomMeter[Difficulty_Medium] = max( StringToInt(sParams[1]), 0 ); /* compat */
|
||||
out.m_iCustomMeter[Difficulty_Medium] = max( std::stoi(sParams[1]), 0 ); /* compat */
|
||||
}
|
||||
else if( sParams.params.size() == 3 )
|
||||
{
|
||||
@@ -107,7 +107,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() );
|
||||
continue;
|
||||
}
|
||||
out.m_iCustomMeter[cd] = max( StringToInt(sParams[2]), 0 );
|
||||
out.m_iCustomMeter[cd] = max( std::stoi(sParams[2]), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
// most played
|
||||
if( sParams[1].Left(strlen("BEST")) == "BEST" )
|
||||
{
|
||||
int iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1;
|
||||
int iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1;
|
||||
if( iChooseIndex > iNumSongs )
|
||||
{
|
||||
// looking up a song that doesn't exist.
|
||||
@@ -185,7 +185,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
// least played
|
||||
else if( sParams[1].Left(strlen("WORST")) == "WORST" )
|
||||
{
|
||||
int iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1;
|
||||
int iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1;
|
||||
if( iChooseIndex > iNumSongs )
|
||||
{
|
||||
// looking up a song that doesn't exist.
|
||||
@@ -202,14 +202,14 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
// best grades
|
||||
else if( sParams[1].Left(strlen("GRADEBEST")) == "GRADEBEST" )
|
||||
{
|
||||
new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1;
|
||||
new_entry.iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1;
|
||||
CLAMP( new_entry.iChooseIndex, 0, 500 );
|
||||
new_entry.songSort = SongSort_TopGrades;
|
||||
}
|
||||
// worst grades
|
||||
else if( sParams[1].Left(strlen("GRADEWORST")) == "GRADEWORST" )
|
||||
{
|
||||
new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1;
|
||||
new_entry.iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1;
|
||||
CLAMP( new_entry.iChooseIndex, 0, 500 );
|
||||
new_entry.songSort = SongSort_LowestGrades;
|
||||
}
|
||||
@@ -308,7 +308,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
else if( !sMod.CompareNoCase("nodifficult") )
|
||||
new_entry.bNoDifficult = true;
|
||||
else if( sMod.length() > 5 && !sMod.Left(5).CompareNoCase("award") )
|
||||
new_entry.iGainLives = StringToInt( sMod.substr(5) );
|
||||
new_entry.iGainLives = std::stoi( sMod.substr(5) );
|
||||
else
|
||||
continue;
|
||||
mods.erase( mods.begin() + j );
|
||||
@@ -330,8 +330,8 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
|
||||
else if( bFromCache && !sValueName.EqualsNoCase("RADAR") )
|
||||
{
|
||||
StepsType st = (StepsType) StringToInt(sParams[1]);
|
||||
CourseDifficulty cd = (CourseDifficulty) StringToInt( sParams[2] );
|
||||
StepsType st = (StepsType) std::stoi(sParams[1]);
|
||||
CourseDifficulty cd = (CourseDifficulty) std::stoi( sParams[2] );
|
||||
|
||||
RadarValues rv;
|
||||
rv.FromString( sParams[3] );
|
||||
|
||||
@@ -267,14 +267,14 @@ void FileTransfer::HTTPUpdate()
|
||||
m_sResponseName = "Malformed response.";
|
||||
return;
|
||||
}
|
||||
m_iResponseCode = StringToInt(m_sBUFFER.substr(i+1,j-i));
|
||||
m_iResponseCode = std::stoi(m_sBUFFER.substr(i+1,j-i));
|
||||
m_sResponseName = m_sBUFFER.substr( j+1, k-j );
|
||||
|
||||
i = m_sBUFFER.find("Content-Length:");
|
||||
j = m_sBUFFER.find("\n", i+1 );
|
||||
|
||||
if( i != string::npos )
|
||||
m_iTotalBytes = StringToInt(m_sBUFFER.substr(i+16,j-i));
|
||||
m_iTotalBytes = std::stoi(m_sBUFFER.substr(i+16,j-i));
|
||||
else
|
||||
m_iTotalBytes = -1; // We don't know, so go until disconnect
|
||||
|
||||
@@ -345,7 +345,7 @@ bool FileTransfer::ParseHTTPAddress( const RString &URL, RString &sProto, RStrin
|
||||
sServer = asMatches[1];
|
||||
if( asMatches[3] != "" )
|
||||
{
|
||||
iPort = StringToInt(asMatches[3]);
|
||||
iPort = std::stoi(asMatches[3]);
|
||||
if( iPort == 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-2
@@ -428,7 +428,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
|
||||
// If val is an integer, it's a width, eg. "10=27".
|
||||
if( IsAnInt(sName) )
|
||||
{
|
||||
cfg.m_mapGlyphWidths[StringToInt(sName)] = pValue->GetValue<int>();
|
||||
cfg.m_mapGlyphWidths[std::stoi(sName)] = pValue->GetValue<int>();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
|
||||
TrimLeft( sRowStr );
|
||||
|
||||
ASSERT( IsAnInt(sRowStr) );
|
||||
const int iRow = StringToInt( sRowStr );
|
||||
const int iRow = std::stoi( sRowStr );
|
||||
const int iFirstFrame = iRow * iNumFramesWide;
|
||||
|
||||
if( iRow > iNumFramesHigh )
|
||||
|
||||
+2
-2
@@ -333,12 +333,12 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
|
||||
else if( sName == "weight" )
|
||||
{
|
||||
m_iWeightPounds = StringToInt( sValue );
|
||||
m_iWeightPounds = std::stoi( sValue );
|
||||
}
|
||||
|
||||
else if( sName == "goalcalories" )
|
||||
{
|
||||
m_iGoalCalories = StringToInt( sValue );
|
||||
m_iGoalCalories = std::stoi( sValue );
|
||||
}
|
||||
|
||||
else if( sName == "goaltype" )
|
||||
|
||||
+1
-1
@@ -233,7 +233,7 @@ void GameState::ApplyCmdline()
|
||||
RString sPlayer;
|
||||
for( int i = 0; GetCommandlineArgument( "player", &sPlayer, i ); ++i )
|
||||
{
|
||||
int pn = StringToInt( sPlayer )-1;
|
||||
int pn = std::stoi( sPlayer )-1;
|
||||
if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS )
|
||||
RageException::Throw( "Invalid argument \"--player=%s\".", sPlayer.c_str() );
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &s
|
||||
|
||||
int NoteSkinManager::GetMetricI( const RString &sButtonName, const RString &sValueName )
|
||||
{
|
||||
return StringToInt( GetMetric(sButtonName,sValueName) );
|
||||
return std::stoi( GetMetric(sButtonName,sValueName) );
|
||||
}
|
||||
|
||||
float NoteSkinManager::GetMetricF( const RString &sButtonName, const RString &sValueName )
|
||||
@@ -264,7 +264,7 @@ float NoteSkinManager::GetMetricF( const RString &sButtonName, const RString &sV
|
||||
bool NoteSkinManager::GetMetricB( const RString &sButtonName, const RString &sValueName )
|
||||
{
|
||||
// Could also call GetMetricI here...hmm.
|
||||
return StringToInt( GetMetric(sButtonName,sValueName) ) != 0;
|
||||
return std::stoi( GetMetric(sButtonName,sValueName) ) != 0;
|
||||
}
|
||||
|
||||
apActorCommands NoteSkinManager::GetMetricA( const RString &sButtonName, const RString &sValueName )
|
||||
|
||||
@@ -565,7 +565,7 @@ void BMSChartReader::ReadHeaders()
|
||||
}
|
||||
else if( it->first == "#playlevel" )
|
||||
{
|
||||
out->SetMeter( StringToInt(it->second) );
|
||||
out->SetMeter( std::stoi(it->second) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+764
-764
File diff suppressed because it is too large
Load Diff
+810
-810
File diff suppressed because it is too large
Load Diff
@@ -109,7 +109,7 @@ void SMLoader::LoadFromTokens(
|
||||
// have a meter on certain steps. Make the meter 1 in these instances.
|
||||
sMeter = "1";
|
||||
}
|
||||
out.SetMeter( StringToInt(sMeter) );
|
||||
out.SetMeter( std::stoi(sMeter) );
|
||||
|
||||
out.SetSMNoteData( sNoteData );
|
||||
|
||||
@@ -393,8 +393,8 @@ void SMLoader::ProcessTimeSignatures( TimingData &out, const RString line, const
|
||||
}
|
||||
|
||||
const float fBeat = RowToBeat( vs2[0], rowsPerBeat );
|
||||
const int iNumerator = StringToInt( vs2[1] );
|
||||
const int iDenominator = StringToInt( vs2[2] );
|
||||
const int iNumerator = std::stoi( vs2[1] );
|
||||
const int iDenominator = std::stoi( vs2[2] );
|
||||
|
||||
if( fBeat < 0 )
|
||||
{
|
||||
@@ -486,7 +486,7 @@ void SMLoader::ProcessSpeeds( TimingData &out, const RString line, const int row
|
||||
const float fDelay = StringToFloat( vs2[2] );
|
||||
|
||||
// XXX: ugly...
|
||||
int iUnit = StringToInt(vs2[3]);
|
||||
int iUnit = std::stoi(vs2[3]);
|
||||
SpeedSegment::BaseUnit unit = (iUnit == 0) ?
|
||||
SpeedSegment::UNIT_BEATS : SpeedSegment::UNIT_SECONDS;
|
||||
|
||||
@@ -587,7 +587,7 @@ bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString
|
||||
// Backward compatibility:
|
||||
if( change.m_def.m_sEffect.empty() )
|
||||
{
|
||||
bool bLoop = StringToInt( aBGChangeValues[5] ) != 0;
|
||||
bool bLoop = std::stoi( aBGChangeValues[5] ) != 0;
|
||||
if( !bLoop )
|
||||
change.m_def.m_sEffect = SBE_StretchNoLoop;
|
||||
}
|
||||
@@ -597,7 +597,7 @@ bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString
|
||||
// Backward compatibility:
|
||||
if( change.m_def.m_sEffect.empty() )
|
||||
{
|
||||
bool bRewindMovie = StringToInt( aBGChangeValues[4] ) != 0;
|
||||
bool bRewindMovie = std::stoi( aBGChangeValues[4] ) != 0;
|
||||
if( bRewindMovie )
|
||||
change.m_def.m_sEffect = SBE_StretchRewind;
|
||||
}
|
||||
@@ -606,7 +606,7 @@ bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString
|
||||
// param 9 overrides this.
|
||||
// Backward compatibility:
|
||||
if( change.m_sTransition.empty() )
|
||||
change.m_sTransition = (StringToInt( aBGChangeValues[3] ) != 0) ? "CrossFade" : "";
|
||||
change.m_sTransition = (std::stoi( aBGChangeValues[3] ) != 0) ? "CrossFade" : "";
|
||||
// fall through
|
||||
case 3:
|
||||
change.m_fRate = StringToFloat( aBGChangeValues[2] );
|
||||
@@ -869,7 +869,7 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache
|
||||
* used 3.9+ features are not excluded here */
|
||||
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
|
||||
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
||||
else if( StringToInt(sParams[1]) > 0 )
|
||||
else if( std::stoi(sParams[1]) > 0 )
|
||||
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
||||
else
|
||||
LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() );
|
||||
|
||||
@@ -33,11 +33,11 @@ void SMALoader::ProcessMultipliers( TimingData &out, const int iRowsPerBeat, con
|
||||
continue;
|
||||
}
|
||||
const float fComboBeat = RowToBeat( arrayMultiplierValues[0], iRowsPerBeat );
|
||||
const int iCombos = StringToInt( arrayMultiplierValues[1] ); // always true.
|
||||
const int iCombos = std::stoi( arrayMultiplierValues[1] ); // always true.
|
||||
// hoping I'm right here: SMA files can use 6 values after the row/beat.
|
||||
const int iMisses = (size == 2 || size == 4 ?
|
||||
iCombos :
|
||||
StringToInt(arrayMultiplierValues[2]));
|
||||
std::stoi(arrayMultiplierValues[2]));
|
||||
out.AddSegment( ComboSegment(BeatToNoteRow(fComboBeat), iCombos, iMisses) );
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
|
||||
continue;
|
||||
}
|
||||
const float fBeat = StringToFloat( vs2[0] );
|
||||
const int iNumerator = StringToInt( vs2[1] );
|
||||
const int iNumerator = std::stoi( vs2[1] );
|
||||
|
||||
if( fBeat < 0 )
|
||||
{
|
||||
@@ -296,7 +296,7 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
|
||||
|
||||
vector<RString> arrayBeatChangeValues;
|
||||
split( arrayBeatChangeExpressions[0], "=", arrayBeatChangeValues );
|
||||
iRowsPerBeat = StringToInt(arrayBeatChangeValues[1]);
|
||||
iRowsPerBeat = std::stoi(arrayBeatChangeValues[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -327,7 +327,7 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
|
||||
* used 3.9+ features are not excluded here */
|
||||
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
|
||||
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
||||
else if( StringToInt(sParams[1]) > 0 )
|
||||
else if( std::stoi(sParams[1]) > 0 )
|
||||
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
||||
else
|
||||
LOG->UserLog("Song file",
|
||||
|
||||
@@ -104,8 +104,8 @@ void SSCLoader::ProcessCombos( TimingData &out, const RString line, const int ro
|
||||
continue;
|
||||
}
|
||||
const float fComboBeat = StringToFloat( arrayComboValues[0] );
|
||||
const int iCombos = StringToInt( arrayComboValues[1] );
|
||||
const int iMisses = (size == 2 ? iCombos : StringToInt(arrayComboValues[2]));
|
||||
const int iCombos = std::stoi( arrayComboValues[1] );
|
||||
const int iMisses = (size == 2 ? iCombos : std::stoi(arrayComboValues[2]));
|
||||
out.AddSegment( ComboSegment( BeatToNoteRow(fComboBeat), iCombos, iMisses ) );
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ bool SSCLoader::LoadNoteDataFromSimfile( const RString & cachePath, Steps &out )
|
||||
|
||||
else if( valueName=="METER" )
|
||||
{
|
||||
if (out.GetMeter() != StringToInt(matcher))
|
||||
if (out.GetMeter() != std::stoi(matcher))
|
||||
tryingSteps = false;
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
|
||||
* used 3.9+ features are not excluded here */
|
||||
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
|
||||
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
||||
else if( StringToInt(sParams[1]) > 0 )
|
||||
else if( std::stoi(sParams[1]) > 0 )
|
||||
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
||||
else
|
||||
LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() );
|
||||
@@ -549,13 +549,13 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
|
||||
else if( sValueName=="HASMUSIC" )
|
||||
{
|
||||
if( bFromCache )
|
||||
out.m_bHasMusic = StringToInt( sParams[1] ) != 0;
|
||||
out.m_bHasMusic = std::stoi( sParams[1] ) != 0;
|
||||
}
|
||||
|
||||
else if( sValueName=="HASBANNER" )
|
||||
{
|
||||
if( bFromCache )
|
||||
out.m_bHasBanner = StringToInt( sParams[1] ) != 0;
|
||||
out.m_bHasBanner = std::stoi( sParams[1] ) != 0;
|
||||
}
|
||||
|
||||
// This tag will get us to the next section.
|
||||
@@ -603,7 +603,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
|
||||
|
||||
else if( sValueName=="METER" )
|
||||
{
|
||||
pNewNotes->SetMeter( StringToInt( sParams[1] ) );
|
||||
pNewNotes->SetMeter( std::stoi( sParams[1] ) );
|
||||
}
|
||||
|
||||
else if( sValueName=="RADARVALUES" )
|
||||
@@ -918,7 +918,7 @@ bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
|
||||
|
||||
else if( sValueName=="METER" )
|
||||
{
|
||||
pNewNotes->SetMeter( StringToInt( sParams[1] ) );
|
||||
pNewNotes->SetMeter( std::stoi( sParams[1] ) );
|
||||
bSSCFormat = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() );
|
||||
|
||||
m_Def.m_bOneChoiceForAllPlayers = false;
|
||||
const int NumCols = StringToInt( lCmds.v[0].m_vsArgs[0] );
|
||||
const int NumCols = std::stoi( lCmds.v[0].m_vsArgs[0] );
|
||||
for( unsigned i=1; i<lCmds.v.size(); i++ )
|
||||
{
|
||||
const Command &cmd = lCmds.v[i];
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
else if( sName == "selectone" ) m_Def.m_selectType = SELECT_ONE;
|
||||
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 == "default" ) m_Def.m_iDefault = StringToInt( cmd.GetArg(1).s ) - 1; // match ENTRY_MODE
|
||||
else if( sName == "default" ) m_Def.m_iDefault = std::stoi( cmd.GetArg(1).s ) - 1; // match ENTRY_MODE
|
||||
else if( sName == "reloadrowmessages" )
|
||||
{
|
||||
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
|
||||
{
|
||||
RString sArg = cmd.m_vsArgs[a];
|
||||
PlayerNumber pn = (PlayerNumber)(StringToInt(sArg)-1);
|
||||
PlayerNumber pn = (PlayerNumber)(std::stoi(sArg)-1);
|
||||
ASSERT( pn >= 0 && pn < NUM_PLAYERS );
|
||||
m_Def.m_vEnabledForPlayers.insert( pn );
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
|
||||
{
|
||||
// XXX: We know what they want, is there any reason not to handle it?
|
||||
// Yes. We should be strict in handling the format. -Chris
|
||||
sErrorOut = ssprintf("Invalid player options \"%s\"; did you mean '*%d'?", s.c_str(), StringToInt(s) );
|
||||
sErrorOut = ssprintf("Invalid player options \"%s\"; did you mean '*%d'?", s.c_str(), std::stoi(s) );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
+1
-1
@@ -1862,7 +1862,7 @@ RString Profile::MakeUniqueFileNameNoExtension( RString sDir, RString sFileNameB
|
||||
continue;
|
||||
|
||||
ASSERT( matches.size() == 1 );
|
||||
iIndex = StringToInt( matches[0] )+1;
|
||||
iIndex = std::stoi( matches[0] )+1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ bool ProfileManager::CreateLocalProfile( RString sName, RString &sProfileIDOut )
|
||||
vector<RString> vs;
|
||||
GetLocalProfileIDs( vs );
|
||||
for (RString const &s : vs)
|
||||
iMaxProfileNumber = StringToInt( s );
|
||||
iMaxProfileNumber = std::stoi( s );
|
||||
|
||||
int iProfileNumber = iMaxProfileNumber + 1;
|
||||
RString sProfileID = ssprintf( "%08d", iProfileNumber );
|
||||
|
||||
@@ -26,8 +26,8 @@ static void GetResolutionFromFileName( RString sPath, int &iWidth, int &iHeight
|
||||
if( !re.Compare(sPath, asMatches) )
|
||||
return;
|
||||
|
||||
iWidth = StringToInt( asMatches[0] );
|
||||
iHeight = StringToInt( asMatches[1] );
|
||||
iWidth = std::stoi( asMatches[0] );
|
||||
iHeight = std::stoi( asMatches[1] );
|
||||
}
|
||||
|
||||
RageBitmapTexture::RageBitmapTexture( RageTextureID name ) :
|
||||
|
||||
+118
-118
@@ -1,118 +1,118 @@
|
||||
#include "global.h"
|
||||
|
||||
#include "RageTexture.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
RageTexture::RageTexture( RageTextureID name ):
|
||||
m_iRefCount(1), m_bWasUsed(false), m_ID(name),
|
||||
m_iSourceWidth(0), m_iSourceHeight(0),
|
||||
m_iTextureWidth(0), m_iTextureHeight(0),
|
||||
m_iImageWidth(0), m_iImageHeight(0),
|
||||
m_iFramesWide(1), m_iFramesHigh(1) {}
|
||||
|
||||
|
||||
RageTexture::~RageTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RageTexture::CreateFrameRects()
|
||||
{
|
||||
GetFrameDimensionsFromFileName( GetID().filename, &m_iFramesWide, &m_iFramesHigh );
|
||||
|
||||
// Fill in the m_FrameRects with the bounds of each frame in the animation.
|
||||
m_TextureCoordRects.clear();
|
||||
|
||||
for( int j=0; j<m_iFramesHigh; j++ ) // traverse along Y
|
||||
{
|
||||
for( int i=0; i<m_iFramesWide; i++ ) // traverse along X (important that this is the inner loop)
|
||||
{
|
||||
RectF frect( (i+0)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth, // these will all be between 0.0 and 1.0
|
||||
(j+0)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight,
|
||||
(i+1)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth,
|
||||
(j+1)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight );
|
||||
m_TextureCoordRects.push_back( frect ); // the index of this array element will be (i + j*m_iFramesWide)
|
||||
|
||||
//LOG->Trace( "Adding frect%d %f %f %f %f", (i + j*m_iFramesWide), frect.left, frect.top, frect.right, frect.bottom );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RageTexture::GetFrameDimensionsFromFileName( RString sPath, int* piFramesWide, int* piFramesHigh )
|
||||
{
|
||||
static Regex match( " ([0-9]+)x([0-9]+)([\\. ]|$)" );
|
||||
vector<RString> asMatch;
|
||||
if( !match.Compare(sPath, asMatch) )
|
||||
{
|
||||
*piFramesWide = *piFramesHigh = 1;
|
||||
return;
|
||||
}
|
||||
*piFramesWide = StringToInt(asMatch[0]);
|
||||
*piFramesHigh = StringToInt(asMatch[1]);
|
||||
}
|
||||
|
||||
const RectF *RageTexture::GetTextureCoordRect( int iFrameNo ) const
|
||||
{
|
||||
return &m_TextureCoordRects[iFrameNo];
|
||||
}
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
/** @brief Allow Lua to have access to the RageTexture. */
|
||||
class LunaRageTexture: public Luna<RageTexture>
|
||||
{
|
||||
public:
|
||||
static int position( T* p, lua_State *L ) { p->SetPosition( FArg(1) ); return 0; }
|
||||
static int loop( T* p, lua_State *L ) { p->SetLooping( BIArg(1) ); return 0; }
|
||||
static int rate( T* p, lua_State *L ) { p->SetPlaybackRate( FArg(1) ); return 0; }
|
||||
static int GetTextureCoordRect( T* p, lua_State *L )
|
||||
{
|
||||
const RectF *pRect = p->GetTextureCoordRect( IArg(1) );
|
||||
lua_pushnumber( L, pRect->left );
|
||||
lua_pushnumber( L, pRect->top );
|
||||
lua_pushnumber( L, pRect->right );
|
||||
lua_pushnumber( L, pRect->bottom );
|
||||
return 4;
|
||||
}
|
||||
|
||||
LunaRageTexture()
|
||||
{
|
||||
ADD_METHOD( position );
|
||||
ADD_METHOD( loop );
|
||||
ADD_METHOD( rate );
|
||||
ADD_METHOD( GetTextureCoordRect );
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_CLASS( RageTexture )
|
||||
// lua end
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
|
||||
#include "RageTexture.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
RageTexture::RageTexture( RageTextureID name ):
|
||||
m_iRefCount(1), m_bWasUsed(false), m_ID(name),
|
||||
m_iSourceWidth(0), m_iSourceHeight(0),
|
||||
m_iTextureWidth(0), m_iTextureHeight(0),
|
||||
m_iImageWidth(0), m_iImageHeight(0),
|
||||
m_iFramesWide(1), m_iFramesHigh(1) {}
|
||||
|
||||
|
||||
RageTexture::~RageTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RageTexture::CreateFrameRects()
|
||||
{
|
||||
GetFrameDimensionsFromFileName( GetID().filename, &m_iFramesWide, &m_iFramesHigh );
|
||||
|
||||
// Fill in the m_FrameRects with the bounds of each frame in the animation.
|
||||
m_TextureCoordRects.clear();
|
||||
|
||||
for( int j=0; j<m_iFramesHigh; j++ ) // traverse along Y
|
||||
{
|
||||
for( int i=0; i<m_iFramesWide; i++ ) // traverse along X (important that this is the inner loop)
|
||||
{
|
||||
RectF frect( (i+0)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth, // these will all be between 0.0 and 1.0
|
||||
(j+0)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight,
|
||||
(i+1)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth,
|
||||
(j+1)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight );
|
||||
m_TextureCoordRects.push_back( frect ); // the index of this array element will be (i + j*m_iFramesWide)
|
||||
|
||||
//LOG->Trace( "Adding frect%d %f %f %f %f", (i + j*m_iFramesWide), frect.left, frect.top, frect.right, frect.bottom );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RageTexture::GetFrameDimensionsFromFileName( RString sPath, int* piFramesWide, int* piFramesHigh )
|
||||
{
|
||||
static Regex match( " ([0-9]+)x([0-9]+)([\\. ]|$)" );
|
||||
vector<RString> asMatch;
|
||||
if( !match.Compare(sPath, asMatch) )
|
||||
{
|
||||
*piFramesWide = *piFramesHigh = 1;
|
||||
return;
|
||||
}
|
||||
*piFramesWide = std::stoi(asMatch[0]);
|
||||
*piFramesHigh = std::stoi(asMatch[1]);
|
||||
}
|
||||
|
||||
const RectF *RageTexture::GetTextureCoordRect( int iFrameNo ) const
|
||||
{
|
||||
return &m_TextureCoordRects[iFrameNo];
|
||||
}
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
/** @brief Allow Lua to have access to the RageTexture. */
|
||||
class LunaRageTexture: public Luna<RageTexture>
|
||||
{
|
||||
public:
|
||||
static int position( T* p, lua_State *L ) { p->SetPosition( FArg(1) ); return 0; }
|
||||
static int loop( T* p, lua_State *L ) { p->SetLooping( BIArg(1) ); return 0; }
|
||||
static int rate( T* p, lua_State *L ) { p->SetPlaybackRate( FArg(1) ); return 0; }
|
||||
static int GetTextureCoordRect( T* p, lua_State *L )
|
||||
{
|
||||
const RectF *pRect = p->GetTextureCoordRect( IArg(1) );
|
||||
lua_pushnumber( L, pRect->left );
|
||||
lua_pushnumber( L, pRect->top );
|
||||
lua_pushnumber( L, pRect->right );
|
||||
lua_pushnumber( L, pRect->bottom );
|
||||
return 4;
|
||||
}
|
||||
|
||||
LunaRageTexture()
|
||||
{
|
||||
ADD_METHOD( position );
|
||||
ADD_METHOD( loop );
|
||||
ADD_METHOD( rate );
|
||||
ADD_METHOD( GetTextureCoordRect );
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_CLASS( RageTexture )
|
||||
// lua end
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
+3
-10
@@ -263,8 +263,8 @@ float HHMMSSToSeconds( const RString &sHHMMSS )
|
||||
arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits
|
||||
|
||||
float fSeconds = 0;
|
||||
fSeconds += StringToInt( arrayBits[0] ) * 60 * 60;
|
||||
fSeconds += StringToInt( arrayBits[1] ) * 60;
|
||||
fSeconds += std::stoi( arrayBits[0] ) * 60 * 60;
|
||||
fSeconds += std::stoi( arrayBits[1] ) * 60;
|
||||
fSeconds += StringToFloat( arrayBits[2] );
|
||||
|
||||
return fSeconds;
|
||||
@@ -1751,13 +1751,6 @@ void MakeLower( wchar_t *p, size_t iLen )
|
||||
UnicodeUpperLower( p, iLen, g_LowerCase );
|
||||
}
|
||||
|
||||
int StringToInt( const RString &sString )
|
||||
{
|
||||
int ret;
|
||||
istringstream ( sString ) >> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
float StringToFloat( const RString &sString )
|
||||
{
|
||||
float ret = strtof( sString, nullptr );
|
||||
@@ -2207,7 +2200,7 @@ namespace StringConversion
|
||||
if( sValue.size() == 0 )
|
||||
return false;
|
||||
|
||||
out = (StringToInt(sValue) != 0);
|
||||
out = (std::stoi(sValue) != 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -405,11 +405,7 @@ void MakeUpper( char *p, size_t iLen );
|
||||
void MakeLower( char *p, size_t iLen );
|
||||
void MakeUpper( 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 );
|
||||
|
||||
float StringToFloat( const RString &sString );
|
||||
/**
|
||||
* @brief Have a standard way of converting floats to strings.
|
||||
|
||||
+4
-4
@@ -3313,7 +3313,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
}
|
||||
else if( SM == SM_BackFromDifficultyMeterChange )
|
||||
{
|
||||
int i = StringToInt( ScreenTextEntry::s_sLastAnswer );
|
||||
int i = std::stoi( ScreenTextEntry::s_sLastAnswer );
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1]->SetMeter(i);
|
||||
SetDirty( true );
|
||||
}
|
||||
@@ -3376,7 +3376,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
}
|
||||
else if ( SM == SM_BackFromTickcountChange && !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
int iTick = StringToInt( ScreenTextEntry::s_sLastAnswer );
|
||||
int iTick = std::stoi( ScreenTextEntry::s_sLastAnswer );
|
||||
|
||||
if ( iTick >= 0 && iTick <= ROWS_PER_BEAT )
|
||||
GetAppropriateTimingForUpdate().AddSegment( TickcountSegment( GetRow(), iTick) );
|
||||
@@ -3441,7 +3441,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
}
|
||||
else
|
||||
{
|
||||
int tmp = StringToInt(ScreenTextEntry::s_sLastAnswer );
|
||||
int tmp = std::stoi(ScreenTextEntry::s_sLastAnswer );
|
||||
|
||||
SpeedSegment::BaseUnit unit = (tmp == 0 ) ?
|
||||
SpeedSegment::UNIT_BEATS : SpeedSegment::UNIT_SECONDS;
|
||||
@@ -4091,7 +4091,7 @@ static void ChangeStepCredit( const RString &sNew )
|
||||
|
||||
static void ChangeStepMeter( const RString &sNew )
|
||||
{
|
||||
int diff = StringToInt(sNew);
|
||||
int diff = std::stoi(sNew);
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1]->SetMeter(max(diff, 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -2801,7 +2801,7 @@ void ScreenGameplay::SaveReplay()
|
||||
continue;
|
||||
|
||||
ASSERT( matches.size() == 1 );
|
||||
iIndex = StringToInt( matches[0] )+1;
|
||||
iIndex = std::stoi( matches[0] )+1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+741
-741
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -176,7 +176,7 @@ bool SongOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut )
|
||||
Regex lives("^([0-9]+) ?(lives|life)$");
|
||||
if( lives.Compare(sBit, matches) )
|
||||
{
|
||||
m_iBatteryLives = StringToInt( matches[0] );
|
||||
m_iBatteryLives = std::stoi( matches[0] );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -50,9 +50,9 @@ void XNode::Free()
|
||||
}
|
||||
|
||||
void XNodeStringValue::GetValue( RString &out ) const { out = m_sValue; }
|
||||
void XNodeStringValue::GetValue( int &out ) const { out = StringToInt(m_sValue); }
|
||||
void XNodeStringValue::GetValue( int &out ) const { out = std::stoi(m_sValue); }
|
||||
void XNodeStringValue::GetValue( float &out ) const { out = StringToFloat(m_sValue); }
|
||||
void XNodeStringValue::GetValue( bool &out ) const { out = StringToInt(m_sValue) != 0; }
|
||||
void XNodeStringValue::GetValue( bool &out ) const { out = std::stoi(m_sValue) != 0; }
|
||||
void XNodeStringValue::GetValue( unsigned &out ) const { out = strtoul(m_sValue,NULL,0); }
|
||||
void XNodeStringValue::PushValue( lua_State *L ) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user