Deal with corner case.

The hardcoded 600 will soon become a metric.
This commit is contained in:
Jason Felds
2011-07-03 13:35:00 -04:00
parent b9e267c0b0
commit 1574de2c25
3 changed files with 15 additions and 2 deletions
+6 -1
View File
@@ -360,12 +360,17 @@ float DisplayBpms::GetMin() const
}
float DisplayBpms::GetMax() const
{
return this->GetMaxWithin();
}
float DisplayBpms::GetMaxWithin(float highest) const
{
float fMax = 0;
FOREACH_CONST( float, vfBpms, f )
{
if( *f != -1 )
fMax = max( fMax, *f );
fMax = clamp(max( fMax, *f ), 0, highest);
}
return fMax;
}
+8
View File
@@ -4,6 +4,7 @@
#define GAME_CONSTANTS_AND_TYPES_H
#include "EnumHelper.h"
#include <float.h> // need the max for default.
// Note definitions
/** @brief Define the mininum difficulty value allowed. */
@@ -513,6 +514,13 @@ struct DisplayBpms
* @return the maximum BPM.
*/
float GetMax() const;
/**
* @brief Retrieve the maximum BPM of the set,
* but no higher than a certain value.
* @param highest the highest BPM to use.
* @return the maximum BPM.
*/
float GetMaxWithin(float highest = FLT_MAX) const;
/**
* @brief Determine if the BPM is really constant.
* @return Whether the BPM is constant or not.
+1 -1
View File
@@ -432,7 +432,7 @@ void Player::Init(
// if the BPMs are < 0, reset and get the actual values.
if( !bpms.IsSecret() )
{
fMaxBPM = bpms.GetMax();
fMaxBPM = bpms.GetMaxWithin(600);
fMaxBPM = max( 0, fMaxBPM );
}