Convert more time handling to handling ticks.

This commit is contained in:
hiker
2018-03-20 09:25:39 +11:00
parent d3a60356c9
commit c456edd9f2
132 changed files with 899 additions and 829 deletions

View File

@@ -127,7 +127,7 @@ void STKConfig::load(const std::string &filename)
}
CHECK_NEG(m_max_karts, "<karts max=..." );
CHECK_NEG(m_item_switch_time, "item-switch-time" );
CHECK_NEG(m_item_switch_ticks, "item switch-time" );
CHECK_NEG(m_bubblegum_counter, "bubblegum disappear counter");
CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects" );
CHECK_NEG(m_max_skidmarks, "max-skidmarks" );
@@ -140,7 +140,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_delay_finish_time, "delay-finish-time" );
CHECK_NEG(m_music_credit_time, "music-credit-time" );
CHECK_NEG(m_leader_time_per_kart, "leader time-per-kart" );
CHECK_NEG(m_penalty_time, "penalty-time" );
CHECK_NEG(m_penalty_ticks, "penalty-time" );
CHECK_NEG(m_max_display_news, "max-display-news" );
CHECK_NEG(m_replay_max_time, "replay max-time" );
CHECK_NEG(m_replay_delta_angle, "replay delta-angle" );
@@ -167,10 +167,11 @@ void STKConfig::init_defaults()
m_bomb_time = m_bomb_time_increase =
m_explosion_impulse_objects = m_music_credit_time =
m_delay_finish_time = m_skid_fadeout_time =
m_near_ground = m_item_switch_time =
m_smooth_angle_limit = m_penalty_time =
m_default_track_friction = m_default_moveable_friction =
UNDEFINED;
m_near_ground =
m_smooth_angle_limit = m_default_track_friction =
m_default_moveable_friction = UNDEFINED;
m_item_switch_ticks = -100;
m_penalty_ticks = -100;
m_physics_fps = -100;
m_bubblegum_counter = -100;
m_shield_restrict_weapos = false;
@@ -266,7 +267,9 @@ void STKConfig::getAllData(const XMLNode * root)
if (const XMLNode *startup_node= root->getNode("startup"))
{
startup_node->get("penalty", &m_penalty_time );
float f;
startup_node->get("penalty", &f);
m_penalty_ticks = time2Ticks(f);
}
if (const XMLNode *news_node= root->getNode("news"))
@@ -347,7 +350,9 @@ void STKConfig::getAllData(const XMLNode * root)
if(const XMLNode *switch_node= root->getNode("switch"))
{
switch_node->get("items", &m_switch_items );
switch_node->get("time", &m_item_switch_time);
float f;
if( switch_node->get("time", &f) )
m_item_switch_ticks = stk_config->time2Ticks(f);
}
if(const XMLNode *bubblegum_node= root->getNode("bubblegum"))

View File

@@ -70,13 +70,13 @@ public:
float m_bomb_time; /**<Time before a bomb explodes. */
float m_bomb_time_increase; /**<Time added to bomb timer when it's
passed on. */
float m_item_switch_time; /**< Time items will be switched. */
int m_item_switch_ticks; /**< Time items will be switched. */
int m_bubblegum_counter; /**< How many times bubble gums must be
driven over before they disappear. */
bool m_shield_restrict_weapos; /**<Wether weapon usage is punished. */
float m_explosion_impulse_objects; /**<Impulse of explosion on moving
objects, e.g. road cones, ... */
float m_penalty_time; /**< Penalty time when starting too
int m_penalty_ticks; /**< Penalty time when starting too
early. */
float m_delay_finish_time; /**<Delay after a race finished before
the results are displayed. */

View File

@@ -20,6 +20,7 @@
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "config/stk_config.hpp"
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
@@ -31,14 +32,15 @@
#include "race/race_manager.hpp"
#include "utils/vec3.hpp"
const float burst_time = 0.1f;
/** Creates an explosion effect. */
Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char * particle_file)
: HitSFX(coord, explosion_sound)
{
// short emision time, explosion, not constant flame
m_remaining_time = burst_time;
m_explosion_ticks = stk_config->time2Ticks(2.0f);
m_remaining_ticks = stk_config->time2Ticks(0.1f);
m_emission_frames = 0;
#ifndef SERVER_ONLY
@@ -84,22 +86,22 @@ Explosion::~Explosion()
* \param dt Time step size.
* \return true If the explosion is finished.
*/
bool Explosion::updateAndDelete(float dt)
bool Explosion::updateAndDelete(int ticks)
{
// The explosion sfx is shorter than the particle effect,
// so no need to save the result of the update call.
HitSFX::updateAndDelete(dt);
HitSFX::updateAndDelete(ticks);
m_emission_frames++;
m_remaining_time -= dt;
m_remaining_ticks -= ticks;
// Do nothing more if the animation is still playing
if (m_remaining_time>0) return false;
if (m_remaining_ticks>0) return false;
// Otherwise check that the sfx has finished, otherwise the
// sfx will get aborted 'in the middle' when this explosion
// object is removed.
if (m_remaining_time > -explosion_time)
if (m_remaining_ticks > -m_explosion_ticks)
{
#ifndef SERVER_ONLY
// if framerate is very low, emit for at least a few frames, in case
@@ -122,3 +124,4 @@ bool Explosion::updateAndDelete(float dt)
return false; // not finished
} // updateAndDelete

View File

@@ -21,6 +21,7 @@
#define HEADER_EXPLOSION_HPP
#include "graphics/hit_sfx.hpp"
#include "utils/cpp2011.hpp"
#include "utils/no_copy.hpp"
namespace irr
@@ -33,23 +34,26 @@ class Vec3;
class SFXBase;
class ParticleEmitter;
const float explosion_time = 2.0f;
/**
* \ingroup graphics
*/
class Explosion : public HitSFX
{
private:
float m_remaining_time;
int m_remaining_ticks;
int m_emission_frames;
ParticleEmitter* m_emitter;
int m_explosion_ticks;
public:
Explosion(const Vec3& coord, const char* explosion_sound, const char * particle_file );
~Explosion();
bool updateAndDelete(float delta_t);
bool hasEnded () { return m_remaining_time <= -explosion_time; }
bool updateAndDelete(int ticks) OVERRIDE;
bool hasEnded ()
{
return m_remaining_ticks <= -m_explosion_ticks;
}
} ;

View File

@@ -43,7 +43,7 @@ public:
/** Updates a hit effect. Called once per frame.
* \param dt Time step size.
* \return True if the hit effect is finished and can be removed. */
virtual bool updateAndDelete(float dt) = 0;
virtual bool updateAndDelete(int ticks) = 0;
// ------------------------------------------------------------------------
/** Sets that this SFX affects a player kart, which can be used to

View File

@@ -61,7 +61,7 @@ void HitSFX::setLocalPlayerKartHit()
* \param dt Time step size.
* \return true If the explosion is finished.
*/
bool HitSFX::updateAndDelete(float dt)
bool HitSFX::updateAndDelete(int ticks)
{
SFXBase::SFXStatus status = m_sfx->getStatus();
return status!= SFXBase::SFX_PLAYING;

View File

@@ -36,7 +36,7 @@ private:
public:
HitSFX(const Vec3& coord, const char* explosion_sound);
~HitSFX();
virtual bool updateAndDelete(float dt) OVERRIDE;
virtual bool updateAndDelete(int ticks) OVERRIDE;
virtual void setLocalPlayerKartHit() OVERRIDE;
}; // HitSFX

View File

@@ -152,7 +152,9 @@ Material::Material(const XMLNode *node, bool deprecated)
node->get("ignore", &m_ignore );
node->get("max-speed", &m_max_speed_fraction );
node->get("slowdown-time", &m_slowdown_time );
float f = stk_config->ticks2Time(m_slowdown_ticks);
node->get("slowdown-time", &f );
m_slowdown_ticks = stk_config->time2Ticks(f);
node->get("colorizable", &m_colorizable );
node->get("colorization-factor", &m_colorization_factor);
node->get("hue-settings", &m_hue_settings );
@@ -484,7 +486,7 @@ void Material::init()
m_colorization_factor = 0.0f;
m_colorization_mask = "";
m_max_speed_fraction = 1.0f;
m_slowdown_time = 1.0f;
m_slowdown_ticks = stk_config->time2Ticks(1.0f);
m_sfx_name = "";
m_sfx_min_speed = 0.0f;
m_sfx_max_speed = 30;

View File

@@ -155,7 +155,7 @@ private:
RandomGenerator m_random_hue;
/** How much the top speed is reduced per second. */
float m_slowdown_time;
int m_slowdown_ticks;
/** Maximum speed at which no more slow down occurs. */
float m_max_speed_fraction;
@@ -287,7 +287,7 @@ public:
/** Returns how long it will take for a slowdown to take effect.
* It is the time it takes till the full slowdown applies to
* karts. So a short time will slowdown a kart much faster. */
float getSlowDownTime() const { return m_slowdown_time; }
int getSlowDownTicks() const { return m_slowdown_ticks; }
// ------------------------------------------------------------------------
/** Returns true if this material is under some other mesh and therefore
* requires another raycast to find the surface it is under (used for

View File

@@ -63,7 +63,7 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
}
#endif
m_slipstream_time = 0.0f;
m_slipstream_ticks = 0;
float length = m_kart->getKartProperties()->getSlipstreamLength();
float kw = m_kart->getKartWidth();
@@ -122,8 +122,8 @@ SlipStream::~SlipStream()
/** Called at re-start of a race. */
void SlipStream::reset()
{
m_slipstream_mode = SS_NONE;
m_slipstream_time = 0;
m_slipstream_mode = SS_NONE;
m_slipstream_ticks = 0;
// Reset a potential max speed increase
m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, 0, 0, 0, 0);
@@ -188,7 +188,7 @@ SP::SPMesh* SlipStream::createMesh(Material* material)
("custom_alpha", [this](SP::SPUniformAssigner* ua)->void
{
// In sp shader it's assigned reverse by 1.0 - custom_alpha
ua->setValue(1.0f - m_slipstream_time);
ua->setValue(1.0f - stk_config->ticks2Time(m_slipstream_ticks));
});
std::vector<uint16_t> indices;
@@ -289,8 +289,8 @@ void SlipStream::setIntensity(float f, const AbstractKart *kart)
*/
bool SlipStream::isSlipstreamReady() const
{
return m_slipstream_time>
m_kart->getKartProperties()->getSlipstreamCollectTime();
return m_slipstream_ticks>
m_kart->getKartProperties()->getSlipstreamCollectTicks();
} // isSlipstreamReady
//-----------------------------------------------------------------------------
@@ -309,7 +309,7 @@ void SlipStream::updateSlipstreamPower()
kp->getSlipstreamMaxSpeedIncrease(),
kp->getSlipstreamAddPower(),
kp->getSlipstreamDuration(),
kp->getSlipstreamFadeOutTime());
kp->getSlipstreamFadeOutTicks());
}
} // upateSlipstreamPower
@@ -341,7 +341,7 @@ void SlipStream::setDebugColor(const video::SColor &color)
/** Update, called once per timestep.
* \param dt Time step size.
*/
void SlipStream::update(float dt)
void SlipStream::update(int ticks)
{
const KartProperties *kp = m_kart->getKartProperties();
@@ -350,12 +350,12 @@ void SlipStream::update(float dt)
|| m_kart->isGhostKart())
return;
MovingTexture::update(dt);
MovingTexture::update(stk_config->ticks2Time(ticks));
if(m_slipstream_mode==SS_USE)
{
m_slipstream_time -= dt;
if(m_slipstream_time<0) m_slipstream_mode=SS_NONE;
m_slipstream_ticks -= ticks;
if(m_slipstream_ticks<0) m_slipstream_mode=SS_NONE;
}
updateSlipstreamPower();
@@ -463,28 +463,33 @@ void SlipStream::update(float dt)
{
m_slipstream_mode = SS_USE;
m_kart->handleZipper();
m_slipstream_time = kp->getSlipstreamCollectTime();
m_slipstream_ticks = kp->getSlipstreamCollectTicks();
return;
}
}
m_slipstream_time -=dt;
if(m_slipstream_time<0) m_slipstream_mode = SS_NONE;
m_slipstream_ticks -= ticks;
if(m_slipstream_ticks<0) m_slipstream_mode = SS_NONE;
setIntensity(0, NULL);
return;
} // if !is_sstreaming
if(UserConfigParams::m_slipstream_debug &&
m_kart->getController()->isLocalPlayerController())
m_target_kart->getSlipstream()->setDebugColor(video::SColor(255, 0, 255, 0));
m_target_kart->getSlipstream()
->setDebugColor(video::SColor(255, 0, 255, 0));
// Accumulate slipstream credits now
m_slipstream_time = m_slipstream_mode==SS_NONE ? dt
: m_slipstream_time+dt;
if (m_slipstream_mode == SS_NONE)
m_slipstream_ticks = ticks;
else
m_slipstream_ticks += ticks;
if(isSlipstreamReady())
m_kart->setSlipstreamEffect(9.0f);
setIntensity(m_slipstream_time, m_target_kart);
setIntensity(stk_config->ticks2Time(m_slipstream_ticks), m_target_kart);
m_slipstream_mode = SS_COLLECT;
if (m_slipstream_time > kp->getSlipstreamCollectTime())
if (m_slipstream_ticks > kp->getSlipstreamCollectTicks())
{
setIntensity(1.0f, m_target_kart);
}

View File

@@ -61,7 +61,7 @@ private:
float m_length;
/** The time a kart was in slipstream. */
float m_slipstream_time;
int m_slipstream_ticks;
/** Slipstream mode: either nothing happening, or the kart is collecting
* 'slipstream credits', or the kart is using accumulated credits. */
@@ -80,7 +80,7 @@ public:
SlipStream (AbstractKart* kart);
virtual ~SlipStream ();
void reset();
virtual void update(float dt);
virtual void update(int ticks);
void setIntensity(float f, const AbstractKart* kart);
void updateSlipstreamPower();
bool isSlipstreamReady() const;

View File

@@ -30,7 +30,7 @@ Weather::Weather()
{
m_thunder_sound = NULL;
m_weather_sound = NULL;
m_lightning = 0.0f;
m_lightning = 0;
if (Track::getCurrentTrack()->getWeatherLightning())
{
@@ -44,7 +44,7 @@ Weather::Weather()
}
RandomGenerator g;
m_next_lightning = (float)g.get(35);
m_next_lightning = stk_config->time2Ticks((float)g.get(35));
} // Weather
// ----------------------------------------------------------------------------
@@ -60,7 +60,7 @@ Weather::~Weather()
// ----------------------------------------------------------------------------
void Weather::update(float dt)
void Weather::update(int ticks)
{
if (!Track::getCurrentTrack()->getWeatherLightning())
return;
@@ -68,9 +68,9 @@ void Weather::update(float dt)
if (World::getWorld()->getRaceGUI() == NULL)
return;
m_next_lightning -= dt;
m_next_lightning -= ticks;
if (m_next_lightning < 0.0f)
if (m_next_lightning < 0)
{
startLightning();
@@ -80,12 +80,12 @@ void Weather::update(float dt)
}
RandomGenerator g;
m_next_lightning = 35 + (float)g.get(35);
m_next_lightning = stk_config->time2Ticks(35.0f + (float)g.get(35));
}
if (m_lightning > 0.0f)
if (m_lightning > 0)
{
m_lightning -= dt;
m_lightning -= ticks;
}
} // update
@@ -100,11 +100,20 @@ void Weather::playSound()
}
}
// ----------------------------------------------------------------------------
/** Set the flag that a lightning should be shown. */
void Weather::startLightning()
{
m_lightning = stk_config->time2Ticks(1.0f);
} // startLightning
// ----------------------------------------------------------------------------
irr::core::vector3df Weather::getIntensity()
{
irr::core::vector3df value = {0.7f * m_lightning,
0.7f * m_lightning,
0.7f * std::min(1.0f, m_lightning * 1.5f)};
float light = stk_config->ticks2Time(m_lightning);
irr::core::vector3df value = {0.7f * light,
0.7f * light,
0.7f * std::min(1.0f, light * 1.5f)};
return value;
}
} // getIntensity

View File

@@ -26,8 +26,11 @@ class SFXBase;
class Weather : public AbstractSingleton<Weather>
{
float m_next_lightning;
float m_lightning;
/** Counts ticks till the next lighting appears. */
int m_next_lightning;
/** Counts the ticks for displaying the current lighting. */
int m_lightning;
SFXBase* m_thunder_sound;
SFXBase* m_weather_sound;
@@ -36,14 +39,13 @@ public:
Weather();
virtual ~Weather();
void update(float dt);
void update(int ticks);
void playSound();
/** Set the flag that a lightning should be shown. */
void startLightning() { m_lightning = 1.0f; }
bool shouldLightning() { return m_lightning > 0.0f; }
void startLightning();
irr::core::vector3df getIntensity();
};
bool shouldLightning() { return m_lightning > 0; }
}; // class Weather
#endif

View File

@@ -366,8 +366,9 @@ void Attachment::hitBanana(Item *item, int new_attachment)
// default time. This is necessary to avoid that a kart lands on the
// same banana again once the explosion animation is finished, giving
// the kart the same penalty twice.
float f = std::max(item->getDisableTime(), kp->getExplosionDuration() + 2.0f);
item->setDisableTime(f);
int ticks = std::max(item->getDisableTicks(),
stk_config->time2Ticks(kp->getExplosionDuration() + 2.0f));
item->setDisableTicks(ticks);
break;
}
case ATTACH_ANVIL:
@@ -490,7 +491,7 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
} // handleCollisionWithKart
//-----------------------------------------------------------------------------
void Attachment::update(float dt)
void Attachment::update(int ticks)
{
if(m_type==ATTACH_NOTHING) return;
@@ -499,7 +500,7 @@ void Attachment::update(float dt)
if (m_type == ATTACH_BOMB && m_kart->getKartAnimation() != NULL)
return;
m_ticks_left--; // dt always physics time step
m_ticks_left -= ticks;
bool is_shield = m_type == ATTACH_BUBBLEGUM_SHIELD ||
@@ -526,6 +527,7 @@ void Attachment::update(float dt)
m_node->setVisible(mod > ticks_per_flash);
}
float dt = stk_config->ticks2Time(ticks);
if (m_node_scale < m_wanted_node_scale)
{
m_node_scale += dt*1.5f;
@@ -537,7 +539,7 @@ void Attachment::update(float dt)
if(m_plugin)
{
bool discard = m_plugin->updateAndTestFinished(dt);
bool discard = m_plugin->updateAndTestFinished(ticks);
if(discard)
{
clear(); // also removes the plugin

View File

@@ -112,7 +112,7 @@ public:
~Attachment();
void clear ();
void hitBanana(Item *item, int new_attachment=-1);
void update (float dt);
void update(int ticks);
void handleCollisionWithKart(AbstractKart *other);
void set (AttachmentType type, int ticks,
AbstractKart *previous_kart=NULL);

View File

@@ -52,7 +52,7 @@ public:
// ------------------------------------------------------------------------
/** Updates a plugin. This is called once each time frame. If the
* function returns true, the attachment is discarded. */
virtual bool updateAndTestFinished(float dt) = 0;
virtual bool updateAndTestFinished(int ticks) = 0;
// ------------------------------------------------------------------------
/** Called when the animation of the Attachment's node is done. */

View File

@@ -76,7 +76,7 @@ Bowling::Bowling(AbstractKart *kart)
getBody()->setCollisionFlags(flag);
// should not live forever, auto-destruct after 20 seconds
m_max_lifespan = 20;
m_max_lifespan = stk_config->time2Ticks(20);
m_roll_sfx = SFXManager::get()->createSoundSource("bowling_roll");
m_roll_sfx->play();
@@ -118,9 +118,9 @@ void Bowling::init(const XMLNode &node, scene::IMesh *bowling)
* \param dt Time step size.
* \returns True of this object should be removed.
*/
bool Bowling::updateAndDelete(float dt)
bool Bowling::updateAndDelete(int ticks)
{
bool can_be_deleted = Flyable::updateAndDelete(dt);
bool can_be_deleted = Flyable::updateAndDelete(ticks);
if(can_be_deleted)
return true;

View File

@@ -53,7 +53,7 @@ public:
Bowling(AbstractKart* kart);
virtual ~Bowling();
static void init(const XMLNode &node, scene::IMesh *bowling);
virtual bool updateAndDelete(float dt);
virtual bool updateAndDelete(int ticks);
virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
virtual HitEffect *getHitEffect() const;

View File

@@ -70,7 +70,7 @@ Flyable::Flyable(AbstractKart *kart, PowerupManager::PowerupType type,
m_animation = NULL;
m_mass = mass;
m_adjust_up_velocity = true;
m_time_since_thrown = 0;
m_ticks_since_thrown = 0;
m_position_offset = Vec3(0,0,0);
m_owner_has_temporary_immunity = true;
m_do_terrain_info = true;
@@ -377,17 +377,17 @@ void Flyable::setAnimation(AbstractKartAnimation *animation)
* \param dt Time step size.
* \returns True if this object can be deleted.
*/
bool Flyable::updateAndDelete(float dt)
bool Flyable::updateAndDelete(int ticks)
{
if (hasAnimation())
{
m_animation->update(dt);
Moveable::update(dt);
m_animation->update(stk_config->ticks2Time(ticks));
Moveable::update(ticks);
return false;
} // if animation
m_time_since_thrown += dt;
if(m_max_lifespan > -1 && m_time_since_thrown > m_max_lifespan)
m_ticks_since_thrown += ticks;
if(m_max_lifespan > -1 && m_ticks_since_thrown > m_max_lifespan)
hit(NULL);
if(m_has_hit_something) return true;
@@ -465,7 +465,7 @@ bool Flyable::updateAndDelete(float dt)
setVelocity(v);
} // if m_adjust_up_velocity
Moveable::update(dt);
Moveable::update(ticks);
return false;
} // updateAndDelete
@@ -478,8 +478,8 @@ bool Flyable::updateAndDelete(float dt)
bool Flyable::isOwnerImmunity(const AbstractKart* kart_hit) const
{
return m_owner_has_temporary_immunity &&
kart_hit == m_owner &&
m_time_since_thrown < 2.0f;
kart_hit == m_owner &&
m_ticks_since_thrown < stk_config->time2Ticks(2.0f);
} // isOwnerImmunity
// ----------------------------------------------------------------------------

View File

@@ -127,11 +127,11 @@ protected:
/** Time since thrown. used so a kart can't hit himself when trying
* something, and also to put some time limit to some collectibles */
float m_time_since_thrown;
int m_ticks_since_thrown;
/** Set to something > -1 if this flyable should auto-destrcut after
* a while. */
float m_max_lifespan;
* that may ticks. */
int m_max_lifespan;
/** If set to true, the kart that throwns this flyable can't collide
* with it for a short time. */
@@ -167,7 +167,7 @@ public:
virtual ~Flyable ();
static void init (const XMLNode &node, scene::IMesh *model,
PowerupManager::PowerupType type);
virtual bool updateAndDelete(float);
virtual bool updateAndDelete(int ticks);
virtual void setAnimation(AbstractKartAnimation *animation);
virtual HitEffect* getHitEffect() const;
bool isOwnerImmunity(const AbstractKart *kart_hit) const;

View File

@@ -118,8 +118,8 @@ void Item::initItem(ItemType type, const Vec3 &xyz)
m_item_id = -1;
m_collected = false;
m_original_type = ITEM_NONE;
m_deactive_time = 0;
m_time_till_return = 0.0f; // not strictly necessary, see isCollected()
m_deactive_ticks = 0;
m_ticks_till_return = 0; // not strictly necessary, see isCollected()
m_emitter = NULL;
m_rotate = (type!=ITEM_BUBBLEGUM) && (type!=ITEM_TRIGGER);
switch(m_type)
@@ -265,8 +265,8 @@ Item::~Item()
void Item::reset()
{
m_collected = false;
m_time_till_return = 0.0f;
m_deactive_time = 0.0f;
m_ticks_till_return = 0;
m_deactive_ticks = 0;
switch(m_type)
{
case ITEM_BUBBLEGUM:
@@ -296,24 +296,24 @@ void Item::reset()
*/
void Item::setParent(AbstractKart* parent)
{
m_event_handler = parent;
m_emitter = parent;
m_deactive_time = 1.5f;
m_event_handler = parent;
m_emitter = parent;
m_deactive_ticks = stk_config->time2Ticks(1.5f);
} // setParent
//-----------------------------------------------------------------------------
/** Updated the item - rotates it, takes care of items coming back into
* the game after it has been collected.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void Item::update(float dt)
void Item::update(int ticks)
{
if(m_deactive_time > 0) m_deactive_time -= dt;
if(m_deactive_ticks > 0) m_deactive_ticks -= ticks;
if(m_collected)
{
m_time_till_return -= dt;
if(m_time_till_return<0)
m_ticks_till_return -= ticks;
if(m_ticks_till_return<0)
{
m_collected=false;
@@ -322,13 +322,14 @@ void Item::update(float dt)
m_node->setScale(core::vector3df(1,1,1));
}
} // time till return <0 --> is fully visible again
else if ( m_time_till_return <=1.0f )
else if ( m_ticks_till_return <= stk_config->time2Ticks(1.0f) )
{
if (m_node != NULL)
{
// Make it visible by scaling it from 0 to 1:
m_node->setVisible(true);
m_node->setScale(core::vector3df(1,1,1)*(1-m_time_till_return));
float t = stk_config->ticks2Time(m_ticks_till_return);
m_node->setScale(core::vector3df(1,1,1)*(1-t));
}
} // time till return < 1
} // if collected
@@ -337,8 +338,11 @@ void Item::update(float dt)
if(!m_rotate || m_node == NULL) return;
// have it rotate
if(!RewindManager::get()->isRewinding())
if (!RewindManager::get()->isRewinding())
{
float dt = stk_config->ticks2Time(ticks);
m_rotation_angle += dt * M_PI;
}
if (m_rotation_angle > M_PI * 2) m_rotation_angle -= M_PI * 2;
btMatrix3x3 m;
@@ -364,7 +368,7 @@ void Item::collected(const AbstractKart *kart, float t)
m_event_handler = kart;
if(m_type==ITEM_EASTER_EGG)
{
m_time_till_return=99999;
m_ticks_till_return=stk_config->time2Ticks(99999);
EasterEggHunt *world = dynamic_cast<EasterEggHunt*>(World::getWorld());
assert(world);
world->collectedEasterEgg(kart);
@@ -379,16 +383,16 @@ void Item::collected(const AbstractKart *kart, float t)
// Deactivates the item for a certain amount of time. It is used to
// prevent bubble gum from hitting a kart over and over again (in each
// frame) by giving it time to drive away.
m_deactive_time = 0.5f;
m_deactive_ticks = stk_config->time2Ticks(0.5f);
// Set the time till reappear to -1 seconds --> the item will
// reappear immediately.
m_time_till_return = -1;
m_ticks_till_return = -1;
}
else
{
// Note if the time is negative, in update the m_collected flag will
// be automatically set to false again.
m_time_till_return = t;
m_ticks_till_return = stk_config->time2Ticks(t);
if (m_node != NULL)
{
m_node->setVisible(false);
@@ -402,7 +406,7 @@ void Item::collected(const AbstractKart *kart, float t)
if (dynamic_cast<ThreeStrikesBattle*>(World::getWorld()) != NULL)
{
m_time_till_return *= 3;
m_ticks_till_return *= 3;
}
} // isCollected

View File

@@ -111,7 +111,7 @@ private:
bool m_collected;
/** Time till a collected item reappears. */
float m_time_till_return;
int m_ticks_till_return;
/** Scene node of this item. */
LODNode *m_node;
@@ -131,7 +131,7 @@ private:
bool m_rotate;
/** Optionally set this if this item was laid by a particular kart. in
* this case the 'm_deactive_time' will also be set - see below. */
* this case the 'm_deactive_ticks' will also be set - see below. */
const AbstractKart *m_event_handler;
/** Kart that emitted this item if any */
@@ -139,7 +139,7 @@ private:
/** Optionally if item was placed by a kart, a timer can be used to
* temporarly deactivate collision so a kart is not hit by its own item */
float m_deactive_time;
int m_deactive_ticks;
/** Counts how often an item is used before it disappears. Used for
* bubble gum to make them disappear after a while. A value >0
@@ -176,7 +176,7 @@ public:
Item(const Vec3& xyz, float distance,
TriggerItemListener* trigger);
virtual ~Item ();
void update (float delta);
void update(int ticks);
virtual void collected(const AbstractKart *kart, float t=2.0f);
void setParent(AbstractKart* parent);
void reset();
@@ -195,7 +195,7 @@ public:
*/
bool hitKart(const Vec3 &xyz, const AbstractKart *kart=NULL) const
{
if (m_event_handler == kart && m_deactive_time > 0)
if (m_event_handler == kart && m_deactive_ticks > 0)
return false;
Vec3 lc = quatRotate(m_original_rotation, xyz - m_xyz);
// Don't be too strict if the kart is a bit above the item
@@ -216,7 +216,7 @@ protected:
bool hitLine(const core::line3df &line,
const AbstractKart *kart=NULL) const
{
if(m_event_handler==kart && m_deactive_time >0) return false;
if(m_event_handler==kart && m_deactive_ticks >0) return false;
Vec3 closest = line.getClosestPoint(m_xyz.toIrrVector());
return hitKart(closest, kart);
@@ -251,10 +251,10 @@ public:
* details.
* \param f Time till the item can be used again.
*/
void setDisableTime(float f) { m_time_till_return = f; }
void setDisableTicks(int t) { m_ticks_till_return = t; }
// ------------------------------------------------------------------------
/** Returns the time the item is disabled for. */
float getDisableTime() const { return m_time_till_return; }
int getDisableTicks() const { return m_ticks_till_return; }
// ------------------------------------------------------------------------
/** Returns the XYZ position of the item. */
const Vec3& getXYZ() const { return m_xyz; }

View File

@@ -156,7 +156,7 @@ void ItemManager::removeTextures()
* of each race. */
ItemManager::ItemManager()
{
m_switch_time = -1.0f;
m_switch_ticks = -1;
// The actual loading is done in loadDefaultItems
// Prepare the switch to array, which stores which item should be
@@ -266,7 +266,7 @@ Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz,
insertItem(item);
if(parent != NULL) item->setParent(parent);
if(m_switch_time>=0)
if(m_switch_ticks>=0)
{
Item::ItemType new_type = m_switch_to[item->getType()];
item->switchTo(new_type, m_item_mesh[(int)new_type],
@@ -354,14 +354,14 @@ void ItemManager::checkItemHit(AbstractKart* kart)
void ItemManager::reset()
{
// If items are switched, switch them back first.
if(m_switch_time>=0)
if(m_switch_ticks>=0)
{
for(AllItemTypes::iterator i =m_all_items.begin();
i!=m_all_items.end(); i++)
{
if(*i) (*i)->switchBack();
}
m_switch_time = -1.0f;
m_switch_ticks = -1;
}
@@ -388,36 +388,36 @@ void ItemManager::reset()
}
} // whilem_all_items.end() i
m_switch_time = -1;
m_switch_ticks = -1;
} // reset
//-----------------------------------------------------------------------------
/** Updates all items, and handles switching items back if the switch time
* is over.
* \param dt Time step.
* \param ticks Number of physics time steps - should be 1.
*/
void ItemManager::update(float dt)
void ItemManager::update(int ticks)
{
// If switch time is over, switch all items back
if(m_switch_time>=0)
if(m_switch_ticks>=0)
{
m_switch_time -= dt;
if(m_switch_time<0)
m_switch_ticks -= ticks;
if(m_switch_ticks<0)
{
for(AllItemTypes::iterator i =m_all_items.begin();
i!=m_all_items.end(); i++)
{
if(*i) (*i)->switchBack();
} // for m_all_items
} // m_switch_time < 0
} // m_switch_time>=0
} // m_switch_ticks < 0
} // m_switch_ticks>=0
for(AllItemTypes::iterator i =m_all_items.begin();
i!=m_all_items.end(); i++)
{
if(*i)
{
(*i)->update(dt);
(*i)->update(ticks);
if( (*i)->isUsedUp())
{
deleteItem( *i );
@@ -472,16 +472,16 @@ void ItemManager::switchItems()
Item::ItemType new_type = m_switch_to[(*i)->getType()];
if(m_switch_time<0)
if(m_switch_ticks<0)
(*i)->switchTo(new_type, m_item_mesh[(int)new_type], m_item_lowres_mesh[(int)new_type]);
else
(*i)->switchBack();
} // for m_all_items
// if the items are already switched (m_switch_time >=0)
// then switch back, and set m_switch_time to -1 to indicate
// if the items are already switched (m_switch_ticks >=0)
// then switch back, and set m_switch_ticks to -1 to indicate
// that the items are now back to normal.
m_switch_time = m_switch_time < 0 ? stk_config->m_item_switch_time : -1;
m_switch_ticks = m_switch_ticks < 0 ? stk_config->m_item_switch_ticks : -1;
} // switchItems

View File

@@ -90,7 +90,7 @@ private:
/** Remaining time that items should remain switched. If the
* value is <0, it indicates that the items are not switched atm. */
float m_switch_time;
int m_switch_ticks;
void insertItem(Item *item);
void deleteItem(Item *item);
@@ -106,7 +106,7 @@ public:
AbstractKart* parent=NULL);
Item* newItem (const Vec3& xyz, float distance,
TriggerItemListener* listener);
void update (float delta);
void update (int ticks);
void checkItemHit (AbstractKart* kart);
void reset ();
void collectedItem (Item *item, AbstractKart *kart,

View File

@@ -122,24 +122,24 @@ void Plunger::init(const XMLNode &node, scene::IMesh *plunger_model)
* \param dt Time step size.
* \returns True of this object should be removed.
*/
bool Plunger::updateAndDelete(float dt)
bool Plunger::updateAndDelete(int ticks)
{
// In keep-alive mode, just update the rubber band
if(m_keep_alive >= 0)
{
m_keep_alive -= dt;
m_keep_alive -= ticks;
if(m_keep_alive<=0)
{
setHasHit();
return true;
}
if(m_rubber_band != NULL) m_rubber_band->update(dt);
if(m_rubber_band != NULL) m_rubber_band->update(ticks);
return false;
}
// Else: update the flyable and rubber band
bool ret = Flyable::updateAndDelete(dt);
if(m_rubber_band != NULL) m_rubber_band->update(dt);
bool ret = Flyable::updateAndDelete(ticks);
if(m_rubber_band != NULL) m_rubber_band->update(ticks);
return ret;
@@ -179,11 +179,12 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
}
else
{
m_keep_alive = m_owner->getKartProperties()->getPlungerBandDuration();
m_keep_alive = stk_config->time2Ticks(m_owner->getKartProperties()
->getPlungerBandDuration() );
// Make this object invisible by placing it faaar down. Not that if this
// objects is simply removed from the scene graph, it might be auto-deleted
// because the ref count reaches zero.
// Make this object invisible by placing it faaar down. Not that if
// this objects is simply removed from the scene graph, it might be
// auto-deleted because the ref count reaches zero.
scene::ISceneNode *node = getNode();
if(node)
{

View File

@@ -40,8 +40,10 @@ class Plunger : public Flyable
private:
/** The rubber band attached to a plunger. */
RubberBand *m_rubber_band;
/** Timer to keep the plunger alive while the rubber band is working. */
float m_keep_alive;
/** Ticks to keep the plunger alive while the rubber band is working. */
int m_keep_alive;
btVector3 m_initial_velocity;
bool m_reverse_mode;
@@ -49,7 +51,7 @@ public:
Plunger(AbstractKart *kart);
~Plunger();
static void init(const XMLNode &node, scene::IMesh* missile);
virtual bool updateAndDelete(float dt);
virtual bool updateAndDelete(int ticks);
virtual void hitTrack ();
virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL);
@@ -57,7 +59,7 @@ public:
/** Sets the keep-alive value. Setting it to 0 will remove the plunger
* at the next update - which is used if the rubber band snaps.
*/
void setKeepAlive(float t) {m_keep_alive = t;}
void setKeepAlive(int ticks) {m_keep_alive = ticks;}
// ------------------------------------------------------------------------
/** No hit effect when it ends. */
virtual HitEffect *getHitEffect() const {return NULL; }

View File

@@ -63,9 +63,9 @@ void ProjectileManager::cleanup()
// -----------------------------------------------------------------------------
/** General projectile update call. */
void ProjectileManager::update(float dt)
void ProjectileManager::update(int ticks)
{
updateServer(dt);
updateServer(ticks);
HitEffects::iterator he = m_active_hit_effects.begin();
while(he!=m_active_hit_effects.end())
@@ -77,7 +77,7 @@ void ProjectileManager::update(float dt)
he = next;
}
// Update this hit effect. If it can be removed, remove it.
else if((*he)->updateAndDelete(dt))
else if((*he)->updateAndDelete(ticks))
{
delete *he;
HitEffects::iterator next = m_active_hit_effects.erase(he);
@@ -90,12 +90,12 @@ void ProjectileManager::update(float dt)
// -----------------------------------------------------------------------------
/** Updates all rockets on the server (or no networking). */
void ProjectileManager::updateServer(float dt)
void ProjectileManager::updateServer(int ticks)
{
Projectiles::iterator p = m_active_projectiles.begin();
while(p!=m_active_projectiles.end())
{
bool can_be_deleted = (*p)->updateAndDelete(dt);
bool can_be_deleted = (*p)->updateAndDelete(ticks);
if(can_be_deleted)
{
HitEffect *he = (*p)->getHitEffect();

View File

@@ -52,13 +52,13 @@ private:
* being shown or have a sfx playing. */
HitEffects m_active_hit_effects;
void updateServer(float dt);
void updateServer(int ticks);
public:
ProjectileManager() {}
~ProjectileManager() {}
void loadData ();
void cleanup ();
void update (float dt);
void update (int ticks);
Flyable* newProjectile (AbstractKart *kart,
PowerupManager::PowerupType type);
void Deactivate (Flyable *p) {}

View File

@@ -42,7 +42,7 @@ float RubberBall::m_st_squash_duration;
float RubberBall::m_st_squash_slowdown;
float RubberBall::m_st_target_distance;
float RubberBall::m_st_target_max_angle;
float RubberBall::m_st_delete_time;
int RubberBall::m_st_delete_ticks;
float RubberBall::m_st_max_height_difference;
float RubberBall::m_st_fast_ping_distance;
float RubberBall::m_st_early_target_factor;
@@ -75,7 +75,7 @@ RubberBall::RubberBall(AbstractKart *kart)
// Do not adjust the up velocity
setAdjustUpVelocity(false);
m_max_lifespan = 9999;
m_max_lifespan = stk_config->time2Ticks(9999);
m_target = NULL;
m_aiming_at_target = false;
m_fast_ping = false;
@@ -89,7 +89,7 @@ RubberBall::RubberBall(AbstractKart *kart)
m_previous_xyz = m_owner->getXYZ();
m_previous_height = 2.0f; //
// A negative value indicates that the timer is not active
m_delete_timer = -1.0f;
m_delete_ticks = -1;
m_tunnel_count = 0;
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
@@ -173,13 +173,13 @@ void RubberBall::computeTarget()
{
// If the firing kart itself is the first kart (that is
// still driving), prepare to remove the rubber ball
if(m_target==m_owner && m_delete_timer < 0)
if(m_target==m_owner && m_delete_ticks < 0)
{
#ifdef PRINT_BALL_REMOVE_INFO
Log::debug("[RubberBall]",
"ball %d removed because owner is target.", m_id);
#endif
m_delete_timer = m_st_delete_time;
m_delete_ticks = m_st_delete_ticks;
}
return;
}
@@ -192,7 +192,7 @@ void RubberBall::computeTarget()
Log::debug("[RubberBall]" "ball %d removed because no more active target.",
m_id);
#endif
m_delete_timer = m_st_delete_time;
m_delete_ticks = m_st_delete_ticks;
m_target = m_owner;
} // computeTarget
@@ -268,7 +268,7 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
m_st_min_interpolation_distance = 30.0f;
m_st_target_distance = 50.0f;
m_st_target_max_angle = 25.0f;
m_st_delete_time = 10.0f;
m_st_delete_ticks = stk_config->time2Ticks(10.0f);
m_st_max_height_difference = 10.0f;
m_st_fast_ping_distance = 50.0f;
m_st_early_target_factor = 1.0f;
@@ -288,8 +288,10 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
if(!node.get("target-distance", &m_st_target_distance))
Log::warn("powerup",
"No target-distance specified for rubber ball.");
if(!node.get("delete-time", &m_st_delete_time))
float f;
if(!node.get("delete-time", &f))
Log::warn("powerup", "No delete-time specified for rubber ball.");
m_st_delete_ticks = stk_config->time2Ticks(f);
if(!node.get("target-max-angle", &m_st_target_max_angle))
Log::warn("powerup", "No target-max-angle specified for rubber ball.");
m_st_target_max_angle *= DEGREE_TO_RAD;
@@ -318,17 +320,17 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
* \param dt Time step size.
* \returns True if the rubber ball should be removed.
*/
bool RubberBall::updateAndDelete(float dt)
bool RubberBall::updateAndDelete(int ticks)
{
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
// FIXME: what does the rubber ball do in case of battle mode??
if(!world) return true;
if(m_delete_timer>0)
if(m_delete_ticks>0)
{
m_delete_timer -= dt;
if(m_delete_timer<=0)
m_delete_ticks -= 1;
if(m_delete_ticks<=0)
{
hit(NULL);
#ifdef PRINT_BALL_REMOVE_INFO
@@ -343,7 +345,7 @@ bool RubberBall::updateAndDelete(float dt)
// Flyable will call update() of the animation to
// update the ball's position.
m_previous_xyz = getXYZ();
return Flyable::updateAndDelete(dt);
return Flyable::updateAndDelete(ticks);
}
// Update the target in case that the first kart was overtaken (or has
@@ -355,9 +357,9 @@ bool RubberBall::updateAndDelete(float dt)
// since it still needs to be adjusted for the height of the terrain.
Vec3 next_xyz;
if(m_aiming_at_target)
moveTowardsTarget(&next_xyz, dt);
moveTowardsTarget(&next_xyz, ticks);
else
interpolate(&next_xyz, dt);
interpolate(&next_xyz, ticks);
// If the ball is close to the ground, we have to start the raycast
// slightly higher (to avoid that the ball tunnels through the floor).
@@ -374,7 +376,7 @@ bool RubberBall::updateAndDelete(float dt)
// Flyable::update for rubber balls.
TerrainInfo::update(next_xyz + getNormal()*vertical_offset, -getNormal());
m_height_timer += dt;
m_height_timer += stk_config->ticks2Time(ticks);
float height = updateHeight()+m_extend.getY()*0.5f;
if(UserConfigParams::logFlyable())
@@ -426,7 +428,7 @@ bool RubberBall::updateAndDelete(float dt)
// Determine new distance along track
TrackSector::update(next_xyz);
return Flyable::updateAndDelete(dt);
return Flyable::updateAndDelete(ticks);
} // updateAndDelete
// ----------------------------------------------------------------------------
@@ -434,9 +436,9 @@ bool RubberBall::updateAndDelete(float dt)
* once the rubber ball is close to its target. It restricts the angle by
* which the rubber ball can change its direction per frame.
* \param next_xyz The position the ball should move to.
* \param dt Time step size.
* \param ticks Number of physics steps - should be 1.
*/
void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
void RubberBall::moveTowardsTarget(Vec3 *next_xyz, int ticks)
{
// If the rubber ball is already close to a target, i.e. aiming
// at it directly, stop interpolating, instead fly straight
@@ -447,7 +449,11 @@ void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
if(diff.length2()==0)
*next_xyz = getXYZ() - getNormal()*m_previous_height;
else
*next_xyz = getXYZ() - getNormal()*m_previous_height +(dt*m_speed / diff.length())*diff;
{
float dt = stk_config->ticks2Time(ticks);
*next_xyz = getXYZ() - getNormal()*m_previous_height
+ (dt*m_speed / diff.length())*diff;
}
// If ball is close to the target, then explode
if (diff.length() < m_target->getKartLength())
@@ -467,10 +473,11 @@ void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
* \param next_xyz Returns the new position.
* \param The time step size.
*/
void RubberBall::interpolate(Vec3 *next_xyz, float dt)
void RubberBall::interpolate(Vec3 *next_xyz, int ticks)
{
// If we have reached or overshot the next control point, move to the
// the next section of the spline
float dt = stk_config->ticks2Time(ticks);
m_t += m_t_increase * dt;
if(m_t > 1.0f)
{
@@ -673,7 +680,7 @@ void RubberBall::updateDistanceToTarget()
// original target, and start deleting it.
if(m_distance_to_target > 0.9f * Track::getCurrentTrack()->getTrackLength())
{
m_delete_timer = m_st_delete_time;
m_delete_ticks = m_st_delete_ticks;
#ifdef PRINT_BALL_REMOVE_INFO
Log::debug("[RubberBall]", "ball %d lost target (overtook?).",
m_id);

View File

@@ -23,6 +23,7 @@
#include "items/flyable.hpp"
#include "tracks/track_sector.hpp"
#include "utils/cpp2011.hpp"
class AbstractKart;
class SFXBase;
@@ -79,7 +80,7 @@ private:
/** If the ball overtakes its target or starts to aim at the kart which
* originally shot the rubber ball, after this amount of time the
* ball will be deleted. */
static float m_st_delete_time;
static int m_st_delete_ticks;
/** Timer before another rubber ball can be picked up. This is to ensure
* that there are not too many rubber balls on the track in races with many
@@ -166,7 +167,7 @@ private:
* originally shot the rubber ball, after a certain amount of time the
* ball will be deleted. This timer tracks this time. If it is < 0
* it indicates that the ball is targeting another kart atm. */
float m_delete_timer;
int m_delete_ticks;
/** The current maximum height of the ball. This value will be
* reduced if the ball gets closer to the target. */
@@ -192,8 +193,8 @@ private:
float *f=NULL);
void getNextControlPoint();
float updateHeight();
void interpolate(Vec3 *next_xyz, float dt);
void moveTowardsTarget(Vec3 *next_xyz, float dt);
void interpolate(Vec3 *next_xyz, int ticks);
void moveTowardsTarget(Vec3 *next_xyz, int ticks);
void initializeControlPoints(const Vec3 &xyz);
float getTunnelHeight(const Vec3 &next_xyz,
const float vertical_offset) const;
@@ -202,7 +203,7 @@ public:
RubberBall (AbstractKart* kart);
virtual ~RubberBall();
static void init(const XMLNode &node, scene::IMesh *rubberball);
virtual bool updateAndDelete(float dt);
virtual bool updateAndDelete(int ticks) OVERRIDE;
virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
virtual void setAnimation(AbstractKartAnimation *animation);
// ------------------------------------------------------------------------

View File

@@ -146,7 +146,7 @@ void RubberBand::updatePosition()
* so, an explosion is triggered.
* \param dt: Time step size.
*/
void RubberBand::update(float dt)
void RubberBand::update(int ticks)
{
const KartProperties *kp = m_owner->getKartProperties();
@@ -155,7 +155,7 @@ void RubberBand::update(float dt)
// Rubber band snaps
m_plunger->hit(NULL);
// This causes the plunger to be removed at the next update
m_plunger->setKeepAlive(0.0f);
m_plunger->setKeepAlive(0);
return;
}
@@ -171,7 +171,7 @@ void RubberBand::update(float dt)
// Rubber band snaps
m_plunger->hit(NULL);
// This causes the plunger to be removed at the next update
m_plunger->setKeepAlive(0.0f);
m_plunger->setKeepAlive(0);
}
// Apply forces (if applicable)
@@ -187,7 +187,7 @@ void RubberBand::update(float dt)
// Rubber band snaps
m_plunger->hit(NULL);
// This causes the plunger to be removed at the next update
m_plunger->setKeepAlive(0.0f);
m_plunger->setKeepAlive(0);
return;
}
@@ -196,8 +196,8 @@ void RubberBand::update(float dt)
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
kp->getPlungerBandSpeedIncrease(),
/*engine_force*/ 0.0f,
/*duration*/0.1f,
kp->getPlungerBandFadeOutTime());
/*duration*/stk_config->time2Ticks(0.1f),
kp->getPlungerBandFadeOutTicks());
if(m_attached_state==RB_TO_KART)
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
}
@@ -260,7 +260,7 @@ void RubberBand::hit(AbstractKart *kart_hit, const Vec3 *track_xyz)
if(kart_hit->isShielded())
{
kart_hit->decreaseShieldTime();
m_plunger->setKeepAlive(0.0f);
m_plunger->setKeepAlive(0);
return;
}

View File

@@ -66,7 +66,7 @@ private:
public:
RubberBand(Plunger *plunger, AbstractKart *kart);
~RubberBand();
void update(float dt);
void update(int ticks);
void hit(AbstractKart *kart_hit, const Vec3 *track_xyz=NULL);
}; // RubberBand
#endif

View File

@@ -114,8 +114,9 @@ Swatter::~Swatter()
* \param dt Time step size.
* \return True if the attachment should be discarded.
*/
bool Swatter::updateAndTestFinished(float dt)
bool Swatter::updateAndTestFinished(int ticks)
{
float dt = stk_config->ticks2Time(ticks);
if (!m_discard_now)
{
if (m_removing_bomb)

View File

@@ -21,6 +21,7 @@
#include "config/stk_config.hpp"
#include "items/attachment_plugin.hpp"
#include "utils/cpp2011.hpp"
#include "utils/no_copy.hpp"
#include "utils/random_generator.hpp"
@@ -79,7 +80,7 @@ public:
Swatter(AbstractKart *kart, bool was_bomb,
scene::ISceneNode* bomb_scene_node);
virtual ~Swatter();
bool updateAndTestFinished(float dt);
bool updateAndTestFinished(int ticks) OVERRIDE;
// ------------------------------------------------------------------------
/** Returns if the swatter is currently aiming, i.e. can be used to

View File

@@ -1496,7 +1496,7 @@ float AbstractCharacteristic::getSlipstreamWidth() const
} // getSlipstreamWidth
// ----------------------------------------------------------------------------
float AbstractCharacteristic::getSlipstreamCollectTime() const
int AbstractCharacteristic::getSlipstreamCollectTicks() const
{
float result;
bool is_set = false;
@@ -1504,8 +1504,8 @@ float AbstractCharacteristic::getSlipstreamCollectTime() const
if (!is_set)
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
getName(SLIPSTREAM_COLLECT_TIME).c_str());
return result;
} // getSlipstreamCollectTime
return stk_config->time2Ticks(result);
} // getSlipstreamCollectTicks
// ----------------------------------------------------------------------------
float AbstractCharacteristic::getSlipstreamUseTime() const

View File

@@ -362,7 +362,7 @@ public:
float getSlipstreamDuration() const;
float getSlipstreamLength() const;
float getSlipstreamWidth() const;
float getSlipstreamCollectTime() const;
int getSlipstreamCollectTicks() const;
float getSlipstreamUseTime() const;
float getSlipstreamAddPower() const;
float getSlipstreamMinSpeed() const;

View File

@@ -253,7 +253,7 @@ public:
virtual float getFinishTime() const = 0;
// ------------------------------------------------------------------------
/** Returns true if the kart has a plunger attached to its face. */
virtual float getBlockedByPlungerTime() const = 0;
virtual int getBlockedByPlungerTicks() const = 0;
// ------------------------------------------------------------------------
/** Sets that the view is blocked by a plunger. The duration depends on
* the difficulty, see KartPorperties getPlungerInFaceTime. */
@@ -285,7 +285,7 @@ public:
* category. Not pure abstract, since there is no need to implement this
* e.g. in Ghost.
* \param category Which category to report on. */
virtual float getSpeedIncreaseTimeLeft(unsigned int category) const = 0;
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const = 0;
// ------------------------------------------------------------------------
/** Sets an increased maximum speed for a category.
* \param category The category for which to set the higher maximum speed.
@@ -295,15 +295,15 @@ public:
* \param fade_out_time How long the maximum speed will fade out linearly.
*/
virtual void increaseMaxSpeed(unsigned int category, float add_speed,
float engine_force, float duration,
float fade_out_time) = 0;
float engine_force, int duration,
int fade_out_time) = 0;
// ------------------------------------------------------------------------
/** Defines a slowdown, which is in fraction of top speed.
* \param category The category for which the speed is increased.
* \param max_speed_fraction Fraction of top speed to allow only.
* \param fade_in_time How long till maximum speed is capped. */
virtual void setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time) = 0;
int fade_in_time) = 0;
// ------------------------------------------------------------------------
/** Returns the remaining collected energy. */
virtual float getEnergy() const = 0;
@@ -364,7 +364,7 @@ public:
/** Return whether nitro is being used despite the nitro button not being
* pressed due to minimal use time requirements
*/
virtual float isOnMinNitroTime() const = 0;
virtual bool isOnMinNitroTime() const = 0;
// ------------------------------------------------------------------------
/** Returns the current material the kart is on. */
virtual const Material *getMaterial() const = 0;
@@ -412,7 +412,7 @@ public:
/** Returns if the kart is invulnerable. */
virtual bool isInvulnerable() const = 0;
// ------------------------------------------------------------------------
virtual void setInvulnerableTime(float t) = 0;
virtual void setInvulnerableTicks(int ticks) = 0;
// ------------------------------------------------------------------------
/** Returns if the kart is protected by a shield. */
virtual bool isShielded() const = 0;
@@ -459,8 +459,8 @@ public:
virtual void setOnScreenText(const wchar_t *text) = 0;
// -------------------------------------------------------------------------
/** Counter which is used for displaying wrong way message after a delay */
virtual float getWrongwayCounter() = 0;
virtual void setWrongwayCounter(float counter) = 0;
virtual int getWrongwayCounter() = 0;
virtual void setWrongwayCounter(int counter) = 0;
// ------------------------------------------------------------------------
/** Returns whether this kart wins or loses. */
virtual bool getRaceResult() const = 0;

View File

@@ -53,7 +53,7 @@ void AIBaseController::reset()
//-----------------------------------------------------------------------------
void AIBaseController::update(float dt)
void AIBaseController::update(int ticks)
{
m_stuck = false;
}
@@ -193,7 +193,7 @@ void AIBaseController::setSteering(float angle, float dt)
if (steer_fraction > 1.0f) steer_fraction = 1.0f;
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
if(m_kart->getBlockedByPlungerTime()>0)
if(m_kart->getBlockedByPlungerTicks()>0)
{
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;

View File

@@ -75,7 +75,7 @@ protected:
// ------------------------------------------------------------------------
void determineTurnRadius(const Vec3 &end, Vec3 *center,
float *radius) const;
virtual void update (float delta);
virtual void update(int ticks);
virtual void setSteering (float angle, float dt);
// ------------------------------------------------------------------------
/** Return true if AI can skid now. */

View File

@@ -195,11 +195,11 @@ void AIBaseLapController::computePath()
/** Updates the ai base controller each time step. Note that any calls to
* isStuck() must be done before update is called, since update will call
* AIBaseController::update() which will reset the isStuck flag!
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void AIBaseLapController::update(float dt)
void AIBaseLapController::update(int ticks)
{
AIBaseController::update(dt);
AIBaseController::update(ticks);
if(DriveGraph::get())
{
// Update the current node:
@@ -252,7 +252,7 @@ float AIBaseLapController::steerToAngle(const unsigned int sector,
//Desired angle minus current angle equals how many angles to turn
float steer_angle = angle - m_kart->getHeading();
if(m_kart->getBlockedByPlungerTime()>0)
if(m_kart->getBlockedByPlungerTicks()>0)
steer_angle += add_angle*0.2f;
else
steer_angle += add_angle;

View File

@@ -53,9 +53,9 @@ protected:
* graph nodes. */
std::vector<std::vector<int> > m_all_look_aheads;
virtual void update (float delta) ;
virtual void update(int ticks);
virtual unsigned int getNextSector(unsigned int index);
virtual void newLap (int lap);
virtual void newLap(int lap);
//virtual void setControllerName(const std::string &name);
float steerToAngle (const unsigned int sector, const float angle);

View File

@@ -59,8 +59,8 @@ void ArenaAI::reset()
m_reverse_point = Vec3(0, 0, 0);
m_time_since_last_shot = 0.0f;
m_time_since_driving = 0.0f;
m_time_since_off_road = 0.0f;
m_time_since_reversing = 0.0f;
m_ticks_since_off_road = 0;
m_ticks_since_reversing = 0;
m_time_since_uturn = 0.0f;
m_turn_radius = 0.0f;
m_steering_angle = 0.0f;
@@ -74,9 +74,9 @@ void ArenaAI::reset()
/** This is the main entry point for the AI.
* It is called once per frame for each AI and determines the behaviour of
* the AI, e.g. steering, accelerating/braking, firing.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void ArenaAI::update(float dt)
void ArenaAI::update(int ticks)
{
// This is used to enable firing an item backwards.
m_controls->setLookBack(false);
@@ -96,30 +96,31 @@ void ArenaAI::update(float dt)
if (!isKartOnRoad() && m_kart->isOnGround())
{
m_time_since_off_road += dt;
m_ticks_since_off_road += ticks;
}
else if (m_time_since_off_road != 0.0f)
else if (m_ticks_since_off_road != 0)
{
m_time_since_off_road = 0.0f;
m_ticks_since_off_road = 0;
}
// If the kart needs to be rescued, do it now (and nothing else)
if (m_time_since_off_road > 5.0f && m_kart->isOnGround())
if (m_ticks_since_off_road > stk_config->time2Ticks(5.0f) &&
m_kart->isOnGround() )
{
m_time_since_off_road = 0.0f;
m_ticks_since_off_road = 0;
new RescueAnimation(m_kart);
AIBaseController::update(dt);
AIBaseController::update(ticks);
return;
}
if (isWaiting())
{
AIBaseController::update(dt);
AIBaseController::update(ticks);
return;
}
float dt = stk_config->ticks2Time(ticks);
checkIfStuck(dt);
if (gettingUnstuck(dt))
if (gettingUnstuck(ticks))
return;
findTarget();
@@ -156,7 +157,7 @@ void ArenaAI::update(float dt)
setSteering(m_steering_angle, dt);
}
AIBaseController::update(dt);
AIBaseController::update(ticks);
} // update
@@ -385,22 +386,23 @@ void ArenaAI::doUTurn(const float dt)
* \param dt Time step size.
* \return True if getting stuck is needed to be done.
*/
bool ArenaAI::gettingUnstuck(const float dt)
bool ArenaAI::gettingUnstuck(int ticks)
{
if (!m_is_stuck || m_is_uturn) return false;
resetAfterStop();
float dt = stk_config->ticks2Time(ticks);
setSteering(0.0f, dt);
m_controls->setBrake(true);
m_time_since_reversing += dt;
m_ticks_since_reversing += ticks;
if (m_time_since_reversing >= 1.0f)
if (m_ticks_since_reversing >= stk_config->time2Ticks(1.0f))
{
m_is_stuck = false;
m_time_since_reversing = 0.0f;
m_ticks_since_reversing = 0;
}
AIBaseController::update(dt);
AIBaseController::update(ticks);
return true;
} // gettingUnstuck

View File

@@ -89,7 +89,7 @@ private:
* until facing in front of it. */
Vec3 m_reverse_point;
/** Indicates that the kart is currently stuck, and m_time_since_reversing
/** Indicates that the kart is currently stuck, and m_ticks_since_reversing
* is counting down. */
bool m_is_stuck;
@@ -105,7 +105,7 @@ private:
float m_time_since_last_shot;
/** This is a timer that counts down when the kart is reversing to get unstuck. */
float m_time_since_reversing;
float m_ticks_since_reversing;
/** This is a timer that counts down when the kart is starting to drive. */
float m_time_since_driving;
@@ -114,7 +114,7 @@ private:
float m_time_since_uturn;
/** This is a timer that counts when the kart start going off road. */
float m_time_since_off_road;
int m_ticks_since_off_road;
/** Used to determine braking and nitro usage. */
float m_turn_radius;
@@ -142,7 +142,7 @@ private:
// ------------------------------------------------------------------------
void doUTurn(const float dt);
// ------------------------------------------------------------------------
bool gettingUnstuck(const float dt);
bool gettingUnstuck(int ticks);
// ------------------------------------------------------------------------
bool updateAimingPosition(Vec3* target_point);
// ------------------------------------------------------------------------
@@ -183,11 +183,11 @@ public:
// ------------------------------------------------------------------------
virtual ~ArenaAI() {}
// ------------------------------------------------------------------------
virtual void update (float delta) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
// ------------------------------------------------------------------------
virtual void reset () OVERRIDE;
virtual void reset() OVERRIDE;
// ------------------------------------------------------------------------
virtual void newLap (int lap) OVERRIDE {}
virtual void newLap(int lap) OVERRIDE {}
};

View File

@@ -61,7 +61,7 @@ public:
Controller (AbstractKart *kart);
virtual ~Controller () {};
virtual void reset () = 0;
virtual void update (float dt) = 0;
virtual void update (int ticks) = 0;
virtual void handleZipper (bool play_sound) = 0;
virtual void collectedItem (const Item &item, int add_info=-1,
float previous_energy=0) = 0;

View File

@@ -172,7 +172,7 @@ void EndController::action(PlayerAction action, int value)
} // action
//-----------------------------------------------------------------------------
void EndController::update(float dt)
void EndController::update(int ticks)
{
// This is used to enable firing an item backwards.
m_controls->setLookBack(false);
@@ -180,7 +180,7 @@ void EndController::update(float dt)
m_controls->setBrake(false);
m_controls->setAccel(1.0f);
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
// In case of battle mode: don't do anything
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES ||
@@ -198,6 +198,7 @@ void EndController::update(float dt)
calcSteps();
/*Response handling functions*/
float dt = stk_config->ticks2Time(ticks);
handleSteering(dt);
handleRescue(dt);
} // update

View File

@@ -84,7 +84,7 @@ public:
EndController(AbstractKart *kart,
Controller *prev_controller);
~EndController();
virtual void update (float delta) ;
virtual void update (int ticks) ;
virtual void reset ();
virtual void action (PlayerAction action, int value);
virtual void newLap (int lap);

View File

@@ -35,7 +35,7 @@ void GhostController::reset()
} // reset
//-----------------------------------------------------------------------------
void GhostController::update(float dt)
void GhostController::update(int ticks)
{
m_current_time = World::getWorld()->getTime();
// Find (if necessary) the next index to use

View File

@@ -47,7 +47,7 @@ public:
GhostController(AbstractKart *kart, core::stringw display_name);
virtual ~GhostController() {};
virtual void reset() OVERRIDE;
virtual void update (float dt) OVERRIDE;
virtual void update (int ticks) OVERRIDE;
virtual bool disableSlipstreamBonus() const OVERRIDE { return true; }
virtual void crashed(const Material *m) OVERRIDE {}
virtual void crashed(const AbstractKart *k) OVERRIDE {}

View File

@@ -172,7 +172,7 @@ bool LocalPlayerController::action(PlayerAction action, int value,
//-----------------------------------------------------------------------------
/** Handles steering for a player kart.
*/
void LocalPlayerController::steer(float dt, int steer_val)
void LocalPlayerController::steer(int ticks, int steer_val)
{
if(UserConfigParams::m_gamepad_debug)
{
@@ -182,7 +182,7 @@ void LocalPlayerController::steer(float dt, int steer_val)
m_kart, 1.0f,
video::SColor(255, 255, 0, 255), false);
}
PlayerController::steer(dt, steer_val);
PlayerController::steer(ticks, steer_val);
if(UserConfigParams::m_gamepad_debug)
{
@@ -194,7 +194,7 @@ void LocalPlayerController::steer(float dt, int steer_val)
//-----------------------------------------------------------------------------
/** Updates the player kart, called once each timestep.
*/
void LocalPlayerController::update(float dt)
void LocalPlayerController::update(int ticks)
{
if (UserConfigParams::m_gamepad_debug)
{
@@ -203,7 +203,7 @@ void LocalPlayerController::update(float dt)
Log::debug("LocalPlayerController", "irr_driver", "-------------------------------------");
}
PlayerController::update(dt);
PlayerController::update(ticks);
// look backward when the player requests or
// if automatic reverse camera is active

View File

@@ -54,13 +54,13 @@ private:
SFXBuffer *m_grab_sound;
SFXBuffer *m_full_sound;
virtual void steer(float, int) OVERRIDE;
virtual void steer(int, int) OVERRIDE;
virtual void displayPenaltyWarning() OVERRIDE;
public:
LocalPlayerController(AbstractKart *kart,
const int local_playerID);
~LocalPlayerController();
void update (float) OVERRIDE;
void update (int ticks) OVERRIDE;
bool action (PlayerAction action, int value,
bool dry_run=false) OVERRIDE;
virtual void handleZipper (bool play_sound) OVERRIDE;

View File

@@ -38,7 +38,7 @@
PlayerController::PlayerController(AbstractKart *kart)
: Controller(kart)
{
m_penalty_time = 0.0f;
m_penalty_ticks = 0;
} // PlayerController
//-----------------------------------------------------------------------------
@@ -53,13 +53,13 @@ PlayerController::~PlayerController()
*/
void PlayerController::reset()
{
m_steer_val_l = 0;
m_steer_val_r = 0;
m_steer_val = 0;
m_prev_brake = 0;
m_prev_accel = 0;
m_prev_nitro = false;
m_penalty_time = 0;
m_steer_val_l = 0;
m_steer_val_r = 0;
m_steer_val = 0;
m_prev_brake = 0;
m_prev_accel = 0;
m_prev_nitro = false;
m_penalty_ticks = 0;
} // reset
// ----------------------------------------------------------------------------
@@ -167,7 +167,7 @@ bool PlayerController::action(PlayerAction action, int value, bool dry_run)
break;
case PA_ACCEL:
SET_OR_TEST(m_prev_accel, value);
if (value && !(m_penalty_time > 0.0f))
if (value && !(m_penalty_ticks > 0))
{
SET_OR_TEST_GETTER(Accel, value/32768.0f);
SET_OR_TEST_GETTER(Brake, false);
@@ -249,7 +249,7 @@ void PlayerController::actionFromNetwork(PlayerAction p_action, int value,
//-----------------------------------------------------------------------------
/** Handles steering for a player kart.
*/
void PlayerController::steer(float dt, int steer_val)
void PlayerController::steer(int ticks, int steer_val)
{
// Get the old value, compute the new steering value,
// and set it at the end of this function
@@ -264,6 +264,7 @@ void PlayerController::steer(float dt, int steer_val)
// Amount the steering is changed for digital devices.
// If the steering is 'back to straight', a different steering
// change speed is used.
float dt = stk_config->ticks2Time(ticks);
const float STEER_CHANGE = ( (steer_val<=0 && steer<0) ||
(steer_val>=0 && steer>0) )
? dt/m_kart->getKartProperties()->getTurnTimeResetSteer()
@@ -313,13 +314,13 @@ void PlayerController::skidBonusTriggered()
//-----------------------------------------------------------------------------
/** Updates the player kart, called once each timestep.
*/
void PlayerController::update(float dt)
void PlayerController::update(int ticks)
{
// Don't do steering if it's replay. In position only replay it doesn't
// matter, but if it's physics replay the gradual steering causes
// incorrect results, since the stored values are already adjusted.
if (!history->replayHistory() || !history->dontDoPhysics())
steer(dt, m_steer_val);
steer(ticks, m_steer_val);
if (World::getWorld()->getPhase() == World::GOAL_PHASE)
{
@@ -336,11 +337,11 @@ void PlayerController::update(float dt)
// Only give penalty time in SET_PHASE.
// Penalty time check makes sure it doesn't get rendered on every
// update.
if (m_penalty_time == 0.0 &&
if (m_penalty_ticks == 0 &&
World::getWorld()->getPhase() == WorldStatus::SET_PHASE)
{
displayPenaltyWarning();
m_penalty_time = stk_config->m_penalty_time;
m_penalty_ticks = stk_config->m_penalty_ticks;
} // if penalty_time = 0
m_controls->setBrake(false);
@@ -350,9 +351,9 @@ void PlayerController::update(float dt)
return;
} // if isStartPhase
if (m_penalty_time>0.0)
if (m_penalty_ticks>0)
{
m_penalty_time-=dt;
m_penalty_ticks-=ticks;
return;
}

View File

@@ -32,9 +32,9 @@ protected:
bool m_prev_brake;
bool m_prev_nitro;
float m_penalty_time;
int m_penalty_ticks;
virtual void steer(float, int);
virtual void steer(int ticks, int steer_val);
// ------------------------------------------------------------------------
/** Called when this kart started too early and got a start penalty. */
virtual void displayPenaltyWarning() {}
@@ -43,7 +43,7 @@ protected:
public:
PlayerController(AbstractKart *kart);
virtual ~PlayerController ();
virtual void update (float) OVERRIDE;
virtual void update (int ticks) OVERRIDE;
virtual bool action (PlayerAction action, int value,
bool dry_run = false ) OVERRIDE;
virtual void actionFromNetwork(PlayerAction action, int value,

View File

@@ -161,7 +161,7 @@ void SkiddingAI::reset()
{
m_time_since_last_shot = 0.0f;
m_start_kart_crash_direction = 0;
m_start_delay = -1.0f;
m_start_delay = -1;
m_time_since_stuck = 0.0f;
m_kart_ahead = NULL;
m_distance_ahead = 0.0f;
@@ -218,8 +218,9 @@ unsigned int SkiddingAI::getNextSector(unsigned int index)
* It is called once per frame for each AI and determines the behaviour of
* the AI, e.g. steering, accelerating/braking, firing.
*/
void SkiddingAI::update(float dt)
void SkiddingAI::update(int ticks)
{
float dt = stk_config->ticks2Time(ticks);
// This is used to enable firing an item backwards.
m_controls->setLookBack(false);
m_controls->setNitro(false);
@@ -293,14 +294,14 @@ void SkiddingAI::update(float dt)
if(isStuck() && !m_kart->getKartAnimation())
{
new RescueAnimation(m_kart);
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
return;
}
if( m_world->isStartPhase() )
{
handleRaceStart();
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
return;
}
@@ -309,7 +310,7 @@ void SkiddingAI::update(float dt)
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI,
m_ai_properties->getSpeedCap(m_distance_to_player),
/*fade_in_time*/0.0f);
/*fade_in_time*/0);
//Detect if we are going to crash with the track and/or kart
checkCrashes(m_kart->getXYZ());
determineTrackDirection();
@@ -347,7 +348,7 @@ void SkiddingAI::update(float dt)
if(!commands_set)
{
/*Response handling functions*/
handleAcceleration(dt);
handleAcceleration(ticks);
handleSteering(dt);
handleItems(dt);
handleRescue(dt);
@@ -361,7 +362,7 @@ void SkiddingAI::update(float dt)
if(m_controls->getNitro() &&
m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
m_kart->getSpeed()>1.0f &&
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
!m_avoid_item_close)
{
// Make sure that not all AI karts use the zipper at the same
@@ -376,7 +377,7 @@ void SkiddingAI::update(float dt)
}
/*And obviously general kart stuff*/
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
} // update
//-----------------------------------------------------------------------------
@@ -849,7 +850,7 @@ bool SkiddingAI::handleSelectedItem(Vec3 kart_aim_direction, Vec3 *aim_point)
// If the item is unavailable keep on testing. It is not necessary
// to test if an item has turned bad, this was tested before this
// function is called.
if(m_item_to_collect->getDisableTime()>0)
if(m_item_to_collect->getDisableTicks()>0)
return false;
const Vec3 &xyz = m_item_to_collect->getXYZ();
@@ -1039,7 +1040,7 @@ void SkiddingAI::evaluateItems(const Item *item, Vec3 kart_aim_direction,
const KartProperties *kp = m_kart->getKartProperties();
// Ignore items that are currently disabled
if(item->getDisableTime()>0) return;
if(item->getDisableTicks()>0) return;
// If the item type is not handled here, ignore it
Item::ItemType type = item->getType();
@@ -1373,7 +1374,8 @@ void SkiddingAI::handleItems(const float dt)
// likely that this kart then gets a good iteam), otherwise use it
// after a waiting an appropriate time
if(m_kart->getPosition()>1 &&
m_time_since_last_shot > stk_config->m_item_switch_time+2.0f)
m_time_since_last_shot >
stk_config->ticks2Time(stk_config->m_item_switch_ticks)+2.0f)
m_controls->setFire(true);
break; // POWERUP_SWITCH
@@ -1504,12 +1506,12 @@ void SkiddingAI::computeNearestKarts()
/** Determines if the AI should accelerate or not.
* \param dt Time step size.
*/
void SkiddingAI::handleAcceleration( const float dt)
void SkiddingAI::handleAcceleration(int ticks)
{
//Do not accelerate until we have delayed the start enough
if( m_start_delay > 0.0f )
if( m_start_delay > 0 )
{
m_start_delay -= dt;
m_start_delay -= ticks;
m_controls->setAccel(0.0f);
return;
}
@@ -1520,7 +1522,7 @@ void SkiddingAI::handleAcceleration( const float dt)
return;
}
if(m_kart->getBlockedByPlungerTime()>0)
if(m_kart->getBlockedByPlungerTicks()>0)
{
if(m_kart->getSpeed() < m_kart->getCurrentMaxSpeed() / 2)
m_controls->setAccel(0.05f);
@@ -1536,14 +1538,15 @@ void SkiddingAI::handleAcceleration( const float dt)
//-----------------------------------------------------------------------------
void SkiddingAI::handleRaceStart()
{
if( m_start_delay < 0.0f )
if( m_start_delay < 0 )
{
// Each kart starts at a different, random time, and the time is
// smaller depending on the difficulty.
m_start_delay = m_ai_properties->m_min_start_delay
m_start_delay = stk_config->time2Ticks(
m_ai_properties->m_min_start_delay
+ (float) rand() / RAND_MAX
* (m_ai_properties->m_max_start_delay -
m_ai_properties->m_min_start_delay);
m_ai_properties->m_min_start_delay) );
float false_start_probability =
m_superpower == RaceManager::SUPERPOWER_NOLOK_BOSS
@@ -1552,7 +1555,7 @@ void SkiddingAI::handleRaceStart()
// Now check for a false start. If so, add 1 second penalty time.
if(rand() < RAND_MAX * false_start_probability)
{
m_start_delay+=stk_config->m_penalty_time;
m_start_delay+=stk_config->m_penalty_ticks;
return;
}
}
@@ -1591,7 +1594,7 @@ void SkiddingAI::handleNitroAndZipper()
if(m_kart->getSpeed() > 0.95f*m_kart->getCurrentMaxSpeed())
return;
// Don't use nitro when the AI has a plunger in the face!
if(m_kart->getBlockedByPlungerTime()>0) return;
if(m_kart->getBlockedByPlungerTicks()>0) return;
// Don't use nitro if we are braking
if(m_controls->getBrake()) return;
@@ -1683,7 +1686,7 @@ void SkiddingAI::handleNitroAndZipper()
if(m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
m_kart->getSpeed()>1.0f &&
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
{
DriveNode::DirectionType dir;
unsigned int last;
@@ -2391,7 +2394,7 @@ void SkiddingAI::setSteering(float angle, float dt)
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
// Restrict steering when a plunger is in the face
if(m_kart->getBlockedByPlungerTime()>0)
if(m_kart->getBlockedByPlungerTicks()>0)
{
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;

View File

@@ -51,8 +51,6 @@
#include <line3d.h>
class LinearWorld;
class DriveGraph;
class ShowCurve;
class Track;
namespace irr
@@ -145,8 +143,8 @@ private:
/** Distance to the kard behind. */
float m_distance_behind;
/** The actual start delay used. */
float m_start_delay;
/** The actual start delay used in ticks. */
int m_start_delay;
/** Time an item has been collected and not used. */
float m_time_since_last_shot;
@@ -242,7 +240,7 @@ private:
*specific action (more like, associated with inaction).
*/
void handleRaceStart();
void handleAcceleration(const float dt);
void handleAcceleration(int ticks);
void handleSteering(float dt);
void handleItems(const float dt);
void handleRescue(const float dt);
@@ -277,7 +275,7 @@ protected:
public:
SkiddingAI(AbstractKart *kart);
~SkiddingAI();
virtual void update (float delta) ;
virtual void update (int ticks);
virtual void reset ();
virtual const irr::core::stringw& getNamePostfix() const;
};

View File

@@ -107,7 +107,7 @@ void SoccerAI::reset()
* after goal.
* \param dt Time step size.
*/
void SoccerAI::update(float dt)
void SoccerAI::update(int ticks)
{
#ifdef BALL_AIM_DEBUG
Vec3 red = m_world->getBallAimPosition(SOCCER_TEAM_RED);
@@ -125,11 +125,11 @@ void SoccerAI::update(float dt)
resetAfterStop();
m_controls->setBrake(false);
m_controls->setAccel(0.0f);
AIBaseController::update(dt);
AIBaseController::update(ticks);
return;
}
ArenaAI::update(dt);
ArenaAI::update(ticks);
} // update
//-----------------------------------------------------------------------------

View File

@@ -100,12 +100,9 @@ private:
public:
SoccerAI(AbstractKart *kart);
// ------------------------------------------------------------------------
~SoccerAI();
// ------------------------------------------------------------------------
virtual void update (float delta) OVERRIDE;
// ------------------------------------------------------------------------
virtual void reset () OVERRIDE;
virtual void update (int ticks) OVERRIDE;
virtual void reset() OVERRIDE;
};

View File

@@ -56,8 +56,8 @@ SpareTireAI::SpareTireAI(AbstractKart *kart)
void SpareTireAI::reset()
{
BattleAI::reset();
m_idx = 0;
m_timer = 0.0f;
m_idx = 0;
m_timer = 0;
} // reset
//-----------------------------------------------------------------------------
@@ -65,12 +65,12 @@ void SpareTireAI::reset()
* \ref m_timer reaches zero which it will be decreased here.
* \param dt Time step size.
*/
void SpareTireAI::update(float dt)
void SpareTireAI::update(int ticks)
{
BattleAI::update(dt);
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI, 0.5f, /*fade_in_time*/0.0f);
m_timer -= dt;
if (m_timer < 0.0f)
BattleAI::update(ticks);
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI, 0.5f, /*fade_in_time*/0);
m_timer -= ticks;
if (m_timer < 0)
unspawn();
} // update
@@ -108,10 +108,10 @@ void SpareTireAI::findTarget()
* moving around.
* \param time_to_last Time before calling \ref unspawn.
*/
void SpareTireAI::spawn(float time_to_last)
void SpareTireAI::spawn(int ticks_to_last)
{
findDefaultPath();
m_timer = time_to_last;
m_timer = ticks_to_last;
Physics::getInstance()->addKart(m_kart);
m_kart->startEngineSFX();

View File

@@ -35,7 +35,7 @@ private:
int m_idx;
/** Store the time before calling \ref unspawn. */
float m_timer;
int m_timer;
// ------------------------------------------------------------------------
virtual void findTarget() OVERRIDE;
@@ -47,11 +47,11 @@ public:
// ------------------------------------------------------------------------
virtual void crashed(const AbstractKart *k) OVERRIDE;
// ------------------------------------------------------------------------
virtual void update(float delta) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
// ------------------------------------------------------------------------
virtual void reset() OVERRIDE;
// ------------------------------------------------------------------------
void spawn(float time_to_last);
void spawn(int ticks_to_last);
// ------------------------------------------------------------------------
void unspawn();
// ------------------------------------------------------------------------

View File

@@ -59,8 +59,8 @@
#include <iostream>
// This define is only used to make the TestAI as similar to the
// SkiddingAI. This way the two AIs can be compared without too many
// false positives.
// SkiddingAI as possible. This way the two AIs can be compared
// without too many false and distracing positives.
#define SkiddingAI TestAI
@@ -167,7 +167,7 @@ void SkiddingAI::reset()
{
m_time_since_last_shot = 0.0f;
m_start_kart_crash_direction = 0;
m_start_delay = -1.0f;
m_start_delay = -1;
m_time_since_stuck = 0.0f;
m_kart_ahead = NULL;
m_distance_ahead = 0.0f;
@@ -224,8 +224,9 @@ unsigned int SkiddingAI::getNextSector(unsigned int index)
* It is called once per frame for each AI and determines the behaviour of
* the AI, e.g. steering, accelerating/braking, firing.
*/
void SkiddingAI::update(float dt)
void SkiddingAI::update(int ticks)
{
float dt = stk_config->ticks2Time(ticks);
// This is used to enable firing an item backwards.
m_controls->setLookBack(false);
m_controls->setNitro(false);
@@ -299,14 +300,14 @@ void SkiddingAI::update(float dt)
if(isStuck() && !m_kart->getKartAnimation())
{
new RescueAnimation(m_kart);
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
return;
}
if( m_world->isStartPhase() )
{
handleRaceStart();
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
return;
}
@@ -315,7 +316,7 @@ void SkiddingAI::update(float dt)
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI,
m_ai_properties->getSpeedCap(m_distance_to_player),
/*fade_in_time*/0.0f);
/*fade_in_time*/0);
//Detect if we are going to crash with the track and/or kart
checkCrashes(m_kart->getXYZ());
determineTrackDirection();
@@ -353,7 +354,7 @@ void SkiddingAI::update(float dt)
if(!commands_set)
{
/*Response handling functions*/
handleAcceleration(dt);
handleAcceleration(ticks);
handleSteering(dt);
handleItems(dt);
handleRescue(dt);
@@ -367,7 +368,7 @@ void SkiddingAI::update(float dt)
if(m_controls->getNitro() &&
m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
m_kart->getSpeed()>1.0f &&
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
!m_avoid_item_close)
{
// Make sure that not all AI karts use the zipper at the same
@@ -382,7 +383,7 @@ void SkiddingAI::update(float dt)
}
/*And obviously general kart stuff*/
AIBaseLapController::update(dt);
AIBaseLapController::update(ticks);
} // update
//-----------------------------------------------------------------------------
@@ -855,7 +856,7 @@ bool SkiddingAI::handleSelectedItem(Vec3 kart_aim_direction, Vec3 *aim_point)
// If the item is unavailable keep on testing. It is not necessary
// to test if an item has turned bad, this was tested before this
// function is called.
if(m_item_to_collect->getDisableTime()>0)
if(m_item_to_collect->getDisableTicks()>0)
return false;
const Vec3 &xyz = m_item_to_collect->getXYZ();
@@ -1045,7 +1046,7 @@ void SkiddingAI::evaluateItems(const Item *item, Vec3 kart_aim_direction,
const KartProperties *kp = m_kart->getKartProperties();
// Ignore items that are currently disabled
if(item->getDisableTime()>0) return;
if(item->getDisableTicks()>0) return;
// If the item type is not handled here, ignore it
Item::ItemType type = item->getType();
@@ -1159,7 +1160,7 @@ void SkiddingAI::handleItems(const float dt)
if (m_superpower == RaceManager::SUPERPOWER_NOLOK_BOSS)
{
m_controls->setLookBack(m_kart->getPowerup()->getType() ==
PowerupManager::POWERUP_BOWLING );
PowerupManager::POWERUP_BOWLING );
if( m_time_since_last_shot > 3.0f )
{
@@ -1287,7 +1288,7 @@ void SkiddingAI::handleItems(const float dt)
// Since cakes can be fired all around, just use a sane distance
// with a bit of extra for backwards, as enemy will go towards cake
m_controls->setFire( (fire_backwards && distance < 25.0f) ||
(!fire_backwards && distance < 20.0f) );
(!fire_backwards && distance < 20.0f) );
if(m_controls->getFire())
m_controls->setLookBack(fire_backwards);
break;
@@ -1339,7 +1340,7 @@ void SkiddingAI::handleItems(const float dt)
m_controls->setFire( ( (fire_backwards && distance < 30.0f) ||
(!fire_backwards && distance <10.0f) ) &&
m_time_since_last_shot > 3.0f &&
(straight_behind || straight_ahead) );
(straight_behind || straight_ahead) );
if(m_controls->getFire())
m_controls->setLookBack(fire_backwards);
break;
@@ -1379,7 +1380,8 @@ void SkiddingAI::handleItems(const float dt)
// likely that this kart then gets a good iteam), otherwise use it
// after a waiting an appropriate time
if(m_kart->getPosition()>1 &&
m_time_since_last_shot > stk_config->m_item_switch_time+2.0f)
m_time_since_last_shot
> stk_config->ticks2Time(stk_config->m_item_switch_ticks)+2.0f)
m_controls->setFire(true);
break; // POWERUP_SWITCH
@@ -1396,7 +1398,7 @@ void SkiddingAI::handleItems(const float dt)
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
{
m_controls->setFire(m_world->getTime()<1.0f &&
m_kart->getPosition()>2 );
m_kart->getPosition()>2 );
}
else
{
@@ -1510,12 +1512,12 @@ void SkiddingAI::computeNearestKarts()
/** Determines if the AI should accelerate or not.
* \param dt Time step size.
*/
void SkiddingAI::handleAcceleration( const float dt)
void SkiddingAI::handleAcceleration(int ticks)
{
//Do not accelerate until we have delayed the start enough
if( m_start_delay > 0.0f )
if( m_start_delay > 0 )
{
m_start_delay -= dt;
m_start_delay -= ticks;
m_controls->setAccel(0.0f);
return;
}
@@ -1530,7 +1532,7 @@ void SkiddingAI::handleAcceleration( const float dt)
return;
}
if(m_kart->getBlockedByPlungerTime()>0)
if(m_kart->getBlockedByPlungerTicks()>0)
{
if(m_kart->getSpeed() < m_kart->getCurrentMaxSpeed() / 2)
m_controls->setAccel(0.05f);
@@ -1546,14 +1548,15 @@ void SkiddingAI::handleAcceleration( const float dt)
//-----------------------------------------------------------------------------
void SkiddingAI::handleRaceStart()
{
if( m_start_delay < 0.0f )
if( m_start_delay < 0 )
{
// Each kart starts at a different, random time, and the time is
// smaller depending on the difficulty.
m_start_delay = m_ai_properties->m_min_start_delay
m_start_delay = stk_config->time2Ticks(
m_ai_properties->m_min_start_delay
+ (float) rand() / RAND_MAX
* (m_ai_properties->m_max_start_delay -
m_ai_properties->m_min_start_delay);
m_ai_properties->m_min_start_delay) );
float false_start_probability =
m_superpower == RaceManager::SUPERPOWER_NOLOK_BOSS
@@ -1562,7 +1565,7 @@ void SkiddingAI::handleRaceStart()
// Now check for a false start. If so, add 1 second penalty time.
if(rand() < RAND_MAX * false_start_probability)
{
m_start_delay+=stk_config->m_penalty_time;
m_start_delay+=stk_config->m_penalty_ticks;
return;
}
}
@@ -1640,7 +1643,7 @@ void SkiddingAI::handleNitroAndZipper()
// sandtrack 10 489.963 64.18 0.00 3 1009 0.00 0 0 1 135 0 0 1407 0.00
// Don't use nitro when the AI has a plunger in the face!
if(m_kart->getBlockedByPlungerTime()>0) return;
if(m_kart->getBlockedByPlungerTicks()>0) return;
// Don't use nitro if we are braking
if(m_controls->getBrake()) return;
@@ -1726,13 +1729,13 @@ void SkiddingAI::handleNitroAndZipper()
{
// Only prevent overtaking on highest level
m_controls->setNitro(m_ai_properties->m_nitro_usage
== AIProperties::NITRO_ALL );
== AIProperties::NITRO_ALL);
return;
}
if(m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
m_kart->getSpeed()>1.0f &&
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
{
DriveNode::DirectionType dir;
unsigned int last;
@@ -1742,7 +1745,7 @@ void SkiddingAI::handleNitroAndZipper()
{
float diff = DriveGraph::get()->getDistanceFromStart(last)
- DriveGraph::get()->getDistanceFromStart(m_track_node);
if (diff < 0) diff += Track::getCurrentTrack()->getTrackLength();
if(diff<0) diff += Track::getCurrentTrack()->getTrackLength();
if(diff>m_ai_properties->m_straight_length_for_zipper)
m_controls->setFire(true);
}
@@ -2076,6 +2079,7 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
*last_node = m_next_node_index[m_track_node];
float angle = DriveGraph::get()->getAngleToNext(m_track_node,
m_successor_index[m_track_node]);
Vec3 direction;
Vec3 step_track_coord;
@@ -2431,7 +2435,7 @@ void SkiddingAI::setSteering(float angle, float dt)
#endif
}
m_controls->setSkidControl(m_skid_probability_state == SKID_PROBAB_SKID
? sc : KartControl::SC_NONE );
? sc : KartControl::SC_NONE );
}
// Adjust steer fraction in case to be in [-1,1]
@@ -2439,7 +2443,7 @@ void SkiddingAI::setSteering(float angle, float dt)
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
// Restrict steering when a plunger is in the face
if(m_kart->getBlockedByPlungerTime()>0)
if(m_kart->getBlockedByPlungerTicks()>0)
{
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;
@@ -2498,7 +2502,7 @@ void SkiddingAI::setSteering(float angle, float dt)
else
{
m_controls->setSteer( (old_steer-max_steer_change < steer_fraction)
? steer_fraction : old_steer-max_steer_change );
? steer_fraction : old_steer-max_steer_change );
}

View File

@@ -101,8 +101,8 @@ private:
/** Distance to the kard behind. */
float m_distance_behind;
/** The actual start delay used. */
float m_start_delay;
/** The actual start delay used in ticks. */
int m_start_delay;
/** Time an item has been collected and not used. */
float m_time_since_last_shot;
@@ -198,7 +198,7 @@ private:
*specific action (more like, associated with inaction).
*/
void handleRaceStart();
void handleAcceleration(const float dt);
void handleAcceleration(int ticks);
void handleSteering(float dt);
void handleItems(const float dt);
void handleRescue(const float dt);
@@ -233,7 +233,7 @@ protected:
public:
TestAI(AbstractKart *kart);
~TestAI();
virtual void update (float delta) ;
virtual void update (int ticks);
virtual void reset ();
virtual const irr::core::stringw& getNamePostfix() const;
};

View File

@@ -105,7 +105,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart,
// Set invulnerable time, and graphical effects
float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime();
m_kart->setInvulnerableTime(t);
m_kart->setInvulnerableTicks(stk_config->time2Ticks(t));
m_kart->showStarEffect(t);
m_kart->getAttachment()->clear();

View File

@@ -72,12 +72,12 @@ void GhostKart::addReplayEvent(float time,
/** Updates the current event of the ghost kart using interpolation
* \param dt Time step size.
*/
void GhostKart::update(float dt)
void GhostKart::update(int ticks)
{
GhostController* gc = dynamic_cast<GhostController*>(getController());
if (gc == NULL) return;
gc->update(dt);
gc->update(ticks);
if (gc->isReplayEnd())
{
m_node->setVisible(false);
@@ -113,8 +113,9 @@ void GhostKart::update(float dt)
center_shift.setY(m_graphical_y_offset);
center_shift = getTrans().getBasis() * center_shift;
Moveable::updateGraphics(dt, center_shift, btQuaternion(0, 0, 0, 1));
Moveable::updateGraphics(ticks, center_shift, btQuaternion(0, 0, 0, 1));
Moveable::updatePosition();
float dt = stk_config->ticks2Time(ticks);
getKartModel()->update(dt, dt*(m_all_physic_info[idx].m_speed),
m_all_physic_info[idx].m_steer, m_all_physic_info[idx].m_speed,
/*lean*/0.0f, idx);

View File

@@ -46,7 +46,7 @@ private:
public:
GhostKart(const std::string& ident,
unsigned int world_kart_id, int position);
virtual void update (float dt);
virtual void update(int ticks);
virtual void reset();
// ------------------------------------------------------------------------
/** No physics body for ghost kart, so nothing to adjust. */

View File

@@ -124,10 +124,10 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_finished_race = false;
m_race_result = false;
m_finish_time = 0.0f;
m_bubblegum_time = 0.0f;
m_bubblegum_ticks = 0;
m_bubblegum_torque = 0.0f;
m_invulnerable_time = 0.0f;
m_squash_time = 0.0f;
m_invulnerable_ticks = 0;
m_squash_ticks = 0;
m_shadow = NULL;
m_wheel_box = NULL;
@@ -139,7 +139,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_flying = false;
m_stars_effect = NULL;
m_is_jumping = false;
m_min_nitro_time = 0.0f;
m_min_nitro_ticks = 0;
m_fire_clicked = 0;
m_wrongway_counter = 0;
m_type = RaceManager::KT_AI;
@@ -316,7 +316,7 @@ void Kart::reset()
Physics::getInstance()->addKart(this);
}
m_min_nitro_time = 0.0f;
m_min_nitro_ticks = 0;
// Reset star effect in case that it is currently being shown.
m_stars_effect->reset();
@@ -348,22 +348,21 @@ void Kart::reset()
m_finished_race = false;
m_eliminated = false;
m_finish_time = 0.0f;
m_bubblegum_time = 0.0f;
m_bubblegum_ticks = 0;
m_bubblegum_torque = 0.0f;
m_invulnerable_time = 0.0f;
m_squash_time = 0.0f;
m_invulnerable_ticks = 0;
m_squash_ticks = 0;
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
m_collected_energy = 0;
m_has_started = false;
m_bounce_back_time = 0.0f;
m_brake_time = 0.0f;
m_bounce_back_ticks = 0;
m_brake_ticks = 0;
m_ticks_last_crash = 0;
m_speed = 0.0f;
m_smoothed_speed = 0.0f;
m_current_lean = 0.0f;
m_view_blocked_by_plunger = 0.0f;
m_bubblegum_time = 0.0f;
m_bubblegum_torque = 0.0f;
m_falling_ticks = 0;
m_view_blocked_by_plunger = 0;
m_has_caught_nolok_bubblegum = false;
m_is_jumping = false;
@@ -444,8 +443,8 @@ void Kart::setXYZ(const Vec3& a)
// -----------------------------------------------------------------------------
void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
float engine_force, float duration,
float fade_out_time)
float engine_force, int duration,
int fade_out_time)
{
m_max_speed->increaseMaxSpeed(category, add_speed, engine_force, duration,
fade_out_time);
@@ -453,7 +452,7 @@ void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
// -----------------------------------------------------------------------------
void Kart::setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time)
int fade_in_time)
{
m_max_speed->setSlowdown(category, max_speed_fraction, fade_in_time);
} // setSlowdown
@@ -464,9 +463,9 @@ float Kart::getCurrentMaxSpeed() const
return m_max_speed->getCurrentMaxSpeed();
} // getCurrentMaxSpeed
// -----------------------------------------------------------------------------
float Kart::getSpeedIncreaseTimeLeft(unsigned int category) const
int Kart::getSpeedIncreaseTicksLeft(unsigned int category) const
{
return m_max_speed->getSpeedIncreaseTimeLeft(category);
return m_max_speed->getSpeedIncreaseTicksLeft(category);
} // getSpeedIncreaseTimeLeft
// -----------------------------------------------------------------------------
@@ -544,7 +543,8 @@ void Kart::blockViewWithPlunger()
{
// Avoid that a plunger extends the plunger time
if(m_view_blocked_by_plunger<=0 && !isShielded())
m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime();
m_view_blocked_by_plunger =
stk_config->time2Ticks(m_kart_properties->getPlungerInFaceTime());
if(isShielded())
{
decreaseShieldTime();
@@ -1020,14 +1020,15 @@ void Kart::collectedItem(Item *item, int add_info)
item->getEmitter()->getIdent() == "nolok");
// slow down
m_bubblegum_time = m_kart_properties->getBubblegumDuration();
m_bubblegum_ticks =
stk_config->time2Ticks(m_kart_properties->getBubblegumDuration());
m_bubblegum_torque = ((rand()%2)
? m_kart_properties->getBubblegumTorque()
: -m_kart_properties->getBubblegumTorque());
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE,
m_kart_properties->getBubblegumSpeedFraction() ,
m_kart_properties->getBubblegumFadeInTime(),
m_bubblegum_time);
m_kart_properties->getBubblegumFadeInTicks(),
m_bubblegum_ticks);
getNextEmitter()->play(getXYZ(), m_goo_sound);
// Play appropriate custom character sound
@@ -1206,19 +1207,19 @@ void Kart::eliminate()
* particle effects, camera position, etc.
* \param dt Time step size.
*/
void Kart::update(float dt)
void Kart::update(int ticks)
{
// Reset any instand speed increase in the bullet kart
m_vehicle->setMinSpeed(0);
// update star effect (call will do nothing if stars are not activated)
m_stars_effect->update(dt);
m_stars_effect->update(stk_config->ticks2Time(ticks));
if(m_squash_time>=0)
if(m_squash_ticks>=0)
{
m_squash_time-=dt;
m_squash_ticks-=ticks;
// If squasing time ends, reset the model
if(m_squash_time<=0)
if(m_squash_ticks<=0)
{
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
scene::ISceneNode* node =
@@ -1236,10 +1237,10 @@ void Kart::update(float dt)
}
} // if squashed
if (m_bubblegum_time > 0.0f)
if (m_bubblegum_ticks > 0.0f)
{
m_bubblegum_time -= dt;
if (m_bubblegum_time <= 0.0f)
m_bubblegum_ticks -= ticks;
if (m_bubblegum_ticks <= 0.0f)
{
m_bubblegum_torque = 0.0f;
}
@@ -1251,6 +1252,7 @@ void Kart::update(float dt)
// before updating the graphical position (which is done in
// Moveable::update() ), otherwise 'stuttering' can happen (caused by
// graphical and physical position not being the same).
float dt = stk_config->ticks2Time(ticks);
if (has_animation_before)
{
m_kart_animation->update(dt);
@@ -1258,7 +1260,7 @@ void Kart::update(float dt)
// Update the position and other data taken from the physics (or
// an animation which calls setXYZ(), which also updates the kart
// physical position).
Moveable::update(dt);
Moveable::update(ticks);
Vec3 front(0, 0, getKartLength()*0.5f);
m_xyz_front = getTrans()(front);
@@ -1267,14 +1269,14 @@ void Kart::update(float dt)
updateSpeed();
if(!history->replayHistory() || !history->dontDoPhysics())
m_controller->update(dt);
m_controller->update(ticks);
#ifndef SERVER_ONLY
#undef DEBUG_CAMERA_SHAKE
#ifdef DEBUG_CAMERA_SHAKE
Log::verbose("camera", "%s t %f %f xyz %f %f %f v %f %f %f d3 %f d2 %f",
Log::verbose("camera", "%s t %f %d xyz %f %f %f v %f %f %f d3 %f d2 %f",
getIdent().c_str(),
World::getWorld()->getTime(), dt,
World::getWorld()->getTime(), ticks,
getXYZ().getX(), getXYZ().getY(), getXYZ().getZ(),
getVelocity().getX(), getVelocity().getY(), getVelocity().getZ(),
(Camera::getCamera(0)->getXYZ()-getXYZ()).length(),
@@ -1287,9 +1289,9 @@ void Kart::update(float dt)
#ifdef DEBUG_TO_COMPARE_KART_PHYSICS
// This information is useful when comparing kart physics, e.g. to
// see top speed, acceleration (i.e. time to top speed) etc.
Log::verbose("physics", " %s t %f %f xyz(9-11) %f %f %f v(13-15) %f %f %f steerf(17) %f maxangle(19) %f speed(21) %f steering(23-24) %f %f clock %lf",
Log::verbose("physics", " %s t %f %d xyz(9-11) %f %f %f v(13-15) %f %f %f steerf(17) %f maxangle(19) %f speed(21) %f steering(23-24) %f %f clock %lf",
getIdent().c_str(),
World::getWorld()->getTime(), dt,
World::getWorld()->getTime(), ticks,
getXYZ().getX(), getXYZ().getY(), getXYZ().getZ(),
getVelocity().getX(), getVelocity().getY(), getVelocity().getZ(), //13,14,15
m_skidding->getSteeringFraction(), //19
@@ -1302,17 +1304,17 @@ void Kart::update(float dt)
#endif
// if its view is blocked by plunger, decrease remaining time
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= dt;
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= ticks;
//unblock the view if kart just became shielded
if(isShielded())
m_view_blocked_by_plunger = 0.0f;
m_view_blocked_by_plunger = 0;
// Decrease remaining invulnerability time
if(m_invulnerable_time>0)
if(m_invulnerable_ticks>0)
{
m_invulnerable_time-=dt;
m_invulnerable_ticks -= ticks;
}
m_slipstream->update(dt);
m_slipstream->update(ticks);
// TODO: hiker said this probably will be moved to btKart or so when updating bullet engine.
// Neutralize any yaw change if the kart leaves the ground, so the kart falls more or less
@@ -1343,13 +1345,13 @@ void Kart::update(float dt)
// Used to prevent creating a rescue animation after an explosion animation
// got deleted
m_attachment->update(dt);
m_attachment->update(ticks);
m_kart_gfx->update(dt);
if (m_collision_particles) m_collision_particles->update(dt);
PROFILER_PUSH_CPU_MARKER("Kart::updatePhysics", 0x60, 0x34, 0x7F);
updatePhysics(dt);
updatePhysics(ticks);
PROFILER_POP_CPU_MARKER();
if(!m_controls.getFire()) m_fire_clicked = 0;
@@ -1471,7 +1473,7 @@ void Kart::update(float dt)
}
PROFILER_PUSH_CPU_MARKER("Kart::Update (material)", 0x60, 0x34, 0x7F);
handleMaterialGFX(dt);
handleMaterialGFX(ticks);
const Material* material=m_terrain_info->getMaterial();
if (!material) // kart falling off the track
{
@@ -1523,14 +1525,14 @@ void Kart::update(float dt)
{
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_TERRAIN,
material->getMaxSpeedFraction(),
material->getSlowDownTime() );
material->getSlowDownTicks() );
#ifdef DEBUG
if(UserConfigParams::m_material_debug)
{
Log::info("Kart","%s\tfraction %f\ttime %f.",
material->getTexFname().c_str(),
material->getMaxSpeedFraction(),
material->getSlowDownTime() );
material->getSlowDownTicks() );
}
#endif
}
@@ -1548,12 +1550,16 @@ void Kart::update(float dt)
static video::SColor green(255, 61, 87, 23);
#ifndef SERVER_ONLY
// draw skidmarks if relevant (we force pink skidmarks on when hitting a bubblegum)
// draw skidmarks if relevant (we force pink skidmarks on when hitting
// a bubblegum)
if(m_kart_properties->getSkidEnabled() && m_skidmarks)
{
m_skidmarks->update(dt,
m_bubblegum_time > 0,
(m_bubblegum_time > 0 ? (m_has_caught_nolok_bubblegum ? &green : &pink) : NULL) );
m_bubblegum_ticks > 0,
(m_bubblegum_ticks > 0
? (m_has_caught_nolok_bubblegum ? &green
: &pink)
: NULL ) );
}
#endif
@@ -1561,7 +1567,7 @@ void Kart::update(float dt)
if (emergency)
{
m_view_blocked_by_plunger = 0.0f;
m_view_blocked_by_plunger = 0;
if (m_flying)
{
stopFlying();
@@ -1695,7 +1701,8 @@ void Kart::setSquash(float time, float slowdown)
}
m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f));
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown,
0.1f, time);
stk_config->time2Ticks(0.1f),
stk_config->time2Ticks(time));
if (m_vehicle->getNumWheels() > 0)
{
if (!m_wheel_box)
@@ -1708,7 +1715,7 @@ void Kart::setSquash(float time, float slowdown)
}
m_wheel_box->getRelativeTransformationMatrix().setScale(core::vector3df(1.0f, 2.0f, 1.0f));
}
m_squash_time = time;
m_squash_ticks = stk_config->time2Ticks(time);
} // setSquash
//-----------------------------------------------------------------------------
@@ -1796,7 +1803,7 @@ void Kart::handleMaterialSFX(const Material *material)
* kart is falling, or if the surface the kart is driving on has
* the 'isBelowSurface' property set.
*/
void Kart::handleMaterialGFX(float dt)
void Kart::handleMaterialGFX(int ticks)
{
const Material *material = getMaterial();
@@ -1833,19 +1840,19 @@ void Kart::handleMaterialGFX(float dt)
bool falling = material && material->hasFallingEffect() && !m_flying;
if (falling)
{
m_falling_time -= dt;
if (m_falling_time < 0.0f)
m_falling_time = 0.0f;
m_falling_ticks -= ticks;
if (m_falling_ticks < 0)
m_falling_ticks = 0;
}
else
m_falling_time = 0.35f;
m_falling_ticks = stk_config->time2Ticks(0.35f);
for(unsigned int i=0; i<Camera::getNumCameras(); i++)
{
Camera *camera = Camera::getCamera(i);
if(camera->getKart()!=this) continue;
if (falling && m_falling_time <= 0.0f)
if (falling && m_falling_ticks <= 0)
{
camera->setMode(Camera::CM_FALLING);
}
@@ -1966,7 +1973,9 @@ void Kart::handleZipper(const Material *material, bool play_sound)
m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
max_speed_increase, speed_gain,
engine_force, duration, fade_out_time);
engine_force,
stk_config->time2Ticks(duration),
stk_config->time2Ticks(fade_out_time));
// Play custom character sound (weee!)
playCustomSFX(SFXManager::CUSTOM_ZIPPER);
m_controller->handleZipper(play_sound);
@@ -1974,32 +1983,33 @@ void Kart::handleZipper(const Material *material, bool play_sound)
// -----------------------------------------------------------------------------
/** Updates the current nitro status.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void Kart::updateNitro(float dt)
void Kart::updateNitro(int ticks)
{
if (m_controls.getNitro() && m_min_nitro_time <= 0.0f)
if (m_controls.getNitro() && m_min_nitro_ticks <= 0)
{
m_min_nitro_time = m_kart_properties->getNitroMinConsumptionTime();
m_min_nitro_ticks = m_kart_properties->getNitroMinConsumptionTicks();
}
if (m_min_nitro_time > 0.0f)
if (m_min_nitro_ticks > 0)
{
m_min_nitro_time -= dt;
m_min_nitro_ticks -= ticks;
// when pressing the key, don't allow the min time to go under zero.
// If it went under zero, it would be reset
if (m_controls.getNitro() && m_min_nitro_time <= 0.0f)
m_min_nitro_time = 0.1f;
if (m_controls.getNitro() && m_min_nitro_ticks <= 0)
m_min_nitro_ticks = 1;
}
bool increase_speed = (m_controls.getNitro() && isOnGround());
if (!increase_speed && m_min_nitro_time <= 0.0f)
if (!increase_speed && m_min_nitro_ticks <= 0)
{
if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING)
m_nitro_sound->stop();
return;
}
float dt = stk_config->ticks2Time(ticks);
m_collected_energy -= dt * m_kart_properties->getNitroConsumption();
if (m_collected_energy < 0)
{
@@ -2014,10 +2024,10 @@ void Kart::updateNitro(float dt)
if(m_nitro_sound->getStatus() != SFXBase::SFX_PLAYING)
m_nitro_sound->play();
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO,
m_kart_properties->getNitroMaxSpeedIncrease(),
m_kart_properties->getNitroEngineForce(),
m_kart_properties->getNitroDuration(),
m_kart_properties->getNitroFadeOutTime());
m_kart_properties->getNitroMaxSpeedIncrease(),
m_kart_properties->getNitroEngineForce(),
stk_config->time2Ticks(m_kart_properties->getNitroDuration()),
stk_config->time2Ticks(m_kart_properties->getNitroFadeOutTime()));
}
else
{
@@ -2096,8 +2106,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
float abs_speed = fabsf(getSpeed());
impulse *= ( abs_speed<10 ? 10.0f : sqrt(abs_speed) )
* m_kart_properties->getCollisionTerrainImpulse();
m_bounce_back_time = 0.2f;
m_bounce_back_time = 0.0f;;
m_bounce_back_ticks = 0;
impulse = Vec3(0, 0, 0);
//m_vehicle->setTimedCentralImpulse(0.1f, impulse);
m_vehicle->setTimedCentralImpulse(0.0, impulse);
@@ -2125,7 +2134,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
else
impulse = Vec3(0, 0, -1); // Arbitrary
impulse *= m_kart_properties->getCollisionTerrainImpulse();
m_bounce_back_time = 0.2f;
m_bounce_back_ticks = stk_config->time2Ticks(0.2f);
m_vehicle->setTimedCentralImpulse(0.1f, impulse);
}
@@ -2173,13 +2182,13 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
else if (m->getCollisionReaction() == Material::PUSH_BACK)
{
// This variable is set to 0.2 in case of a kart-terrain collision
if (m_bounce_back_time <= 0.2f)
if (m_bounce_back_ticks <= stk_config->time2Ticks(0.2f))
{
btVector3 push = m_body->getLinearVelocity().normalized();
push[1] = 0.1f;
m_body->applyCentralImpulse( -4000.0f*push );
m_bounce_back_time = 2.0f;
} // if m_bounce_back_time <= 0.2f
m_bounce_back_ticks = stk_config->time2Ticks(2.0f);
} // if m_bounce_back_ticks <= 0.2f
} // if (m->getCollisionReaction() == Material::PUSH_BACK)
} // if(m && m->getCollisionReaction() != Material::NORMAL &&
// !getKartAnimation())
@@ -2200,7 +2209,7 @@ void Kart::playCrashSFX(const Material* m, AbstractKart *k)
// 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).
if(m_bounce_back_time<=0.0f)
if(m_bounce_back_ticks <= 0)
{
if (getVelocity().length()> 0.555f)
{
@@ -2244,7 +2253,7 @@ void Kart::playCrashSFX(const Material* m, AbstractKart *k)
crash_sound_emitter->play(getXYZ(), buffer);
}
} // if lin_vel > 0.555
} // if m_bounce_back_time <= 0
} // if m_bounce_back_ticks <= 0
} // playCrashSFX
// -----------------------------------------------------------------------------
@@ -2327,9 +2336,9 @@ bool Kart::playCustomSFX(unsigned int type)
// ----------------------------------------------------------------------------
/** Updates the physics for this kart: computing the driving force, set
* steering, handles skidding, terrain impact on kart, ...
* \param dt Time step size.
* \param ticks Number if physics time steps - should be 1.
*/
void Kart::updatePhysics(float dt)
void Kart::updatePhysics(int ticks)
{
// Check if accel is pressed for the first time. The actual timing
// is done in getStartupBoost - it returns 0 if the start was actually
@@ -2342,22 +2351,22 @@ void Kart::updatePhysics(float dt)
{
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_ZIPPER, 100*f);
m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
0.9f*f, f,
/*engine_force*/200.0f,
/*duration*/5.0f,
/*fade_out_time*/5.0f);
0.9f*f, f,
/*engine_force*/200.0f,
/*duration*/stk_config->time2Ticks(5.0f),
/*fade_out_time*/stk_config->time2Ticks(5.0f));
}
}
m_bounce_back_time-=dt;
m_bounce_back_ticks-=ticks;
updateEnginePowerAndBrakes(dt);
updateEnginePowerAndBrakes(ticks);
// apply flying physics if relevant
if (m_flying)
updateFlying();
m_skidding->update(dt, isOnGround(), m_controls.getSteer(),
m_skidding->update(ticks, isOnGround(), m_controls.getSteer(),
m_controls.getSkidControl());
m_vehicle->setVisualRotation(m_skidding->getVisualSkidRotation());
if(( m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_LEFT ||
@@ -2383,10 +2392,10 @@ void Kart::updatePhysics(float dt)
float min_speed = m && m->isZipper() ? m->getZipperMinSpeed() : -1.0f;
m_max_speed->setMinSpeed(min_speed);
m_max_speed->update(dt);
m_max_speed->update(ticks);
updateEngineSFX(dt);
updateEngineSFX(stk_config->ticks2Time(ticks));
#ifdef XX
Log::info("Kart","angVel %f %f %f heading %f suspension %f %f %f %f"
,m_body->getAngularVelocity().getX()
@@ -2447,9 +2456,9 @@ void Kart::updateEngineSFX(float dt)
/** Sets the engine power. It considers the engine specs, items that influence
* the available power, and braking/steering.
*/
void Kart::updateEnginePowerAndBrakes(float dt)
void Kart::updateEnginePowerAndBrakes(int ticks)
{
updateNitro(dt);
updateNitro(ticks);
float engine_power = getActualWheelForce();
// apply parachute physics if relevant
@@ -2457,7 +2466,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
engine_power*=0.2f;
// apply bubblegum physics if relevant
if (m_bubblegum_time > 0.0f)
if (m_bubblegum_ticks > 0)
{
engine_power = 0.0f;
m_body->applyTorque(btVector3(0.0, m_bubblegum_torque, 0.0));
@@ -2467,7 +2476,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
{
// For a short time after a collision disable the engine,
// so that the karts can bounce back a bit from the obstacle.
if(m_bounce_back_time>0.0f)
if(m_bounce_back_ticks>0.0f)
engine_power = 0.0f;
// let a player going backwards accelerate quickly (e.g. if a player
// hits a wall, he needs to be able to start again quickly after
@@ -2487,7 +2496,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
if(m_vehicle->getWheelInfo(0).m_brake &&
!World::getWorld()->isStartPhase())
m_vehicle->setAllBrakes(0);
m_brake_time = 0;
m_brake_ticks = 0;
}
else
{ // not accelerating
@@ -2497,10 +2506,10 @@ void Kart::updateEnginePowerAndBrakes(float dt)
if(m_speed > 0.0f)
{ // Still going forward while braking
applyEngineForce(-engine_power*2.5f);
m_brake_time += dt;
m_brake_ticks += ticks;
// Apply the brakes - include the time dependent brake increase
float f = 1 + m_brake_time
* m_kart_properties->getEngineBrakeTimeIncrease();
float f = 1.0f + stk_config->ticks2Time(m_brake_ticks)
* m_kart_properties->getEngineBrakeTimeIncrease();
m_vehicle->setAllBrakes(m_kart_properties->getEngineBrakeFactor() * f);
}
else // m_speed < 0
@@ -2525,7 +2534,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
}
else // !m_brake
{
m_brake_time = 0;
m_brake_ticks = 0;
// lift the foot from throttle, brakes with 10% engine_power
assert(!std::isnan(m_controls.getAccel()));
assert(!std::isnan(engine_power));
@@ -2847,14 +2856,14 @@ SFXBase* Kart::getNextEmitter()
* \param offset_xyz Offset to be added to the position.
* \param rotation Additional rotation.
*/
void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
void Kart::updateGraphics(int ticks, const Vec3& offset_xyz,
const btQuaternion& rotation)
{
// Upate particle effects (creation rate, and emitter size
// depending on speed)
// --------------------------------------------------------
float nitro_frac = 0;
if ( (m_controls.getNitro() || m_min_nitro_time > 0.0f) &&
if ( (m_controls.getNitro() || m_min_nitro_ticks > 0) &&
isOnGround() && m_collected_energy > 0 )
{
// fabs(speed) is important, otherwise the negative number will
@@ -2882,6 +2891,8 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
const float steer_frac = m_skidding->getSteeringFraction();
const float roll_speed = m_kart_properties->getLeanSpeed() * DEGREE_TO_RAD;
float dt = stk_config->ticks2Time(ticks);
if(speed_frac > 0.8f && fabsf(steer_frac)>0.5f)
{
// Use steering ^ 7, which means less effect at lower
@@ -2934,7 +2945,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
center_shift = getTrans().getBasis() * center_shift;
float heading = m_skidding->getVisualSkidRotation();
Moveable::updateGraphics(dt, center_shift,
Moveable::updateGraphics(ticks, center_shift,
btQuaternion(heading, 0, -m_current_lean));
// m_speed*dt is the distance the kart has moved, which determines

View File

@@ -133,24 +133,24 @@ protected:
/** How long the brake key has been pressed - the longer the harder
* the kart will brake. */
float m_brake_time;
int m_brake_ticks;
/** A short time after a collision acceleration is disabled to allow
* the karts to bounce back*/
float m_bounce_back_time;
int m_bounce_back_ticks;
/** Time a kart is invulnerable. */
float m_invulnerable_time;
int m_invulnerable_ticks;
/** How long a kart is being squashed. If this is >0
* the kart is squashed. */
float m_squash_time;
int m_squash_ticks;
/** Current leaning of the kart. */
float m_current_lean;
/** If > 0 then bubble gum effect is on. This is the sliding when hitting a gum on the floor, not the shield. */
float m_bubblegum_time;
int m_bubblegum_ticks;
/** The torque to apply after hitting a bubble gum. */
float m_bubblegum_torque;
@@ -159,7 +159,7 @@ protected:
bool m_fire_clicked;
/** Counter which is used for displaying wrong way message after a delay */
float m_wrongway_counter;
int m_wrongway_counter;
// Bullet physics parameters
@@ -193,11 +193,11 @@ protected:
float m_finish_time;
bool m_finished_race;
float m_falling_time = 0.35f;
int m_falling_ticks;
/** When a kart has its view blocked by the plunger, this variable will be
* > 0 the number it contains is the time left before removing plunger. */
float m_view_blocked_by_plunger;
int m_view_blocked_by_plunger;
/** The current speed (i.e. length of velocity vector) of this kart. */
float m_speed;
/** For camera handling an exponentially smoothened value is used, which
@@ -227,17 +227,17 @@ protected:
RaceManager::KartType m_type;
/** To prevent using nitro in too short bursts */
float m_min_nitro_time;
int m_min_nitro_ticks;
void updatePhysics(float dt);
void updatePhysics(int ticks);
void handleMaterialSFX(const Material *material);
void handleMaterialGFX(float dt);
void handleMaterialGFX(int ticks);
void updateFlying();
void updateSliding();
void updateEnginePowerAndBrakes(float dt);
void updateEnginePowerAndBrakes(int ticks);
void updateEngineSFX(float dt);
void updateSpeed();
void updateNitro(float dt);
void updateNitro(int ticks);
float getActualWheelForce();
void playCrashSFX(const Material* m, AbstractKart *k);
void loadData(RaceManager::KartType type, bool animatedModel);
@@ -250,7 +250,7 @@ public:
virtual ~Kart();
virtual void init(RaceManager::KartType type);
virtual void kartIsInRestNow();
virtual void updateGraphics(float dt, const Vec3& off_xyz,
virtual void updateGraphics(int ticks, const Vec3& off_xyz,
const btQuaternion& off_rotation);
virtual void createPhysics ();
virtual void updateWeight ();
@@ -265,11 +265,11 @@ public:
virtual void startEngineSFX ();
virtual void adjustSpeed (float f);
virtual void increaseMaxSpeed(unsigned int category, float add_speed,
float engine_force, float duration,
float fade_out_time);
float engine_force, int duration,
int fade_out_time);
virtual void setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time);
virtual float getSpeedIncreaseTimeLeft(unsigned int category) const;
int fade_in_time);
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE;
virtual void collectedItem(Item *item, int random_attachment);
virtual float getStartupBoost() const;
@@ -286,7 +286,7 @@ public:
virtual void crashed (AbstractKart *k, bool update_attachments);
virtual void crashed (const Material *m, const Vec3 &normal);
virtual float getHoT () const;
virtual void update (float dt);
virtual void update (int ticks);
virtual void finishedRace (float time, bool from_server=false);
virtual void setPosition (int p);
virtual void beep ();
@@ -335,7 +335,7 @@ public:
virtual bool hasFinishedRace () const { return m_finished_race; }
// ------------------------------------------------------------------------
/** Returns true if the kart has a plunger attached to its face. */
virtual float getBlockedByPlungerTime() const
virtual int getBlockedByPlungerTicks() const
{ return m_view_blocked_by_plunger; }
// ------------------------------------------------------------------------
/** Sets that the view is blocked by a plunger. The duration depends on
@@ -416,10 +416,13 @@ public:
virtual void eliminate();
// ------------------------------------------------------------------------
/** Makes a kart invulnerable for a certain amount of time. */
virtual void setInvulnerableTime(float t) { m_invulnerable_time = t; }
virtual void setInvulnerableTicks(int ticks) OVERRIDE
{
m_invulnerable_ticks = ticks;
} // setInvulnerableTicks
// ------------------------------------------------------------------------
/** Returns if the kart is invulnerable. */
virtual bool isInvulnerable() const { return m_invulnerable_time > 0; }
virtual bool isInvulnerable() const { return m_invulnerable_ticks > 0; }
// ------------------------------------------------------------------------
/** Enables a kart shield protection for a certain amount of time. */
virtual void setShieldTime(float t);
@@ -440,10 +443,10 @@ public:
/** Return whether nitro is being used despite the nitro button not being
* pressed due to minimal use time requirements
*/
virtual float isOnMinNitroTime() const { return m_min_nitro_time > 0.0f; }
virtual bool isOnMinNitroTime() const { return m_min_nitro_ticks > 0; }
// ------------------------------------------------------------------------
/** Returns if the kart is currently being squashed. */
virtual bool isSquashed() const { return m_squash_time >0; }
virtual bool isSquashed() const { return m_squash_ticks >0; }
// ------------------------------------------------------------------------
/** Shows the star effect for a certain time. */
virtual void showStarEffect(float t);
@@ -461,9 +464,9 @@ public:
bool isFlying() const { return m_flying; }
// ------------------------------------------------------------------------
/** Counter which is used for displaying wrong way message after a delay */
float getWrongwayCounter() { return m_wrongway_counter; }
int getWrongwayCounter() { return m_wrongway_counter; }
// ------------------------------------------------------------------------
void setWrongwayCounter(float counter) { m_wrongway_counter = counter; }
void setWrongwayCounter(int counter) { m_wrongway_counter = counter; }
// ------------------------------------------------------------------------
/** Returns whether this kart wins or loses. */
virtual bool getRaceResult() const { return m_race_result; }

View File

@@ -839,9 +839,10 @@ float KartProperties::getBubblegumTorque() const
} // getBubblegumTorque
// ----------------------------------------------------------------------------
float KartProperties::getBubblegumFadeInTime() const
int KartProperties::getBubblegumFadeInTicks() const
{
return m_cached_characteristic->getBubblegumFadeInTime();
return stk_config->time2Ticks(m_cached_characteristic
->getBubblegumFadeInTime());
} // getBubblegumFadeInTime
// ----------------------------------------------------------------------------
@@ -929,9 +930,10 @@ float KartProperties::getPlungerBandSpeedIncrease() const
} // getPlungerBandSpeedIncrease
// ----------------------------------------------------------------------------
float KartProperties::getPlungerBandFadeOutTime() const
int KartProperties::getPlungerBandFadeOutTicks() const
{
return m_cached_characteristic->getPlungerBandFadeOutTime();
return stk_config->time2Ticks(m_cached_characteristic
->getPlungerBandFadeOutTime());
} // getPlungerBandFadeOutTime
// ----------------------------------------------------------------------------
@@ -994,6 +996,15 @@ float KartProperties::getNitroDuration() const
return m_cached_characteristic->getNitroDuration();
} // getNitroDuration
// ------------------------------------------------------------------------
/** Returns minimum time during which nitro is consumed when pressing nitro
* key, to prevent using nitro in very short bursts
*/
int KartProperties::getNitroMinConsumptionTicks() const
{
return stk_config->time2Ticks(m_nitro_min_consumption);
}
// ----------------------------------------------------------------------------
float KartProperties::getNitroEngineForce() const
{
@@ -1037,9 +1048,10 @@ float KartProperties::getNitroMax() const
} // getNitroMax
// ----------------------------------------------------------------------------
float KartProperties::getSlipstreamDuration() const
int KartProperties::getSlipstreamDuration() const
{
return m_cached_characteristic->getSlipstreamDuration();
return stk_config->time2Ticks( m_cached_characteristic
->getSlipstreamDuration() );
} // getSlipstreamDuration
// ----------------------------------------------------------------------------
@@ -1055,9 +1067,9 @@ float KartProperties::getSlipstreamWidth() const
} // getSlipstreamWidth
// ----------------------------------------------------------------------------
float KartProperties::getSlipstreamCollectTime() const
int KartProperties::getSlipstreamCollectTicks() const
{
return m_cached_characteristic->getSlipstreamCollectTime();
return m_cached_characteristic->getSlipstreamCollectTicks();
} // getSlipstreamCollectTime
// ----------------------------------------------------------------------------
@@ -1085,9 +1097,10 @@ float KartProperties::getSlipstreamMaxSpeedIncrease() const
} // getSlipstreamMaxSpeedIncrease
// ----------------------------------------------------------------------------
float KartProperties::getSlipstreamFadeOutTime() const
int KartProperties::getSlipstreamFadeOutTicks() const
{
return m_cached_characteristic->getSlipstreamFadeOutTime();
return stk_config->time2Ticks(m_cached_characteristic
->getSlipstreamFadeOutTime());
} // getSlipstreamFadeOutTime
// ----------------------------------------------------------------------------

View File

@@ -352,11 +352,6 @@ public:
/** Returns the full path where the files for this kart are stored. */
const std::string& getKartDir () const {return m_root; }
// ------------------------------------------------------------------------
/** Returns minimum time during which nitro is consumed when pressing nitro
* key, to prevent using nitro in very short bursts
*/
float getNitroMinConsumptionTime() const { return m_nitro_min_consumption; }
// ------------------------------------------------------------------------
/** Returns the bevel factor (!=0 indicates to use a bevelled box). */
const Vec3 &getBevelFactor() const { return m_bevel_factor; }
@@ -440,7 +435,7 @@ public:
float getBubblegumDuration() const;
float getBubblegumSpeedFraction() const;
float getBubblegumTorque() const;
float getBubblegumFadeInTime() const;
int getBubblegumFadeInTicks() const;
float getBubblegumShieldDuration() const;
float getZipperDuration() const;
@@ -458,7 +453,7 @@ public:
float getPlungerBandForce() const;
float getPlungerBandDuration() const;
float getPlungerBandSpeedIncrease() const;
float getPlungerBandFadeOutTime() const;
int getPlungerBandFadeOutTicks() const;
float getPlungerInFaceTime() const;
std::vector<float> getStartupTime() const;
@@ -480,16 +475,18 @@ public:
float getNitroMaxSpeedIncrease() const;
float getNitroFadeOutTime() const;
float getNitroMax() const;
int getNitroMinConsumptionTicks() const;
// ------------------------------------------------------------------------
float getSlipstreamDuration() const;
int getSlipstreamDuration() const;
float getSlipstreamLength() const;
float getSlipstreamWidth() const;
float getSlipstreamCollectTime() const;
int getSlipstreamCollectTicks() const;
float getSlipstreamUseTime() const;
float getSlipstreamAddPower() const;
float getSlipstreamMinSpeed() const;
float getSlipstreamMaxSpeedIncrease() const;
float getSlipstreamFadeOutTime() const;
int getSlipstreamFadeOutTicks() const;
float getSkidIncrease() const;
float getSkidDecrease() const;

View File

@@ -181,9 +181,9 @@ void KartRewinder::rewindToState(BareNetworkString *buffer)
/** Called once a frame. It will add a new kart control event to the rewind
* manager if any control values have changed.
*/
void KartRewinder::update(float dt)
void KartRewinder::update(int ticks)
{
Kart::update(dt);
Kart::update(ticks);
} // update
// ----------------------------------------------------------------------------

View File

@@ -49,7 +49,7 @@ public:
void reset();
virtual void rewindToState(BareNetworkString *p) OVERRIDE;
virtual void rewindToEvent(BareNetworkString *p) OVERRIDE;
virtual void update(float dt);
virtual void update(int ticks) OVERRIDE;
// -------------------------------------------------------------------------
virtual void undoState(BareNetworkString *p) OVERRIDE

View File

@@ -58,10 +58,11 @@ void KartWithStats::reset()
* statistics for this kart.
* \param dt Time step size.
*/
void KartWithStats::update(float dt)
void KartWithStats::update(int ticks)
{
Kart::update(dt);
Kart::update(ticks);
if(getSpeed()>m_top_speed ) m_top_speed = getSpeed();
float dt = stk_config->ticks2Time(ticks);
if(getControls().getSkidControl()) m_skidding_time += dt;
if(getControls().getBrake() ) m_brake_count ++;
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());

View File

@@ -76,7 +76,7 @@ public:
int position,
const btTransform& init_transform,
PerPlayerDifficulty difficulty);
virtual void update(float dt);
virtual void update(int ticks) OVERRIDE;
virtual void reset();
virtual void collectedItem(Item *item, int add_info);
virtual void setKartAnimation(AbstractKartAnimation *ka);

View File

@@ -18,13 +18,14 @@
#include "karts/max_speed.hpp"
#include <algorithm>
#include <assert.h>
#include "config/stk_config.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "physics/btKart.hpp"
#include <algorithm>
#include <assert.h>
/** This class handles maximum speed for karts. Several factors can influence
* the maximum speed a kart can drive, some will decrease the maximum speed,
* some will increase the maximum speed.
@@ -88,8 +89,8 @@ void MaxSpeed::reset()
* \param fade_out_time How long the maximum speed will fade out linearly.
*/
void MaxSpeed::increaseMaxSpeed(unsigned int category, float add_speed,
float engine_force, float duration,
float fade_out_time)
float engine_force, int duration,
int fade_out_time)
{
// Allow fade_out_time 0 if add_speed is set to 0.
assert(add_speed==0.0f || fade_out_time>0.01f);
@@ -117,8 +118,8 @@ void MaxSpeed::increaseMaxSpeed(unsigned int category, float add_speed,
*/
void MaxSpeed::instantSpeedIncrease(unsigned int category,
float add_max_speed, float speed_boost,
float engine_force, float duration,
float fade_out_time)
float engine_force, int duration,
int fade_out_time)
{
increaseMaxSpeed(category, add_max_speed, engine_force, duration,
fade_out_time);
@@ -144,9 +145,9 @@ void MaxSpeed::instantSpeedIncrease(unsigned int category,
* -m_fade_out_time and 0, the maximum speed will linearly decrease.
* \param dt Time step size.
*/
void MaxSpeed::SpeedIncrease::update(float dt)
void MaxSpeed::SpeedIncrease::update(int ticks)
{
m_duration -= dt;
m_duration -= ticks;
// End of increased max speed reached.
if(m_duration < -m_fade_out_time)
{
@@ -157,15 +158,15 @@ void MaxSpeed::SpeedIncrease::update(float dt)
if(m_duration >0) return;
// Now we are in the fade out period: decrease time linearly
m_current_speedup -= dt*m_max_add_speed/m_fade_out_time;
m_current_speedup -= ticks*m_max_add_speed/m_fade_out_time;
} // SpeedIncrease::update
// ----------------------------------------------------------------------------
void MaxSpeed::SpeedIncrease::saveState(BareNetworkString *buffer) const
{
buffer->addFloat(m_max_add_speed);
buffer->addFloat(m_duration);
buffer->addFloat(m_fade_out_time);
buffer->addUInt32(m_duration);
buffer->addUInt32(m_fade_out_time);
buffer->addFloat(m_current_speedup);
buffer->addFloat(m_engine_force);
} // saveState
@@ -177,8 +178,8 @@ void MaxSpeed::SpeedIncrease::rewindTo(BareNetworkString *buffer,
if(is_active)
{
m_max_add_speed = buffer->getFloat();
m_duration = buffer->getFloat();
m_fade_out_time = buffer->getFloat();
m_duration = buffer->getUInt32();
m_fade_out_time = buffer->getUInt32();
m_current_speedup = buffer->getFloat();
m_engine_force = buffer->getFloat();
}
@@ -198,7 +199,7 @@ void MaxSpeed::SpeedIncrease::rewindTo(BareNetworkString *buffer,
* value is changed to something else).
*/
void MaxSpeed::setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time, float duration)
int fade_in_time, int duration)
{
assert(category>=MS_DECREASE_MIN && category <MS_DECREASE_MAX);
m_speed_decrease[category].m_max_speed_fraction = max_speed_fraction;
@@ -210,12 +211,12 @@ void MaxSpeed::setSlowdown(unsigned int category, float max_speed_fraction,
/** Handles the speed increase for a certain category.
* \param dt Time step size.
*/
void MaxSpeed::SpeedDecrease::update(float dt)
void MaxSpeed::SpeedDecrease::update(int ticks)
{
if(m_duration>-1.0f)
if(m_duration>-1)
{
// It's a timed slowdown
m_duration -= dt;
m_duration -= ticks;
if(m_duration<0)
{
m_duration = 0;
@@ -228,8 +229,9 @@ void MaxSpeed::SpeedDecrease::update(float dt)
float diff = m_current_fraction - m_max_speed_fraction;
if(diff > 0)
{
if (diff * m_fade_in_time > dt)
m_current_fraction -= dt/m_fade_in_time;
float dt = stk_config->ticks2Time(ticks);
if (diff * m_fade_in_time > ticks)
m_current_fraction -= float(dt)/m_fade_in_time;
else
m_current_fraction = m_max_speed_fraction;
}
@@ -245,9 +247,9 @@ void MaxSpeed::SpeedDecrease::update(float dt)
void MaxSpeed::SpeedDecrease::saveState(BareNetworkString *buffer) const
{
buffer->addFloat(m_max_speed_fraction);
buffer->addFloat(m_fade_in_time);
buffer->addUInt32(m_fade_in_time);
buffer->addFloat(m_current_fraction);
buffer->addFloat(m_duration);
buffer->addUInt32(m_duration);
} // saveState
// ----------------------------------------------------------------------------
@@ -259,9 +261,9 @@ void MaxSpeed::SpeedDecrease::rewindTo(BareNetworkString *buffer,
if(is_active)
{
m_max_speed_fraction = buffer->getFloat();
m_fade_in_time = buffer->getFloat();
m_fade_in_time = buffer->getUInt32();
m_current_fraction = buffer->getFloat();
m_duration = buffer->getFloat();
m_duration = buffer->getUInt32();
}
else // make sure it is not active
{
@@ -273,7 +275,7 @@ void MaxSpeed::SpeedDecrease::rewindTo(BareNetworkString *buffer,
/** Returns how much increased speed time is left over in the given category.
* \param category Which category to report on.
*/
float MaxSpeed::getSpeedIncreaseTimeLeft(unsigned int category)
int MaxSpeed::getSpeedIncreaseTicksLeft(unsigned int category)
{
return m_speed_increase[category].getTimeLeft();
} // getSpeedIncreaseTimeLeft
@@ -285,7 +287,7 @@ float MaxSpeed::getSpeedIncreaseTimeLeft(unsigned int category)
* change to any of the speed increase/decrease objects will be done.
* \param dt Time step size (dt=0 only updates the current maximum speed).
*/
void MaxSpeed::update(float dt)
void MaxSpeed::update(int ticks)
{
// First compute the minimum max-speed fraction, which
@@ -295,7 +297,7 @@ void MaxSpeed::update(float dt)
for(unsigned int i=MS_DECREASE_MIN; i<MS_DECREASE_MAX; i++)
{
SpeedDecrease &slowdown = m_speed_decrease[i];
slowdown.update(dt);
slowdown.update(ticks);
slowdown_factor = std::min(slowdown_factor,
slowdown.getSlowdownFraction());
}
@@ -308,7 +310,7 @@ void MaxSpeed::update(float dt)
for(unsigned int i=MS_INCREASE_MIN; i<MS_INCREASE_MAX; i++)
{
SpeedIncrease &speedup = m_speed_increase[i];
speedup.update(dt);
speedup.update(ticks);
m_current_max_speed += speedup.getSpeedIncrease();
m_add_engine_force += speedup.getEngineForce();
}

View File

@@ -71,9 +71,9 @@ private:
* to the duration will be decreased. When the duration is <0, the
* fade out time starts, and duration will go down to
* -m_fade_out_time before this speed increase stops. */
float m_duration;
int m_duration;
/** The fadeout time. */
float m_fade_out_time;
int m_fade_out_time;
/** The current max speed increase value. */
float m_current_speedup;
/** Additional engine force. */
@@ -96,7 +96,7 @@ private:
m_engine_force = 0;
} // reset
// --------------------------------------------------------------------
void update(float dt);
void update(int ticks);
void saveState(BareNetworkString *buffer) const;
void rewindTo(BareNetworkString *buffer, bool is_active);
// --------------------------------------------------------------------
@@ -107,7 +107,7 @@ private:
* Note that this function will return a negative value if
* the fade_out time has started or this speed increase has
* expired. */
float getTimeLeft() const {return m_duration; }
int getTimeLeft() const {return m_duration; }
// --------------------------------------------------------------------
/** Returns the additional engine force for this speed increase. */
float getEngineForce() const
@@ -127,14 +127,14 @@ private:
/** The maximum slowdown to apply. */
float m_max_speed_fraction;
/** How long it should take for the full slowdown to take effect. */
float m_fade_in_time;
int m_fade_in_time;
/** The current slowdown fraction, taking the fade-in time
* into account. */
float m_current_fraction;
/** How long the effect should last. A -1.0f as value indicates
* that this effect stays active till it is changed back. */
float m_duration;
int m_duration;
/** The constructor initialises the data with data that won't
* affect top speed at all. */
@@ -147,12 +147,12 @@ private:
void reset()
{
m_max_speed_fraction = 1.0f;
m_fade_in_time = 0.0f;
m_current_fraction = 1.0f;
m_duration = 0.0f;
m_fade_in_time = 0;
m_duration = 0;
} //reset
// --------------------------------------------------------------------
void update(float dt);
void update(int ticks);
void saveState(BareNetworkString *buffer) const;
void rewindTo(BareNetworkString *buffer, bool is_active);
// --------------------------------------------------------------------
@@ -179,16 +179,16 @@ public:
MaxSpeed(AbstractKart *kart);
void increaseMaxSpeed(unsigned int category, float add_speed,
float engine_force, float duration,
float fade_out_time);
float engine_force, int duration,
int fade_out_time);
void instantSpeedIncrease(unsigned int category,
float add_speed, float speed_boost,
float engine_force, float duration,
float fade_out_time/*=1.0f*/);
float engine_force, int duration,
int fade_out_time);
void setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time, float duration=-1.0f);
float getSpeedIncreaseTimeLeft(unsigned int category);
void update(float dt);
int fade_in_time, int duration=-1);
int getSpeedIncreaseTicksLeft(unsigned int category);
void update(int ticks);
void reset();
void saveState(BareNetworkString *buffer) const;
void rewindTo(BareNetworkString *buffer);

View File

@@ -88,7 +88,7 @@ void Moveable::addError(const Vec3& pos_error,
* \param offset_xyz Offset to be added to the position.
* \param rotation Additional rotation.
*/
void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
void Moveable::updateGraphics(int ticks, const Vec3& offset_xyz,
const btQuaternion& rotation)
{
// If this is a client, don't smooth error during rewinds
@@ -165,16 +165,16 @@ void Moveable::stopFlying()
//-----------------------------------------------------------------------------
/** Updates the current position and rotation from the corresponding physics
* body, and then calls updateGraphics to position the model correctly.
* \param float dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void Moveable::update(float dt)
void Moveable::update(int ticks)
{
if(m_body->getInvMass()!=0)
m_motion_state->getWorldTransform(m_transform);
m_velocityLC = getVelocity()*m_transform.getBasis();
updatePosition();
updateGraphics(dt, Vec3(0,0,0), btQuaternion(0, 0, 0, 1));
updateGraphics(ticks, Vec3(0,0,0), btQuaternion(0, 0, 0, 1));
} // update
//-----------------------------------------------------------------------------

View File

@@ -116,10 +116,10 @@ public:
m_motion_state->setWorldTransform(m_transform);
} // setRotation(btQuaternion)
// ------------------------------------------------------------------------
virtual void updateGraphics(float dt, const Vec3& off_xyz,
virtual void updateGraphics(int ticks, const Vec3& off_xyz,
const btQuaternion& off_rotation);
virtual void reset();
virtual void update(float dt) ;
virtual void update(int ticks) ;
btRigidBody *getBody() const {return m_body; }
void createBody(float mass, btTransform& trans,
btCollisionShape *shape,

View File

@@ -225,15 +225,17 @@ float Skidding::getSteeringWhenSkidding(float steering) const
// ----------------------------------------------------------------------------
/** Updates skidding status.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
* \param is_on_ground True if the kart is on ground.
* \param steering Raw steering of the kart [-1,1], i.e. not adjusted by
* the kart's max steering angle.
* \param skidding True if the skid button is pressed.
*/
void Skidding::update(float dt, bool is_on_ground,
void Skidding::update(int ticks, bool is_on_ground,
float steering, KartControl::SkidControl skidding)
{
float dt = stk_config->ticks2Time(ticks);
const KartProperties *kp = m_kart->getKartProperties();
// If a kart animation is shown, stop all skidding bonuses.
@@ -440,9 +442,10 @@ void Skidding::update(float dt, bool is_on_ground,
->setCreationRateRelative(KartGFX::KGFX_SKIDR, 1.0f);
m_kart->m_max_speed->
instantSpeedIncrease(MaxSpeed::MS_INCREASE_SKIDDING,
bonus_speed, bonus_speed,
bonus_force, bonus_time,
/*fade-out-time*/ 1.0f);
bonus_speed, bonus_speed,
bonus_force,
stk_config->time2Ticks(bonus_time),
/*fade-out-time*/ stk_config->time2Ticks(1.0f));
if (m_kart->getController()->canGetAchievements())
{

View File

@@ -104,7 +104,7 @@ public:
Skidding(Kart *kart);
~Skidding();
void reset();
void update(float dt, bool is_on_ground, float steer,
void update(int dt, bool is_on_ground, float steer,
KartControl::SkidControl skidding);
void saveState(BareNetworkString *buffer);
void rewindTo(BareNetworkString *buffer);

View File

@@ -169,25 +169,25 @@ float MainLoop::getLimitedDt()
// to findout which events to replay
if (World::getWorld() && history->replayHistory() )
{
dt = history->updateReplayAndGetDT(World::getWorld()->getTime(), dt);
history->updateReplay(World::getWorld()->getTime(), dt);
}
return dt;
} // getLimitedDt
//-----------------------------------------------------------------------------
/** Updates all race related objects.
* \param dt Time step size.
* \param ticks Number of ticks (physics steps) to simulate - should be 1.
*/
void MainLoop::updateRace(float dt)
void MainLoop::updateRace(int ticks)
{
if (!World::getWorld()) return; // No race on atm - i.e. we are in menu
// The race event manager will update world in case of an online race
if ( RaceEventManager::getInstance() &&
RaceEventManager::getInstance()->isRunning() )
RaceEventManager::getInstance()->update(dt);
RaceEventManager::getInstance()->update(ticks);
else
World::getWorld()->updateWorld(dt);
World::getWorld()->updateWorld(ticks);
} // updateRace
//-----------------------------------------------------------------------------
@@ -356,7 +356,7 @@ void MainLoop::run()
m_is_last_substep = (i == num_steps - 1);
PROFILER_PUSH_CPU_MARKER("Update race", 0, 255, 255);
if (World::getWorld()) updateRace(dt);
if (World::getWorld()) updateRace(1);
PROFILER_POP_CPU_MARKER();
// We need to check again because update_race may have requested
@@ -368,11 +368,11 @@ void MainLoop::run()
0x7F, 0x00, 0x7F);
if (auto pm = ProtocolManager::lock())
{
pm->update(dt);
pm->update(1);
}
PROFILER_POP_CPU_MARKER();
if (World::getWorld()) World::getWorld()->updateTime(dt);
if (World::getWorld()) World::getWorld()->updateTime(1);
} // for i < num_steps
m_is_last_substep = false;

View File

@@ -41,7 +41,7 @@ private:
Uint32 m_curr_time;
Uint32 m_prev_time;
float getLimitedDt();
void updateRace(float dt);
void updateRace(int ticks);
public:
MainLoop();
~MainLoop();

View File

@@ -181,9 +181,9 @@ const std::string& CutsceneWorld::getIdent() const
//-----------------------------------------------------------------------------
/** Update the world and the track.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void CutsceneWorld::update(float dt)
void CutsceneWorld::update(int ticks)
{
/*
{
@@ -234,7 +234,7 @@ void CutsceneWorld::update(float dt)
double prev_time = m_time;
double now = StkTime::getRealTime();
m_time = now - m_time_at_second_reset;
dt = (float)(m_time - prev_time);
ticks = stk_config->time2Ticks(float(m_time - prev_time));
}
float fade = 0.0f;
@@ -288,8 +288,8 @@ void CutsceneWorld::update(float dt)
}
World::update((float)dt);
World::updateTrack((float)dt);
World::update(ticks);
World::updateTrack(ticks);
PtrVector<TrackObject>& objects = Track::getCurrentTrack()
->getTrackObjectManager()->getObjects();

View File

@@ -70,7 +70,7 @@ public:
virtual const std::string& getIdent() const OVERRIDE;
virtual void update(float dt) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
virtual void createRaceGUI() OVERRIDE;

View File

@@ -53,20 +53,25 @@ private:
public:
DemoWorld();
virtual ~DemoWorld();
/** Returns identifier for this world. */
virtual std::string getInternalCode() const OVERRIDE { return "DEMO"; }
virtual void update(float dt) OVERRIDE {ProfileWorld::update(dt);};
virtual bool isRaceOver() OVERRIDE;
virtual void enterRaceOverState() OVERRIDE;
// ------------------------------------------------------------------------
static bool updateIdleTimeAndStartDemo(float dt);
/** Returns identifier for this world. */
virtual std::string getInternalCode() const OVERRIDE { return "DEMO"; }
// ------------------------------------------------------------------------
virtual void update(int ticks) OVERRIDE { ProfileWorld::update(ticks); }
// ------------------------------------------------------------------------
static bool updateIdleTimeAndStartDemo(float dt);
// ------------------------------------------------------------------------
/** Sets the number of laps to use in demo mode. m_num_laps is from
* ProfileWorld. */
static void setNumLaps(unsigned int num_laps) { m_num_laps = num_laps; }
// ------------------------------------------------------------------------
/** Sets the number of karts to use in demo mode. */
static void setNumKarts(unsigned int num_karts) { m_default_num_karts = num_karts;}
static void setNumKarts(unsigned int num_karts)
{
m_default_num_karts = num_karts;
} // setNumKarts
// ------------------------------------------------------------------------
static void setTracks(const std::vector<std::string> &tracks);
// ------------------------------------------------------------------------

View File

@@ -156,12 +156,12 @@ void EasterEggHunt::collectedEasterEgg(const AbstractKart *kart)
//-----------------------------------------------------------------------------
/** Update the world and the track.
* \param dt Time step size.
* \param ticks Physics time step size - should be 1.
*/
void EasterEggHunt::update(float dt)
void EasterEggHunt::update(int ticks)
{
LinearWorld::update(dt);
LinearWorld::updateTrack(dt);
LinearWorld::update(ticks);
LinearWorld::updateTrack(ticks);
} // update
//-----------------------------------------------------------------------------
@@ -209,7 +209,7 @@ void EasterEggHunt::getKartsDisplayInfo(
* direction messages in the easter egg mode since there is no direction there.
* \param i Kart id.
*/
void EasterEggHunt::checkForWrongDirection(unsigned int i, float dt)
void EasterEggHunt::checkForWrongDirection(unsigned int i, int ticks)
{
} // checkForWrongDirection

View File

@@ -57,7 +57,7 @@ public:
virtual const std::string& getIdent() const OVERRIDE;
virtual void terminateRace() OVERRIDE;
virtual void update(float dt) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
@@ -65,7 +65,7 @@ public:
void collectedEasterEgg(const AbstractKart *kart);
void readData(const std::string &filename);
virtual void checkForWrongDirection(unsigned int i, float dt) OVERRIDE;
virtual void checkForWrongDirection(unsigned int i, int ticks) OVERRIDE;
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
}; // EasterEggHunt

View File

@@ -150,13 +150,13 @@ void LinearWorld::reset()
//-----------------------------------------------------------------------------
/** General update function called once per frame. This updates the kart
* sectors, which are then used to determine the kart positions.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void LinearWorld::update(float dt)
void LinearWorld::update(int ticks)
{
// run generic parent stuff that applies to all modes. It
// especially updates the kart positions.
WorldWithRank::update(dt);
WorldWithRank::update(ticks);
if (m_last_lap_sfx_playing &&
m_last_lap_sfx->getStatus() != SFXBase::SFX_PLAYING)
@@ -197,7 +197,7 @@ void LinearWorld::update(float dt)
// updated their position and laps etc, otherwise inconsistencies
// (like two karts at same position) can occur.
// ---------------------------------------------------------------
WorldWithRank::updateTrack(dt);
WorldWithRank::updateTrack(ticks);
updateRacePosition();
for (unsigned int i=0; i<kart_amount; i++)
@@ -213,7 +213,7 @@ void LinearWorld::update(float dt)
m_kart_info[i].m_estimated_finish =
estimateFinishTimeForKart(m_karts[i]);
}
checkForWrongDirection(i, dt);
checkForWrongDirection(i, ticks);
}
#ifdef DEBUG
@@ -842,12 +842,12 @@ void LinearWorld::updateRacePosition()
* player karts to display a message to the player.
* \param i Kart id.
*/
void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
void LinearWorld::checkForWrongDirection(unsigned int i, int ticks)
{
if (!m_karts[i]->getController()->isLocalPlayerController())
return;
float wrongway_counter = m_karts[i]->getWrongwayCounter();
int wrongway_counter = m_karts[i]->getWrongwayCounter();
const AbstractKart *kart=m_karts[i];
// If the kart can go in more than one directions from the current track
@@ -875,14 +875,14 @@ void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
kart->getVelocityLC().getY() > 0.0f &&
!kart->hasFinishedRace())
{
wrongway_counter += dt;
wrongway_counter += ticks;
if (wrongway_counter > 2.0f)
wrongway_counter = 2.0f;
if (wrongway_counter > stk_config->time2Ticks(2.0f))
wrongway_counter = stk_config->time2Ticks(2.0f);
}
else
{
wrongway_counter -= dt;
wrongway_counter -= ticks;
if (wrongway_counter < 0)
wrongway_counter = 0;
@@ -891,7 +891,7 @@ void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
if (kart->getKartAnimation())
wrongway_counter = 0;
if (wrongway_counter > 1.0f)
if (wrongway_counter > stk_config->time2Ticks(1.0f))
{
m_race_gui->addMessage(_("WRONG WAY!"), kart,
/* time */ -1.0f,

View File

@@ -101,7 +101,7 @@ protected:
*/
AlignedArray<KartInfo> m_kart_info;
virtual void checkForWrongDirection(unsigned int i, float dt);
virtual void checkForWrongDirection(unsigned int i, int ticks);
void updateRacePosition();
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
@@ -113,7 +113,7 @@ public:
virtual void init() OVERRIDE;
virtual ~LinearWorld();
virtual void update(float delta) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
float getDistanceDownTrackForKart(const int kart_id) const;
float getDistanceToCenterForKart(const int kart_id) const;
float getEstimatedFinishTime(const int kart_id) const;

View File

@@ -101,9 +101,9 @@ void OverWorld::enterOverWorld()
//-----------------------------------------------------------------------------
/** General update function called once per frame.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void OverWorld::update(float dt)
void OverWorld::update(int ticks)
{
// Skip annoying waiting without a purpose
// Make sure to do all things that would normally happen in the
@@ -119,8 +119,8 @@ void OverWorld::update(float dt)
music_manager->startMusic();
m_karts[0]->startEngineSFX();
}
World::update(dt);
World::updateTrack(dt);
World::update(ticks);
World::updateTrack(ticks);
const unsigned int kart_amount = (unsigned int)m_karts.size();
// isn't it cool, on the overworld nitro is free!

View File

@@ -46,7 +46,7 @@ public:
static void enterOverWorld();
virtual void update(float delta) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE;
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;

View File

@@ -149,10 +149,11 @@ bool ProfileWorld::isRaceOver()
//-----------------------------------------------------------------------------
/** Counts the number of frames.
* \param ticks number of physics time steps - should be 1.
*/
void ProfileWorld::update(float dt)
void ProfileWorld::update(int ticks)
{
StandardRace::update(dt);
StandardRace::update(ticks);
m_frame_count++;
video::IVideoDriver *driver = irr_driver->getVideoDriver();

View File

@@ -82,7 +82,7 @@ public:
virtual ~ProfileWorld();
/** Returns identifier for this world. */
virtual std::string getInternalCode() const {return "PROFILE"; }
virtual void update(float dt);
virtual void update(int ticks);
virtual bool isRaceOver();
virtual void enterRaceOverState();

View File

@@ -84,12 +84,12 @@ void SoccerWorld::init()
m_kart_position_map.clear();
WorldWithRank::init();
m_display_rank = false;
m_goal_timer = 0.0f;
m_ball_hitter = -1;
m_ball = NULL;
m_ball_body = NULL;
m_goal_target = race_manager->getMaxGoal();
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
m_goal_timer = 0;
m_ball_hitter = -1;
m_ball = NULL;
m_ball_body = NULL;
m_goal_target = race_manager->getMaxGoal();
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
Track *track = Track::getCurrentTrack();
if (track->hasNavMesh())
@@ -143,7 +143,7 @@ void SoccerWorld::reset()
m_red_kdm.clear();
m_blue_kdm.clear();
m_ball_heading = 0.0f;
m_ball_invalid_timer = 0.0f;
m_ball_invalid_timer = 0;
if (m_goal_sound != NULL &&
m_goal_sound->getStatus() == SFXBase::SFX_PLAYING)
@@ -177,34 +177,34 @@ const std::string& SoccerWorld::getIdent() const
//-----------------------------------------------------------------------------
/** Update the world and the track.
* \param dt Time step size.
* \param ticks Physics time steps - should be 1.
*/
void SoccerWorld::update(float dt)
void SoccerWorld::update(int ticks)
{
updateBallPosition(dt);
updateBallPosition(ticks);
if (Track::getCurrentTrack()->hasNavMesh())
{
updateSectorForKarts();
updateAIData();
}
WorldWithRank::update(dt);
WorldWithRank::updateTrack(dt);
WorldWithRank::update(ticks);
WorldWithRank::updateTrack(ticks);
if (getPhase() == World::GOAL_PHASE)
{
if (m_goal_timer == 0.0f)
if (m_goal_timer == 0)
{
// Stop all karts
for (unsigned int i = 0; i < m_karts.size(); i++)
m_karts[i]->setVelocity(btVector3(0, 0, 0));
}
m_goal_timer += dt;
m_goal_timer += ticks;
if (m_goal_timer > 3.0f)
if (m_goal_timer > stk_config->time2Ticks(3.0f))
{
setPhase(WorldStatus::RACE_PHASE);
m_goal_timer = 0.0f;
m_goal_timer = 0;
if (!isRaceOver())
{
// Reset all karts
@@ -448,7 +448,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
//-----------------------------------------------------------------------------
/** Localize the ball on the navigation mesh.
*/
void SoccerWorld::updateBallPosition(float dt)
void SoccerWorld::updateBallPosition(int ticks)
{
if (isRaceOver()) return;
@@ -465,11 +465,11 @@ void SoccerWorld::updateBallPosition(float dt)
->update(getBallPosition(), true/*ignore_vertical*/);
if (!m_ball_track_sector->isOnRoad() && getPhase() == RACE_PHASE)
{
m_ball_invalid_timer += dt;
m_ball_invalid_timer += ticks;
// Reset the ball and karts if out of navmesh after 2 seconds
if (m_ball_invalid_timer >= 2.0f)
if (m_ball_invalid_timer >= stk_config->time2Ticks(2.0f))
{
m_ball_invalid_timer = 0.0f;
m_ball_invalid_timer = 0;
m_ball->reset();
for (unsigned int i = 0; i < m_karts.size(); i++)
moveKartAfterRescue(m_karts[i]);
@@ -478,7 +478,7 @@ void SoccerWorld::updateBallPosition(float dt)
}
}
else
m_ball_invalid_timer = 0.0f;
m_ball_invalid_timer = 0;
}
} // updateBallPosition

View File

@@ -266,8 +266,11 @@ private:
SFXBase *m_goal_sound;
/** Timer for displaying goal text*/
float m_goal_timer;
float m_ball_invalid_timer;
int m_goal_timer;
/** Counts ticks when the ball is off track, so a reset can be
* triggered if the ball is off for more than 2 seconds. */
int m_ball_invalid_timer;
int m_ball_hitter;
/** Goals data of each team scored */
@@ -290,7 +293,7 @@ private:
/** Set the team for the karts */
void initKartList();
/** Function to update the location the ball on the polygon map */
void updateBallPosition(float dt);
void updateBallPosition(int ticks);
/** Function to update data for AI usage. */
void updateAIData();
/** Get number of teammates in a team, used by starting position assign. */
@@ -326,7 +329,7 @@ public:
virtual const std::string& getIdent() const OVERRIDE;
virtual void update(float dt) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
// ------------------------------------------------------------------------
void onCheckGoalTriggered(bool first_goal);
// ------------------------------------------------------------------------

View File

@@ -95,11 +95,12 @@ void ThreeStrikesBattle::reset()
{
WorldWithRank::reset();
m_next_sta_spawn_time =
float next_spawn_time =
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 40.0f :
race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ? 30.0f :
race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM ?
25.0f : 20.0f;
m_next_sta_spawn_ticks = stk_config->time2Ticks(next_spawn_time);
const unsigned int kart_amount = (unsigned int)m_karts.size();
for(unsigned int n=0; n<kart_amount; n++)
@@ -349,12 +350,12 @@ const std::string& ThreeStrikesBattle::getIdent() const
//-----------------------------------------------------------------------------
/** Update the world and the track.
* \param dt Time step size.
* \param ticks Number of physics time step - should be 1.
*/
void ThreeStrikesBattle::update(float dt)
void ThreeStrikesBattle::update(int ticks)
{
WorldWithRank::update(dt);
WorldWithRank::updateTrack(dt);
WorldWithRank::update(ticks);
WorldWithRank::updateTrack(ticks);
spawnSpareTireKarts();
if (Track::getCurrentTrack()->hasNavMesh())
@@ -625,7 +626,7 @@ void ThreeStrikesBattle::addKartLife(unsigned int id)
void ThreeStrikesBattle::spawnSpareTireKarts()
{
if (m_spare_tire_karts.empty() ||
getTicksSinceStart() < m_next_sta_spawn_time)
getTicksSinceStart() < m_next_sta_spawn_ticks)
return;
// The lifespan for sta: inc_factor / period * 1000 / 2
@@ -639,10 +640,11 @@ void ThreeStrikesBattle::spawnSpareTireKarts()
default: inc_factor = 0.55f; lifespan = 27.5f; break;
}
int lifespan_ticks = stk_config->time2Ticks(lifespan);
// Spawn spare tire kart when necessary
m_next_sta_spawn_time = stk_config->time2Ticks(lifespan)
+ getTicksSinceStart() * inc_factor
+ getTicksSinceStart();
m_next_sta_spawn_ticks = int( lifespan_ticks
+ getTicksSinceStart() * inc_factor
+ getTicksSinceStart() );
int kart_has_few_lives = 0;
for (unsigned int i = 0; i < m_kart_info.size(); i++)
{
@@ -663,7 +665,7 @@ void ThreeStrikesBattle::spawnSpareTireKarts()
SpareTireAI* sta = dynamic_cast<SpareTireAI*>
(m_spare_tire_karts[i]->getController());
assert(sta);
sta->spawn(lifespan);
sta->spawn(lifespan_ticks);
}
} // spawnSpareTireKarts

View File

@@ -78,7 +78,7 @@ private:
int m_total_hit;
std::vector<AbstractKart*> m_spare_tire_karts;
float m_next_sta_spawn_time;
int m_next_sta_spawn_ticks;
public:
/** Used to show a nice graph when battle is over */
@@ -113,7 +113,7 @@ public:
// ------------------------------------------------------------------------
virtual void kartHit(const unsigned int kart_id) OVERRIDE;
// ------------------------------------------------------------------------
virtual void update(float dt) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
// ------------------------------------------------------------------------
virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node)
OVERRIDE;

View File

@@ -740,7 +740,8 @@ void World::resetAllKarts()
(*i)->getMaterial() && (*i)->getMaterial()->hasGravity() ?
(*i)->getNormal() * -g : Vec3(0, -g, 0));
}
for(int i=0; i<60; i++) Physics::getInstance()->update(1.f/60.f);
for(int i=0; i<stk_config->getPhysicsFPS(); i++)
Physics::getInstance()->update(1);
for ( KartList::iterator i=m_karts.begin(); i!=m_karts.end(); i++)
{
@@ -834,9 +835,9 @@ void World::scheduleUnpause()
* call World::update() first, to get updated kart positions. If race
* over would be handled in World::update, LinearWorld had no opportunity
* to update its data structures before the race is finished).
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void World::updateWorld(float dt)
void World::updateWorld(int ticks)
{
#ifdef DEBUG
assert(m_magic_number == 0xB01D6543);
@@ -863,12 +864,12 @@ void World::updateWorld(float dt)
! (NetworkConfig::get()->isClient() &&
RewindManager::get()->isRewinding() ) )
{
history->updateSaving(dt); // updating the saved state
history->updateSaving(ticks); // updating the saved state
}
try
{
update(dt);
update(ticks);
}
catch (AbortWorldUpdateException& e)
{
@@ -959,9 +960,9 @@ void World::scheduleTutorial()
//-----------------------------------------------------------------------------
/** Updates the physics, all karts, the track, and projectile manager.
* \param dt Time step size.
* \param ticks Number of physics time steps - should be 1.
*/
void World::update(float dt)
void World::update(int ticks)
{
#ifdef DEBUG
assert(m_magic_number == 0xB01D6543);
@@ -970,20 +971,20 @@ void World::update(float dt)
PROFILER_PUSH_CPU_MARKER("World::update()", 0x00, 0x7F, 0x00);
#if MEASURE_FPS
static float time = 0.0f;
time += dt;
if (time > 5.0f)
static int time = 0.0f;
time += ticks;
if (time > stk_config->time2Ticks(5.0f))
{
time -= 5.0f;
time -= stk_config->time2Ticks(5.0f);
printf("%i\n",irr_driver->getVideoDriver()->getFPS());
}
#endif
PROFILER_PUSH_CPU_MARKER("World::update (sub-updates)", 0x20, 0x7F, 0x00);
WorldStatus::update(dt);
WorldStatus::update(ticks);
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("World::update (RewindManager)", 0x20, 0x7F, 0x40);
RewindManager::get()->update(dt);
RewindManager::get()->update(ticks);
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("World::update (Kart::upate)", 0x40, 0x7F, 0x00);
@@ -998,7 +999,7 @@ void World::update(float dt)
dynamic_cast<SpareTireAI*>(m_karts[i]->getController());
// Update all karts that are not eliminated
if(!m_karts[i]->isEliminated() || (sta && sta->isMoving()))
m_karts[i]->update(dt);
m_karts[i]->update(ticks);
}
PROFILER_POP_CPU_MARKER();
@@ -1009,29 +1010,29 @@ void World::update(float dt)
for (unsigned int i = 0; i < Camera::getNumCameras(); i++)
{
Camera::getCamera(i)->update(dt);
Camera::getCamera(i)->update(stk_config->ticks2Time(ticks));
}
PROFILER_POP_CPU_MARKER();
} // if !rewind
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(dt);
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(ticks);
Scripting::ScriptEngine *script_engine = Scripting::ScriptEngine::getInstance();
if (script_engine) script_engine->update(dt);
if (script_engine) script_engine->update(ticks);
if (!history->dontDoPhysics())
{
Physics::getInstance()->update(dt);
Physics::getInstance()->update(ticks);
}
PROFILER_PUSH_CPU_MARKER("World::update (weather)", 0x80, 0x7F, 0x00);
if (UserConfigParams::m_particles_effects > 1 && Weather::getInstance())
{
Weather::getInstance()->update(dt);
Weather::getInstance()->update(ticks);
}
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("World::update (projectiles)", 0xa0, 0x7F, 0x00);
projectile_manager->update(dt);
projectile_manager->update(ticks);
PROFILER_POP_CPU_MARKER();
PROFILER_POP_CPU_MARKER();
@@ -1041,16 +1042,6 @@ void World::update(float dt)
#endif
} // update
// ----------------------------------------------------------------------------
/** Compute the new time, and set this new time to be used in the rewind
* manager.
* \param dt Time step size.
*/
void World::updateTime(const float dt)
{
WorldStatus::updateTime(dt);
} // updateTime
// ----------------------------------------------------------------------------
/** 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
@@ -1068,12 +1059,12 @@ void World::updateTime(const float dt)
* 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)
void World::updateTrack(int ticks)
{
Track::getCurrentTrack()->update(dt);
Track::getCurrentTrack()->update(ticks);
} // update Track
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Highscores* World::getHighscores() const
{
if(!m_use_highscores) return NULL;

View File

@@ -163,9 +163,9 @@ protected:
virtual void onGo() OVERRIDE;
/** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0;
virtual void update(float dt) OVERRIDE;
virtual void update(int ticks) OVERRIDE;
virtual void createRaceGUI();
void updateTrack(float dt);
void updateTrack(int ticks);
// ------------------------------------------------------------------------
/** 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
@@ -240,7 +240,6 @@ public:
virtual void reset() OVERRIDE;
virtual void pause(Phase phase) OVERRIDE;
virtual void unpause() OVERRIDE;
virtual void updateTime(const float dt) OVERRIDE;
virtual void getDefaultCollectibles(int *collectible_type,
int *amount );
virtual void endRaceEarly() { return; }
@@ -273,7 +272,7 @@ public:
void scheduleUnpause();
void scheduleExitRace() { m_schedule_exit_race = true; }
void scheduleTutorial();
void updateWorld(float dt);
void updateWorld(int ticks);
void handleExplosion(const Vec3 &xyz, AbstractKart *kart_hit,
PhysicalObject *object);
AbstractKart* getPlayerKart(unsigned int player) const;

View File

@@ -172,7 +172,7 @@ void WorldStatus::terminateRace()
* updated.
* \param dt Time step.
*/
void WorldStatus::update(float dt)
void WorldStatus::update(int ticks)
{
} // update
@@ -180,9 +180,9 @@ void WorldStatus::update(float dt)
/** Updates the world time and clock (which might be running backwards), and
* all status information, called once per frame at the end of the main
* loop.
* \param dt Duration of time step.
* \param ticks Number of ticks (physics time steps) - should be 1.
*/
void WorldStatus::updateTime(const float dt)
void WorldStatus::updateTime(int ticks)
{
switch (m_phase)
{

View File

@@ -152,8 +152,8 @@ public:
virtual ~WorldStatus();
virtual void reset();
virtual void updateTime(const float dt);
virtual void update(float dt);
virtual void updateTime(int ticks);
virtual void update(int ticks);
void startReadySetGo();
virtual void pause(Phase phase);
virtual void unpause();

View File

@@ -119,7 +119,7 @@ public:
/** \brief Called by the protocol listener, synchronously with the main
* loop. Must be re-defined.*/
virtual void update(float dt) = 0;
virtual void update(int ticks) = 0;
/** \brief Called by the protocol listener as often as possible.
* Must be re-defined. */

View File

@@ -395,14 +395,14 @@ bool ProtocolManager::sendEvent(Event* event)
* \param dt Time step size.
* \param async True if asynchronousUpdate() should be called.
*/
void ProtocolManager::OneProtocolType::update(float dt, bool async)
void ProtocolManager::OneProtocolType::update(int ticks, bool async)
{
for (unsigned int i = 0; i < m_protocols.getData().size(); i++)
{
if (m_protocols.getData()[i]->getState() == PROTOCOL_STATE_RUNNING)
{
async ? m_protocols.getData()[i]->asynchronousUpdate()
: m_protocols.getData()[i]->update(dt);
: m_protocols.getData()[i]->update(ticks);
}
}
} // update
@@ -417,7 +417,7 @@ void ProtocolManager::OneProtocolType::update(float dt, bool async)
* This function is called by the main thread (i.e. from main_loop).
* This function IS FPS-dependant.
*/
void ProtocolManager::update(float dt)
void ProtocolManager::update(int ticks)
{
// Update from main thread only:
assert(std::this_thread::get_id() != m_asynchronous_update_thread.get_id());
@@ -449,7 +449,7 @@ void ProtocolManager::update(float dt)
{
OneProtocolType &opt = m_all_protocols[i];
opt.lock();
opt.update(dt, /*async*/false);
opt.update(ticks, /*async*/false);
opt.unlock();
}
} // update

Some files were not shown because too many files have changed in this diff Show More