Fix parachute rewind

This commit is contained in:
Benau 2018-09-28 22:52:18 +08:00
parent 97e5e63e7c
commit d61b74fdd4
2 changed files with 9 additions and 7 deletions

View File

@ -110,7 +110,8 @@ Attachment::~Attachment()
*/
void Attachment::set(AttachmentType type, int ticks,
AbstractKart *current_kart,
bool disable_swatter_animation)
bool disable_swatter_animation,
bool set_by_rewind_parachute)
{
// Don't override currently player swatter removing bomb animation
Swatter* s = dynamic_cast<Swatter*>(m_plugin);
@ -179,7 +180,8 @@ void Attachment::set(AttachmentType type, int ticks,
// A parachute can be attached as result of the usage of an item. In this
// case we have to save the current kart speed so that it can be detached
// by slowing down.
if(m_type==ATTACH_PARACHUTE)
// if set by rewind the parachute ticks is already correct
if (m_type == ATTACH_PARACHUTE && !set_by_rewind_parachute)
{
const KartProperties *kp = m_kart->getKartProperties();
float speed_mult;
@ -306,9 +308,7 @@ void Attachment::rewindTo(BareNetworkString *buffer)
// Attaching an object can be expensive (loading new models, ...)
// so avoid doing this if there is no change in attachment type
// Don't use set to reset a model on local player if it's already cleared
// (or m_initial_speed is redone / model is re-shown again when rewinding)
if (m_type == new_type || m_type == ATTACH_NOTHING)
if (m_type == new_type)
{
setTicksLeft(ticks_left);
if (m_type != new_type && new_type != ATTACH_SWATTER)
@ -318,7 +318,8 @@ void Attachment::rewindTo(BareNetworkString *buffer)
set(new_type, ticks_left, m_previous_owner,
new_type == ATTACH_SWATTER && !is_removing_bomb
/*disable_swatter_animation*/);
/*disable_swatter_animation*/,
new_type == ATTACH_PARACHUTE);
} // rewindTo
// -----------------------------------------------------------------------------

View File

@ -116,7 +116,8 @@ public:
void handleCollisionWithKart(AbstractKart *other);
void set (AttachmentType type, int ticks,
AbstractKart *previous_kart=NULL,
bool disable_swatter_animation = false);
bool disable_swatter_animation = false,
bool set_by_rewind_parachute = false);
void rewindTo(BareNetworkString *buffer);
void saveState(BareNetworkString *buffer) const;