Added more asserts to find #687 (nan when setting engine force).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11509 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-08-16 04:22:33 +00:00
parent b966057611
commit 36c6284ebe

View File

@ -878,17 +878,20 @@ void Kart::collectedItem(Item *item, int add_info)
float Kart::getActualWheelForce()
{
float add_force = m_max_speed->getCurrentAdditionalEngineForce();
assert(!isnan(add_force));
const std::vector<float>& gear_ratio=m_kart_properties->getGearSwitchRatio();
for(unsigned int i=0; i<gear_ratio.size(); i++)
{
if(m_speed <= m_kart_properties->getMaxSpeed()*gear_ratio[i])
{
assert(!isnan(m_kart_properties->getMaxPower()));
assert(!isnan(m_kart_properties->getGearPowerIncrease()[i]));
return m_kart_properties->getMaxPower()
*m_kart_properties->getGearPowerIncrease()[i]
+add_force;
}
}
assert(!isnan(m_kart_properties->getMaxPower()));
return m_kart_properties->getMaxPower()+add_force;
} // getActualWheelForce
@ -1951,6 +1954,8 @@ void Kart::updateEnginePowerAndBrakes(float dt)
else // !m_brake
{
// lift the foot from throttle, brakes with 10% engine_power
assert(!isnan(m_controls.m_accel));
assert(!isnan(engine_power));
applyEngineForce(-m_controls.m_accel*engine_power*0.1f);
// If not giving power (forward or reverse gear), and speed is low