Properly fix #3159 (Wrong direction text is displayed twice).
When this is merged with master, the current work around in #3159 can be reverted.
This commit is contained in:
parent
2192d1383f
commit
10a2ae0e2a
@ -459,8 +459,8 @@ public:
|
|||||||
virtual void setOnScreenText(const wchar_t *text) = 0;
|
virtual void setOnScreenText(const wchar_t *text) = 0;
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
/** Counter which is used for displaying wrong way message after a delay */
|
/** Counter which is used for displaying wrong way message after a delay */
|
||||||
virtual int getWrongwayCounter() = 0;
|
virtual float getWrongwayTimer() = 0;
|
||||||
virtual void setWrongwayCounter(int counter) = 0;
|
virtual void setWrongwayTimer(float timer) = 0;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns whether this kart wins or loses. */
|
/** Returns whether this kart wins or loses. */
|
||||||
virtual bool getRaceResult() const = 0;
|
virtual bool getRaceResult() const = 0;
|
||||||
|
@ -141,7 +141,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
|||||||
m_is_jumping = false;
|
m_is_jumping = false;
|
||||||
m_min_nitro_ticks = 0;
|
m_min_nitro_ticks = 0;
|
||||||
m_fire_clicked = 0;
|
m_fire_clicked = 0;
|
||||||
m_wrongway_counter = 0;
|
m_wrongway_timer = 0;
|
||||||
m_type = RaceManager::KT_AI;
|
m_type = RaceManager::KT_AI;
|
||||||
|
|
||||||
m_view_blocked_by_plunger = 0;
|
m_view_blocked_by_plunger = 0;
|
||||||
|
@ -158,8 +158,8 @@ protected:
|
|||||||
/** True if fire button was pushed and not released */
|
/** True if fire button was pushed and not released */
|
||||||
bool m_fire_clicked;
|
bool m_fire_clicked;
|
||||||
|
|
||||||
/** Counter which is used for displaying wrong way message after a delay */
|
/** Timer which is used for displaying wrong way message after a delay */
|
||||||
int m_wrongway_counter;
|
float m_wrongway_timer;
|
||||||
|
|
||||||
|
|
||||||
// Bullet physics parameters
|
// Bullet physics parameters
|
||||||
@ -463,10 +463,10 @@ public:
|
|||||||
/** For debugging only: check if a kart is flying. */
|
/** For debugging only: check if a kart is flying. */
|
||||||
bool isFlying() const { return m_flying; }
|
bool isFlying() const { return m_flying; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Counter which is used for displaying wrong way message after a delay */
|
/** Timer which is used for displaying wrong way message after a delay */
|
||||||
int getWrongwayCounter() { return m_wrongway_counter; }
|
float getWrongwayTimer() { return m_wrongway_timer; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setWrongwayCounter(int counter) { m_wrongway_counter = counter; }
|
void setWrongwayTimer(float timer) { m_wrongway_timer = timer; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns whether this kart wins or loses. */
|
/** Returns whether this kart wins or loses. */
|
||||||
virtual bool getRaceResult() const { return m_race_result; }
|
virtual bool getRaceResult() const { return m_race_result; }
|
||||||
|
@ -208,8 +208,9 @@ void EasterEggHunt::getKartsDisplayInfo(
|
|||||||
/** Override the base class method to change behavior. We don't want wrong
|
/** Override the base class method to change behavior. We don't want wrong
|
||||||
* direction messages in the easter egg mode since there is no direction there.
|
* direction messages in the easter egg mode since there is no direction there.
|
||||||
* \param i Kart id.
|
* \param i Kart id.
|
||||||
|
* \param dt Time step size.
|
||||||
*/
|
*/
|
||||||
void EasterEggHunt::checkForWrongDirection(unsigned int i, int ticks)
|
void EasterEggHunt::checkForWrongDirection(unsigned int i, float dt)
|
||||||
{
|
{
|
||||||
} // checkForWrongDirection
|
} // checkForWrongDirection
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
void collectedEasterEgg(const AbstractKart *kart);
|
void collectedEasterEgg(const AbstractKart *kart);
|
||||||
void readData(const std::string &filename);
|
void readData(const std::string &filename);
|
||||||
|
|
||||||
virtual void checkForWrongDirection(unsigned int i, int ticks) OVERRIDE;
|
virtual void checkForWrongDirection(unsigned int i, float dt) OVERRIDE;
|
||||||
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
||||||
|
|
||||||
}; // EasterEggHunt
|
}; // EasterEggHunt
|
||||||
|
@ -96,7 +96,7 @@ void LinearWorld::reset()
|
|||||||
for(unsigned int i=0; i<kart_amount; i++)
|
for(unsigned int i=0; i<kart_amount; i++)
|
||||||
{
|
{
|
||||||
m_kart_info[i].reset();
|
m_kart_info[i].reset();
|
||||||
m_karts[i]->setWrongwayCounter(0);
|
m_karts[i]->setWrongwayTimer(0);
|
||||||
} // next kart
|
} // next kart
|
||||||
|
|
||||||
// At the moment the last kart would be the one that is furthest away
|
// At the moment the last kart would be the one that is furthest away
|
||||||
@ -158,13 +158,6 @@ void LinearWorld::update(int ticks)
|
|||||||
// especially updates the kart positions.
|
// especially updates the kart positions.
|
||||||
WorldWithRank::update(ticks);
|
WorldWithRank::update(ticks);
|
||||||
|
|
||||||
if (m_last_lap_sfx_playing &&
|
|
||||||
m_last_lap_sfx->getStatus() != SFXBase::SFX_PLAYING)
|
|
||||||
{
|
|
||||||
music_manager->resetTemporaryVolume();
|
|
||||||
m_last_lap_sfx_playing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned int kart_amount = getNumKarts();
|
const unsigned int kart_amount = getNumKarts();
|
||||||
|
|
||||||
// Do stuff specific to this subtype of race.
|
// Do stuff specific to this subtype of race.
|
||||||
@ -213,7 +206,6 @@ void LinearWorld::update(int ticks)
|
|||||||
m_kart_info[i].m_estimated_finish =
|
m_kart_info[i].m_estimated_finish =
|
||||||
estimateFinishTimeForKart(m_karts[i]);
|
estimateFinishTimeForKart(m_karts[i]);
|
||||||
}
|
}
|
||||||
checkForWrongDirection(i, ticks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -242,6 +234,33 @@ void LinearWorld::update(int ticks)
|
|||||||
#endif
|
#endif
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/** This updates all only graphical elements.It is only called once per
|
||||||
|
* rendered frame, not once per time step.
|
||||||
|
* float dt Time since last rame.
|
||||||
|
*/
|
||||||
|
void LinearWorld::updateGraphics(float dt)
|
||||||
|
{
|
||||||
|
if (m_last_lap_sfx_playing &&
|
||||||
|
m_last_lap_sfx->getStatus() != SFXBase::SFX_PLAYING)
|
||||||
|
{
|
||||||
|
music_manager->resetTemporaryVolume();
|
||||||
|
m_last_lap_sfx_playing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned int kart_amount = getNumKarts();
|
||||||
|
for (unsigned int i = 0; i<kart_amount; i++)
|
||||||
|
{
|
||||||
|
// ---------- update rank ------
|
||||||
|
if (!m_karts[i]->hasFinishedRace() &&
|
||||||
|
!m_karts[i]->isEliminated())
|
||||||
|
{
|
||||||
|
checkForWrongDirection(i, dt);
|
||||||
|
}
|
||||||
|
} // for i <kart_amount
|
||||||
|
|
||||||
|
} // updateGraphics
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Is called by check structures if a kart starts a new lap.
|
/** Is called by check structures if a kart starts a new lap.
|
||||||
* \param kart_index Index of the kart.
|
* \param kart_index Index of the kart.
|
||||||
@ -841,13 +860,14 @@ void LinearWorld::updateRacePosition()
|
|||||||
/** Checks if a kart is going in the wrong direction. This is done only for
|
/** Checks if a kart is going in the wrong direction. This is done only for
|
||||||
* player karts to display a message to the player.
|
* player karts to display a message to the player.
|
||||||
* \param i Kart id.
|
* \param i Kart id.
|
||||||
|
* \param dt Time step size.
|
||||||
*/
|
*/
|
||||||
void LinearWorld::checkForWrongDirection(unsigned int i, int ticks)
|
void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
|
||||||
{
|
{
|
||||||
if (!m_karts[i]->getController()->isLocalPlayerController())
|
if (!m_karts[i]->getController()->isLocalPlayerController())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int wrongway_counter = m_karts[i]->getWrongwayCounter();
|
float wrongway_timer = m_karts[i]->getWrongwayTimer();
|
||||||
|
|
||||||
const AbstractKart *kart=m_karts[i];
|
const AbstractKart *kart=m_karts[i];
|
||||||
// If the kart can go in more than one directions from the current track
|
// If the kart can go in more than one directions from the current track
|
||||||
@ -875,23 +895,23 @@ void LinearWorld::checkForWrongDirection(unsigned int i, int ticks)
|
|||||||
kart->getVelocityLC().getY() > 0.0f &&
|
kart->getVelocityLC().getY() > 0.0f &&
|
||||||
!kart->hasFinishedRace())
|
!kart->hasFinishedRace())
|
||||||
{
|
{
|
||||||
wrongway_counter += ticks;
|
wrongway_timer += dt;
|
||||||
|
|
||||||
if (wrongway_counter > stk_config->time2Ticks(2.0f))
|
if (wrongway_timer > 2.0f)
|
||||||
wrongway_counter = stk_config->time2Ticks(2.0f);
|
wrongway_timer = 2.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wrongway_counter -= ticks;
|
wrongway_timer -= dt;
|
||||||
|
|
||||||
if (wrongway_counter < 0)
|
if (wrongway_timer < 0)
|
||||||
wrongway_counter = 0;
|
wrongway_timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kart->getKartAnimation())
|
if (kart->getKartAnimation())
|
||||||
wrongway_counter = 0;
|
wrongway_timer = 0;
|
||||||
|
|
||||||
if (wrongway_counter > stk_config->time2Ticks(1.0f))
|
if (wrongway_timer > 1.0f)
|
||||||
{
|
{
|
||||||
m_race_gui->addMessage(_("WRONG WAY!"), kart,
|
m_race_gui->addMessage(_("WRONG WAY!"), kart,
|
||||||
/* time */ -1.0f,
|
/* time */ -1.0f,
|
||||||
@ -900,7 +920,7 @@ void LinearWorld::checkForWrongDirection(unsigned int i, int ticks)
|
|||||||
/*big font*/ true);
|
/*big font*/ true);
|
||||||
} // if angle is too big
|
} // if angle is too big
|
||||||
|
|
||||||
m_karts[i]->setWrongwayCounter(wrongway_counter);
|
m_karts[i]->setWrongwayTimer(wrongway_timer);
|
||||||
} // checkForWrongDirection
|
} // checkForWrongDirection
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -101,7 +101,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
AlignedArray<KartInfo> m_kart_info;
|
AlignedArray<KartInfo> m_kart_info;
|
||||||
|
|
||||||
virtual void checkForWrongDirection(unsigned int i, int ticks);
|
virtual void checkForWrongDirection(unsigned int i, float dt);
|
||||||
void updateRacePosition();
|
void updateRacePosition();
|
||||||
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
||||||
|
|
||||||
@ -114,6 +114,7 @@ public:
|
|||||||
virtual ~LinearWorld();
|
virtual ~LinearWorld();
|
||||||
|
|
||||||
virtual void update(int ticks) OVERRIDE;
|
virtual void update(int ticks) OVERRIDE;
|
||||||
|
virtual void updateGraphics(float dt) OVERRIDE;
|
||||||
float getDistanceDownTrackForKart(const int kart_id) const;
|
float getDistanceDownTrackForKart(const int kart_id) const;
|
||||||
float getDistanceToCenterForKart(const int kart_id) const;
|
float getDistanceToCenterForKart(const int kart_id) const;
|
||||||
float getEstimatedFinishTime(const int kart_id) const;
|
float getEstimatedFinishTime(const int kart_id) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user