Handle exceptions in int conversions (#2092)
* RageUtil: Add exception-safe wrappers around std::stoi, stol, stoll * Replace use of std::stoi with exception-safe StringToInt
This commit is contained in:
@@ -483,7 +483,7 @@ struct bmsCommandTree
|
||||
while (randomStack.size() < currentNode->branchHeight + 1) // if we're on branch level N we need N+1 values.
|
||||
randomStack.push_back(0);
|
||||
|
||||
randomStack[currentNode->branchHeight] = rand() % std::stoi(value) + 1;
|
||||
randomStack[currentNode->branchHeight] = rand() % StringToInt(value) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -886,12 +886,12 @@ void BMSChartReader::ReadHeaders()
|
||||
}
|
||||
else if( it->first == "#playlevel" )
|
||||
{
|
||||
out->SetMeter( std::stoi(it->second) );
|
||||
out->SetMeter( StringToInt(it->second) );
|
||||
}
|
||||
else if( it->first == "#difficulty")
|
||||
{
|
||||
// only set the difficulty if the #difficulty tag is between 1 and 6 (beginner~edit)
|
||||
int diff = std::stoi(it->second)-1; // BMS uses 1 to 6, SM uses 0 to 5
|
||||
int diff = StringToInt(it->second)-1; // BMS uses 1 to 6, SM uses 0 to 5
|
||||
if(diff>=0 && diff<NUM_Difficulty) {
|
||||
out->SetDifficulty( (Difficulty)diff );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user