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:
@@ -32,19 +32,6 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
|
||||
|
||||
|
||||
|
||||
cHorse::~cHorse()
|
||||
{
|
||||
auto Window = GetWindow();
|
||||
if (Window != nullptr)
|
||||
{
|
||||
Window->OwnerDestroyed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
Super::Tick(a_Dt, a_Chunk);
|
||||
@@ -123,6 +110,21 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
void cHorse::OnRemoveFromWorld(cWorld & a_World)
|
||||
{
|
||||
const auto Window = GetWindow();
|
||||
if (Window != nullptr)
|
||||
{
|
||||
Window->OwnerDestroyed();
|
||||
}
|
||||
|
||||
Super::OnRemoveFromWorld(a_World);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cHorse::OnRightClicked(cPlayer & a_Player)
|
||||
{
|
||||
Super::OnRightClicked(a_Player);
|
||||
|
||||
Reference in New Issue
Block a user