From 2d6c45f65ee0f230887dc6a87801da98da8417e7 Mon Sep 17 00:00:00 2001 From: Benau Date: Wed, 11 Jul 2018 01:36:20 +0800 Subject: [PATCH] Fix attachment rewind with passing bomb --- src/items/attachment.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index b9dce1b46..7c651d98a 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -287,16 +287,7 @@ void Attachment::rewindTo(BareNetworkString *buffer) int ticks_left = buffer->getUInt32(); - // Attaching an object can be expensive (loading new models, ...) - // so avoid doing this if there is no change in attachment type - if(new_type == m_type) - { - setTicksLeft(ticks_left); - return; - } - // Now it is a new attachment: - if (type == (ATTACH_BOMB | 0x80)) // we have previous owner information { uint8_t kart_id = buffer->getUInt8(); @@ -306,6 +297,15 @@ void Attachment::rewindTo(BareNetworkString *buffer) { m_previous_owner = NULL; } + + // Attaching an object can be expensive (loading new models, ...) + // so avoid doing this if there is no change in attachment type + if(new_type == m_type) + { + setTicksLeft(ticks_left); + return; + } + set(new_type, ticks_left, m_previous_owner); } // rewindTo // ----------------------------------------------------------------------------- @@ -412,7 +412,7 @@ void Attachment::hitBanana(ItemState *item_state) // if going very slowly or backwards, // braking won't remove parachute if(m_initial_speed <= 1.5) m_initial_speed = 1.5; - break ; + break; case ATTACH_ANVIL: set(ATTACH_ANVIL, stk_config->time2Ticks(kp->getAnvilDuration()) + leftover_ticks ); @@ -422,12 +422,13 @@ void Attachment::hitBanana(ItemState *item_state) // handled in Kart::updatePhysics m_kart->adjustSpeed(kp->getAnvilSpeedFactor()); m_kart->updateWeight(); - break ; + break; case ATTACH_BOMB: set( ATTACH_BOMB, stk_config->time2Ticks(stk_config->m_bomb_time) + leftover_ticks ); - - break ; + break; + default: + break; } // switch } } // hitBanana