Merge remote-tracking branch 'origin/fix_timer'

This commit is contained in:
Benau 2016-07-25 14:46:58 +08:00
commit 8c38e9e79b
9 changed files with 19 additions and 26 deletions

View File

@ -407,7 +407,7 @@ void Powerup::hitBonusBox(const Item &item, int add_info)
{
new_powerup = powerup_manager->getRandomPowerup(position, &n);
if(new_powerup != PowerupManager::POWERUP_RUBBERBALL ||
( World::getWorld()->getTime() - powerup_manager->getBallCollectTime()) >
( World::getWorld()->getTimeSinceStart() - powerup_manager->getBallCollectTime()) >
RubberBall::getTimeBetweenRubberBalls() )
break;
}

View File

@ -241,7 +241,7 @@ void AIBaseController::crashed(const Material *m)
const unsigned int NUM_COLLISION = 3;
const float COLLISION_TIME = 1.5f;
float time = World::getWorld()->getTime();
float time = World::getWorld()->getTimeSinceStart();
if(m_collision_times.size()==0)
{
m_collision_times.push_back(time);

View File

@ -1001,7 +1001,7 @@ void Kart::collectedItem(Item *item, int add_info)
*/
float Kart::getStartupBoost() const
{
float t = World::getWorld()->getTime();
float t = World::getWorld()->getTimeSinceStart();
std::vector<float> startup_times = m_kart_properties->getStartupTime();
for (unsigned int i = 0; i < startup_times.size(); i++)
{
@ -1991,9 +1991,9 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
*/
void Kart::playCrashSFX(const Material* m, AbstractKart *k)
{
if(World::getWorld()->getTime()-m_time_last_crash < 0.5f) return;
if(World::getWorld()->getTimeSinceStart()-m_time_last_crash < 0.5f) return;
m_time_last_crash = World::getWorld()->getTime();
m_time_last_crash = World::getWorld()->getTimeSinceStart();
// After a collision disable the engine for a short time so that karts
// can 'bounce back' a bit (without this the engine force will prevent
// karts from bouncing back, they will instead stuck towards the obstable).

View File

@ -113,15 +113,6 @@ const btTransform &FollowTheLeaderRace::getStartTransform(int index)
return m_track->getStartTransform(start_index);
} // getStartTransform
//-----------------------------------------------------------------------------
/** Returns the original time at which the countdown timer started. This is
* used by the race_gui to display the music credits in FTL mode correctly.
*/
float FollowTheLeaderRace::getClockStartTime() const
{
return m_leader_intervals[0];
} // getClockStartTime
//-----------------------------------------------------------------------------
/** Called when a kart must be eliminated.
*/

View File

@ -49,7 +49,6 @@ public:
virtual void reset() OVERRIDE;
virtual const std::string& getIdent() const OVERRIDE;
virtual const btTransform &getStartTransform(int index) OVERRIDE;
virtual float getClockStartTime() const;
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
virtual void init() OVERRIDE;

View File

@ -461,6 +461,7 @@ World::~World()
race_manager->setRaceGhostKarts(false);
race_manager->setRecordRace(false);
race_manager->setWatchingReplay(false);
race_manager->setTimeTarget(0.0f);
Camera::removeAllCameras();

View File

@ -70,7 +70,8 @@ void WorldStatus::reset()
{
m_time = 0.0f;
m_auxiliary_timer = 0.0f;
m_count_up_timer = 0.0f;
m_engines_started = false;
// Using SETUP_PHASE will play the track into sfx first, and has no
@ -340,16 +341,19 @@ void WorldStatus::update(const float dt)
{
case CLOCK_CHRONO:
m_time += dt;
m_count_up_timer += dt;
break;
case CLOCK_COUNTDOWN:
// stop countdown when race is over
if (m_phase == RESULT_DISPLAY_PHASE || m_phase == FINISH_PHASE)
{
m_time = 0.0f;
m_count_up_timer = 0.0f;
break;
}
m_time -= dt;
m_count_up_timer += dt;
if(m_time <= 0.0)
{

View File

@ -114,6 +114,8 @@ private:
*/
float m_auxiliary_timer;
float m_count_up_timer;
bool m_engines_started;
void startEngines();
public:
@ -172,6 +174,10 @@ public:
/** Called when the race actually starts. */
virtual void onGo() {};
// ------------------------------------------------------------------------
/** Get the time since start regardless of which way the clock counts */
float getTimeSinceStart() const { return m_count_up_timer; }
}; // WorldStatus

View File

@ -41,7 +41,7 @@
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp"
#include "karts/rescue_animation.hpp"
#include "modes/follow_the_leader.hpp"
#include "modes/linear_world.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@ -457,15 +457,7 @@ void RaceGUIBase::drawGlobalMusicDescription()
gui::IGUIFont* font = GUIEngine::getFont();
float race_time = World::getWorld()->getTime();
// In the modes that the clock counts backwards, convert the
// countdown time to time since start:
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
race_time = ((FollowTheLeaderRace*)World::getWorld())->getClockStartTime()
- race_time;
else if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_SOCCER &&
race_manager->hasTimeTarget())
race_time = race_manager->getTimeTarget() - World::getWorld()->getTime();
float race_time = World::getWorld()->getTimeSinceStart();
// ---- Manage pulsing effect
// 3.0 is the duration of ready/set (TODO: don't hardcode)