Made the 'wrap around' lap counting approach work correctly.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6782 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
99aa5b1960
commit
b800ddd200
@ -167,11 +167,11 @@ void LinearWorld::restartRace()
|
||||
* sectors, which are then used to determine the kart positions.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void LinearWorld::update(float delta)
|
||||
void LinearWorld::update(float dt)
|
||||
{
|
||||
// run generic parent stuff that applies to all modes. It
|
||||
// especially updates the kart positions.
|
||||
WorldWithRank::update(delta);
|
||||
WorldWithRank::update(dt);
|
||||
|
||||
if (m_last_lap_sfx_playing && m_last_lap_sfx->getStatus() != SFXManager::SFX_PLAYING)
|
||||
{
|
||||
@ -223,6 +223,7 @@ void LinearWorld::update(float delta)
|
||||
// (like two karts at same position) can occur.
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
WorldWithRank::updateTrack(dt);
|
||||
updateRacePosition();
|
||||
|
||||
for (unsigned int i=0; i<kart_amount; i++)
|
||||
|
@ -120,6 +120,16 @@ std::string ThreeStrikesBattle::getIdent() const
|
||||
return STRIKES_IDENT;
|
||||
} // getIdent
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Update the world and the track.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void ThreeStrikesBattle::update(float dt)
|
||||
{
|
||||
WorldWithRank::update(dt);
|
||||
WorldWithRank::updateTrack(dt);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void ThreeStrikesBattle::updateKartRanks()
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
virtual std::string getIdent() const;
|
||||
|
||||
virtual void kartHit(const int kart_id);
|
||||
|
||||
virtual void update(float dt);
|
||||
void updateKartRanks();
|
||||
}; // ThreeStrikesBattles
|
||||
|
||||
|
@ -513,24 +513,31 @@ void World::update(float dt)
|
||||
// Update all karts that are not eliminated
|
||||
if(!m_karts[i]->isEliminated()) m_karts[i]->update(dt) ;
|
||||
}
|
||||
// The order of updates is rather important: if track update would
|
||||
// be called before kart update, then the check manager (called from
|
||||
// track update) will be using the old kart position to determine
|
||||
// e.g. if a kart has crossed a new line. But linear world (from
|
||||
// which this is called in case of a race) will be using the new
|
||||
// position of the karts to determine the driveline quad a kart
|
||||
// is on. So if a kart just arrived at quad 0 (meaning the distance
|
||||
// along the track goes from close-to-lap-length to close-to-zero),
|
||||
// the order of karts will be incorrect, since this kart will not
|
||||
// have started the next lap. While this will only last for one
|
||||
// frame (since in the next frame the check manager will detect
|
||||
// the new lap), it causes an incorrect display of icons in the
|
||||
// icon display for this one frame.
|
||||
m_track->update(dt);
|
||||
|
||||
projectile_manager->update(dt);
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Only updates the track. The order in which the various parts of STK are
|
||||
* updated is quite important (i.e. the track can't be updated as part of
|
||||
* the standard update call):
|
||||
* the track must be updated after updating the karts (otherwise the
|
||||
* checklines would be using the previous kart positions to determine
|
||||
* new laps, but linear world which determines distance along track would
|
||||
* be using the new kart positions --> the lap counting line will be
|
||||
* triggered one frame too late, potentially causing strange behaviour of
|
||||
* the icons.
|
||||
* Similarly linear world must update the position of all karts after all
|
||||
* karts have been updated (i.e. World::update() must be called before
|
||||
* updating the position of the karts). The check manager (which is called
|
||||
* from Track::update()) needs the updated distance along track, so track
|
||||
* update has to be called after updating the race position in linear world.
|
||||
* That's why there is a separate call for trackUpdate here.
|
||||
*/
|
||||
void World::updateTrack(float dt)
|
||||
{
|
||||
m_track->update(dt);
|
||||
} // update Track
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Highscores* World::getHighscores() const
|
||||
|
@ -137,6 +137,7 @@ protected:
|
||||
/** Returns true if the race is over. Must be defined by all modes. */
|
||||
virtual bool isRaceOver() = 0;
|
||||
virtual void update(float dt);
|
||||
void updateTrack(float dt);
|
||||
/** Used for AI karts that are still racing when all player kart finished.
|
||||
* Generally it should estimate the arrival time for those karts, but as
|
||||
* a default (useful for battle mode and ftl races) we just use the
|
||||
|
Loading…
Reference in New Issue
Block a user