make sure inhandnade is cleaned up if bounceent is removed

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4274 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2009-03-16 21:04:21 +00:00
parent 74fd154656
commit e2ff773e0e
3 changed files with 14 additions and 2 deletions
+2 -1
View File
@@ -548,7 +548,8 @@ public:
bool local;
int nadestate;
float distsincebounce;
grenadeent (playerent *owner, int millis = 0);
grenadeent(playerent *owner, int millis = 0);
~grenadeent();
void activate(const vec &from, const vec &to);
void _throw(const vec &from, const vec &vel);
void explode();
+9
View File
@@ -691,6 +691,11 @@ grenadeent::grenadeent (playerent *owner, int millis)
distsincebounce = 0.0f;
}
grenadeent::~grenadeent()
{
if(owner && owner->weapons[GUN_GRENADE]) owner->weapons[GUN_GRENADE]->removebounceent(this);
}
void grenadeent::explode()
{
if(nadestate!=NS_ACTIVATED && nadestate!=NS_THROWED ) return;
@@ -908,6 +913,10 @@ void grenades::onownerdies()
if(owner==player1 && inhandnade) dropnade();
}
void grenades::removebounceent(bounceent *b)
{
if(b == inhandnade) { inhandnade = NULL; reset(); }
}
// gun base class
+3 -1
View File
@@ -1,5 +1,6 @@
class playerent;
class bounceent;
struct weapon
{
@@ -38,6 +39,7 @@ struct weapon
virtual void ondeselecting() {}
virtual void onammopicked() {}
virtual void onownerdies() {}
virtual void removebounceent(bounceent *b) {}
void sendshoot(vec &from, vec &to);
bool modelattacking();
@@ -49,7 +51,6 @@ struct weapon
};
class grenadeent;
class bounceent;
enum { GST_NONE, GST_INHAND, GST_THROWING };
@@ -74,6 +75,7 @@ struct grenades : weapon
bool busy();
void onselecting();
void onownerdies();
void removebounceent(bounceent *b);
int flashtime() const;
};