From 22f1111dbe6167497ea048272b80e67954a4007f Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 18 Oct 2018 00:51:51 +0800 Subject: [PATCH] Fix rare end race in network crash reported --- src/karts/abstract_kart.cpp | 8 ++++++-- src/karts/abstract_kart_animation.hpp | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index d6fda8d50..6880fd22e 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -72,8 +72,11 @@ AbstractKart::AbstractKart(const std::string& ident, AbstractKart::~AbstractKart() { delete m_kart_model; - if(m_kart_animation) + if (m_kart_animation) + { + m_kart_animation->handleResetRace(); delete m_kart_animation; + } } // ~AbstractKart // ---------------------------------------------------------------------------- @@ -82,8 +85,9 @@ void AbstractKart::reset() // important to delete animations before calling reset, as some animations // set the kart velocity in their destructor (e.g. cannon) which "reset" // can then cancel. See #2738 - if(m_kart_animation) + if (m_kart_animation) { + m_kart_animation->handleResetRace(); delete m_kart_animation; m_kart_animation = NULL; } diff --git a/src/karts/abstract_kart_animation.hpp b/src/karts/abstract_kart_animation.hpp index 7e2fd94fb..f0e79fc57 100644 --- a/src/karts/abstract_kart_animation.hpp +++ b/src/karts/abstract_kart_animation.hpp @@ -108,6 +108,10 @@ public: int getEndTicks() const { return m_end_ticks; } // ------------------------------------------------------------------------ virtual KartAnimationType getAnimationType() const = 0; + // ------------------------------------------------------------------------ + /* Remove the timer changes by checkNetworkAnimationCreationSucceed if + * m_kart has been eliminated by network. */ + void handleResetRace() { m_timer = 9999; } }; // AbstractKartAnimation #endif