From d61b74fdd4f39f4d7b518d9a459270fb69735d88 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 28 Sep 2018 22:52:18 +0800 Subject: [PATCH] Fix parachute rewind --- src/items/attachment.cpp | 13 +++++++------ src/items/attachment.hpp | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index f6919d166..e9ec70a2f 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -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(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 // ----------------------------------------------------------------------------- diff --git a/src/items/attachment.hpp b/src/items/attachment.hpp index ef2ed2d68..1e11f7c9a 100644 --- a/src/items/attachment.hpp +++ b/src/items/attachment.hpp @@ -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;