Fix nitro in network
This commit is contained in:
parent
16cebffa3a
commit
75c8864e8f
@ -2073,10 +2073,11 @@ void Kart::updateNitro(int ticks)
|
||||
m_min_nitro_ticks = 1;
|
||||
}
|
||||
|
||||
bool rewinding = RewindManager::get()->isRewinding();
|
||||
bool increase_speed = (m_min_nitro_ticks > 0 && isOnGround());
|
||||
if (!increase_speed && m_min_nitro_ticks <= 0)
|
||||
{
|
||||
if (m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING)
|
||||
if (m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING && !rewinding)
|
||||
m_nitro_sound->stop();
|
||||
return;
|
||||
}
|
||||
@ -2085,7 +2086,7 @@ void Kart::updateNitro(int ticks)
|
||||
m_collected_energy -= dt * m_kart_properties->getNitroConsumption();
|
||||
if (m_collected_energy < 0)
|
||||
{
|
||||
if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING)
|
||||
if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING && !rewinding)
|
||||
m_nitro_sound->stop();
|
||||
m_collected_energy = 0;
|
||||
return;
|
||||
@ -2093,7 +2094,7 @@ void Kart::updateNitro(int ticks)
|
||||
|
||||
if (increase_speed)
|
||||
{
|
||||
if(m_nitro_sound->getStatus() != SFXBase::SFX_PLAYING)
|
||||
if(m_nitro_sound->getStatus() != SFXBase::SFX_PLAYING && !rewinding)
|
||||
m_nitro_sound->play();
|
||||
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO,
|
||||
m_kart_properties->getNitroMaxSpeedIncrease(),
|
||||
@ -2103,7 +2104,7 @@ void Kart::updateNitro(int ticks)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING)
|
||||
if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING && !rewinding)
|
||||
m_nitro_sound->stop();
|
||||
}
|
||||
} // updateNitro
|
||||
|
@ -251,7 +251,7 @@ protected:
|
||||
RaceManager::KartType m_type;
|
||||
|
||||
/** To prevent using nitro in too short bursts */
|
||||
int m_min_nitro_ticks;
|
||||
int8_t m_min_nitro_ticks;
|
||||
|
||||
void updatePhysics(int ticks);
|
||||
void handleMaterialSFX();
|
||||
|
@ -92,7 +92,7 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_color = video::SColor(255, 0, 0, 0);
|
||||
m_shape = 32; // close enough to a circle.
|
||||
m_engine_sfx_type = "engine_small";
|
||||
m_nitro_min_consumption = 0.53f;
|
||||
m_nitro_min_consumption = 64;
|
||||
// The default constructor for stk_config uses filename=""
|
||||
if (filename != "")
|
||||
{
|
||||
@ -1001,15 +1001,6 @@ float KartProperties::getNitroDuration() const
|
||||
} // 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
|
||||
{
|
||||
return m_cached_characteristic->getNitroEngineForce();
|
||||
|
@ -147,7 +147,7 @@ private:
|
||||
/** Minimum time during which nitro is consumed when pressing
|
||||
* the nitro key (to prevent using in very small bursts)
|
||||
*/
|
||||
float m_nitro_min_consumption;
|
||||
int8_t m_nitro_min_consumption;
|
||||
|
||||
/** Type of the kart (for the properties) */
|
||||
std::string m_kart_type;
|
||||
@ -476,9 +476,6 @@ public:
|
||||
float getNitroMaxSpeedIncrease() const;
|
||||
float getNitroFadeOutTime() const;
|
||||
float getNitroMax() const;
|
||||
int getNitroMinConsumptionTicks() const;
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
float getSlipstreamDurationFactor() const;
|
||||
float getSlipstreamBaseSpeed() const;
|
||||
float getSlipstreamLength() const;
|
||||
@ -509,6 +506,12 @@ public:
|
||||
float getSkidReduceTurnMin() const;
|
||||
float getSkidReduceTurnMax() const;
|
||||
bool getSkidEnabled() const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns minimum time during which nitro is consumed when pressing nitro
|
||||
* key, to prevent using nitro in very short bursts
|
||||
*/
|
||||
int8_t getNitroMinConsumptionTicks() const
|
||||
{ return m_nitro_min_consumption; }
|
||||
|
||||
/* <characteristics-end kpdefs> */
|
||||
|
||||
|
@ -108,7 +108,7 @@ BareNetworkString* KartRewinder::saveState()
|
||||
// -----------------------------
|
||||
getAttachment()->saveState(buffer);
|
||||
getPowerup()->saveState(buffer);
|
||||
buffer->addFloat(getEnergy());
|
||||
buffer->addUInt8(m_min_nitro_ticks).addFloat(getEnergy());
|
||||
|
||||
// 4) Max speed info
|
||||
// ------------------
|
||||
@ -173,6 +173,7 @@ void KartRewinder::restoreState(BareNetworkString *buffer, int count)
|
||||
// ------------------------------
|
||||
getAttachment()->rewindTo(buffer);
|
||||
getPowerup()->rewindTo(buffer);
|
||||
m_min_nitro_ticks = buffer->getUInt8();
|
||||
float nitro = buffer->getFloat();
|
||||
setEnergy(nitro);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user