Fix potential destruction crashes (#5095)
* Fix potential destruction crashes * Fix destructors accessing destroyted objects * Fix cPlayer not destroying windows (Destroyed never called) * Tentatively fixes #4608, fixes #3236, fixes #3262 - Remove cEntity::Destroyed() and replace with cEntity::OnRemoveFromWorld() * Add missing call to OnRemoveFromWorld
This commit is contained in:
@@ -28,25 +28,6 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) :
|
||||
|
||||
|
||||
|
||||
cPawn::~cPawn()
|
||||
{
|
||||
ASSERT(m_TargetingMe.size() == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cPawn::Destroyed()
|
||||
{
|
||||
StopEveryoneFromTargetingMe();
|
||||
Super::Destroyed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
std::vector<cEntityEffect *> EffectsToTick;
|
||||
@@ -453,6 +434,16 @@ void cPawn::HandleFalling(void)
|
||||
|
||||
|
||||
|
||||
void cPawn::OnRemoveFromWorld(cWorld & a_World)
|
||||
{
|
||||
StopEveryoneFromTargetingMe();
|
||||
Super::OnRemoveFromWorld(a_World);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cPawn::StopEveryoneFromTargetingMe()
|
||||
{
|
||||
std::vector<cMonster*>::iterator i = m_TargetingMe.begin();
|
||||
|
||||
Reference in New Issue
Block a user