mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 09:44:02 +00:00
fix some rare crashes with dangling pointers
- Always handle entity death ie. do pointer cleanup - Call Lua entityDied() only when EV_ENTITYDIED is set - EV_ENTITYDIED is now meaningless for non-scripted entities
This commit is contained in:
parent
c1084a022d
commit
bf58fe91c6
6 changed files with 18 additions and 35 deletions
|
@ -3063,11 +3063,6 @@ void Avatar::setBlockSinging(bool v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Avatar::canSetBoneLock()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::onSetBoneLock()
|
void Avatar::onSetBoneLock()
|
||||||
{
|
{
|
||||||
Entity::onSetBoneLock();
|
Entity::onSetBoneLock();
|
||||||
|
|
|
@ -300,8 +300,6 @@ public:
|
||||||
Web *web;
|
Web *web;
|
||||||
float rollDelay;
|
float rollDelay;
|
||||||
|
|
||||||
bool canSetBoneLock() OVERRIDE;
|
|
||||||
|
|
||||||
void revert();
|
void revert();
|
||||||
void doBindSong();
|
void doBindSong();
|
||||||
void doShieldSong();
|
void doShieldSong();
|
||||||
|
|
|
@ -61,17 +61,18 @@ void Entity::setIngredientData(const std::string &name)
|
||||||
void Entity::entityDied(Entity *e)
|
void Entity::entityDied(Entity *e)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < targets.size(); i++)
|
for (size_t i = 0; i < targets.size(); i++)
|
||||||
|
if(targets[i] == e)
|
||||||
|
targets[i] = NULL;
|
||||||
|
|
||||||
|
if (boneLock.on && boneLock.entity == e)
|
||||||
{
|
{
|
||||||
targets[i] = 0;
|
setBoneLock(BoneLock(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boneLock.on)
|
if(riding == e)
|
||||||
{
|
riding = NULL;
|
||||||
if (boneLock.entity == e)
|
if(ridingOnEntity == e)
|
||||||
{
|
ridingOnEntity = NULL;
|
||||||
setBoneLock(BoneLock());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setBounceType(BounceType bt)
|
void Entity::setBounceType(BounceType bt)
|
||||||
|
@ -98,14 +99,13 @@ void Entity::generateCollisionMask(int ovrCollideRadius)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Entity::setBoneLock(const BoneLock &bl, bool force)
|
||||||
|
|
||||||
bool Entity::setBoneLock(const BoneLock &bl)
|
|
||||||
{
|
{
|
||||||
if (!canSetBoneLock()) return false;
|
if(!force)
|
||||||
|
{
|
||||||
if (bl.on && boneLockDelay > 0) return false;
|
if (bl.on && boneLockDelay > 0) return false;
|
||||||
if (boneLock.on && bl.on) return false;
|
if (boneLock.on && bl.on) return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (boneLock.on && !bl.on)
|
if (boneLock.on && !bl.on)
|
||||||
{
|
{
|
||||||
|
@ -138,11 +138,6 @@ bool Entity::setBoneLock(const BoneLock &bl)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::canSetBoneLock()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity::Entity()
|
Entity::Entity()
|
||||||
{
|
{
|
||||||
addType(SCO_ENTITY);
|
addType(SCO_ENTITY);
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
float health;
|
float health;
|
||||||
float maxHealth;
|
float maxHealth;
|
||||||
|
|
||||||
bool setBoneLock(const BoneLock &boneLock);
|
bool setBoneLock(const BoneLock &boneLock, bool force = false);
|
||||||
|
|
||||||
void heal(float a, int type=0);
|
void heal(float a, int type=0);
|
||||||
|
|
||||||
|
@ -330,8 +330,6 @@ public:
|
||||||
void setPoison(float m, float t);
|
void setPoison(float m, float t);
|
||||||
inline float getPoison() const { return poison; }
|
inline float getPoison() const { return poison; }
|
||||||
|
|
||||||
virtual bool canSetBoneLock();
|
|
||||||
|
|
||||||
void initHair(int numSegments, float segmentLength, float width, const std::string &tex);
|
void initHair(int numSegments, float segmentLength, float width, const std::string &tex);
|
||||||
void updateHair(float dt);
|
void updateHair(float dt);
|
||||||
void setHairHeadPosition(const Vector &pos);
|
void setHairHeadPosition(const Vector &pos);
|
||||||
|
|
|
@ -2333,10 +2333,7 @@ void Game::entityDied(Entity *eDead)
|
||||||
FOR_ENTITIES(i)
|
FOR_ENTITIES(i)
|
||||||
{
|
{
|
||||||
e = *i;
|
e = *i;
|
||||||
if (e != eDead && e->isv(EV_ENTITYDIED,1))
|
e->entityDied(eDead);
|
||||||
{
|
|
||||||
e->entityDied(eDead);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dsq->continuity.entityDied(eDead);
|
dsq->continuity.entityDied(eDead);
|
||||||
|
|
|
@ -688,7 +688,7 @@ void ScriptedEntity::entityDied(Entity *e)
|
||||||
{
|
{
|
||||||
CollideEntity::entityDied(e);
|
CollideEntity::entityDied(e);
|
||||||
|
|
||||||
if (script)
|
if (script && e != this && e->isv(EV_ENTITYDIED,1))
|
||||||
{
|
{
|
||||||
script->call("entityDied", this, e);
|
script->call("entityDied", this, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue