Improved end of lap detection by using the actual length of the track.

Otherwise (when testing for distance along tracks >300) it could
happen (e.g. shifting sand, drive left after the lap was counted before
the pillar till you do a shortcut) that laps were 'discounted' twice.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2686 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2008-12-16 00:57:23 +00:00
parent 0ef006a95a
commit e63962ba7c

View File

@@ -283,9 +283,11 @@ void LinearWorld::update(float delta)
//-----------------------------------------------------------------------------
void LinearWorld::doLapCounting ( KartInfo& kart_info, Kart* kart )
{
bool newLap = kart_info.m_last_track_coords.getY() > 300.0f &&
kart_info.m_curr_track_coords.getY() < 20.0f;
const float delta=20.0f;
float track_length = m_track->getTrackLength();
bool newLap = kart_info.m_last_track_coords.getY() > track_length-delta &&
kart_info.m_curr_track_coords.getY() < delta;
// This fails if a kart skips a sector (or comes from the outside of the drivelines)
//const bool newLap = kart_info.m_last_valid_sector == (int)RaceManager::getTrack()->m_distance_from_start.size()-1 &&
// kart_info.m_track_sector == 0;
@@ -346,7 +348,8 @@ void LinearWorld::doLapCounting ( KartInfo& kart_info, Kart* kart )
}
kart_info.m_lap_start_time = RaceManager::getWorld()->getTime();
}
else if ( kart_info.m_curr_track_coords.getY() > 300.0f && kart_info.m_last_track_coords.getY() < 20.0f)
else if ( kart_info.m_curr_track_coords.getY() > track_length-delta &&
kart_info.m_last_track_coords.getY() < delta)
{
kart_info.m_race_lap-- ;
// Prevent cheating by setting time to a negative number, indicating