This commit is contained in:
Alayan 2023-12-14 16:55:53 +01:00
parent 6d38bfec8c
commit f8db600d09
No known key found for this signature in database
2 changed files with 16 additions and 4 deletions

View File

@ -42,6 +42,7 @@ GhostKart::GhostKart(const std::string& ident, unsigned int world_kart_id,
m_replay_data(rd), m_last_egg_idx(0)
{
m_graphical_y_offset = 0;
m_finish_computed = false;
} // GhostKart
// ----------------------------------------------------------------------------
@ -271,7 +272,18 @@ void GhostKart::computeFinishTime()
* Track::getCurrentTrack()->getTrackLength();
m_finish_time = getTimeForDistance(full_distance);
}
}
m_finish_computed = true;
} // computeFinishTime
// ------------------------------------------------------------------------
/** Returns the finish time for a ghost kart. */
float GhostKart::getGhostFinishTime()
{
if (!m_finish_computed)
computeFinishTime();
return m_finish_time;
} // getGhostFinishTime
// ----------------------------------------------------------------------------
/** Returns the time at which the kart was at a given distance.

View File

@ -50,6 +50,8 @@ private:
unsigned int m_last_egg_idx;
bool m_finish_computed;
// ----------------------------------------------------------------------------
/** Compute the time at which the ghost finished the race */
void computeFinishTime();
@ -84,11 +86,9 @@ public:
// ------------------------------------------------------------------------
/** Returns the speed of the kart in meters/second. */
virtual float getSpeed() const OVERRIDE;
// ------------------------------------------------------------------------
/** Returns the finished time for a ghost kart. */
float getGhostFinishTime() { computeFinishTime(); return m_finish_time; }
float getGhostFinishTime();
// ------------------------------------------------------------------------
/** Returns the time at which the kart was at a given distance.
* Returns -1.0f if none */