Fix rare end race in network crash reported

This commit is contained in:
Benau 2018-10-18 00:51:51 +08:00
parent c1f10d79cb
commit 22f1111dbe
2 changed files with 10 additions and 2 deletions

View File

@ -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;
}

View File

@ -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