Fixed counting of explosions and rescues in KartWithStats.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11554 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
42b9550373
commit
0ba86c2c3b
@ -24,6 +24,7 @@
|
||||
#include "karts/controller/kart_control.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
class AbstractKartAnimation;
|
||||
class Attachment;
|
||||
class btKart;
|
||||
class btQuaternion;
|
||||
@ -31,7 +32,6 @@ class btUprightConstraint;
|
||||
class Camera;
|
||||
class Controller;
|
||||
class Item;
|
||||
class AbstractKartAnimation;
|
||||
class KartModel;
|
||||
class KartProperties;
|
||||
class Material;
|
||||
@ -158,7 +158,7 @@ public:
|
||||
{ return m_kart_animation; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets a new kart animation. */
|
||||
void setKartAnimation(AbstractKartAnimation *ka);
|
||||
virtual void setKartAnimation(AbstractKartAnimation *ka);
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -53,12 +53,12 @@ public:
|
||||
virtual ~AbstractKartAnimation();
|
||||
virtual void update(float dt);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current animation timer. */
|
||||
virtual float getAnimationTimer() const { return m_timer; }
|
||||
#ifdef DEBUG
|
||||
// ------------------------------------------------------------------------
|
||||
/** To easily allow printing the name of the animation being used atm.
|
||||
* Used in AstractKart in case of an incorrect sequence of calls. */
|
||||
virtual const std::string getName() const { return m_name; }
|
||||
#endif
|
||||
virtual const std::string &getName() const { return m_name; }
|
||||
|
||||
}; // AbstractKartAnimation
|
||||
|
||||
|
@ -76,12 +76,16 @@ void KartWithStats::setKartAnimation(AbstractKartAnimation *ka)
|
||||
// Nothing to count if it's not a new animation
|
||||
if(!is_new) return;
|
||||
|
||||
if(dynamic_cast<ExplosionAnimation*>(ka))
|
||||
// We can't use a dynamic cast here, since this function is called from
|
||||
// constructor of AbstractKartAnimation, which is the base class for all
|
||||
// animations. So at this stage ka is only an AbstractKartAnimation, not
|
||||
// any of the derived classes.
|
||||
if(ka && ka->getName()=="ExplosionAnimation")
|
||||
{
|
||||
m_explosion_count ++;
|
||||
m_explosion_time += ka->getAnimationTimer();
|
||||
}
|
||||
else if(dynamic_cast<RescueAnimation*>(ka))
|
||||
else if(ka && ka->getName()=="RescueAnimation")
|
||||
{
|
||||
m_rescue_count ++;
|
||||
m_rescue_time += ka->getAnimationTimer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user