Fix delete() in CBot not destroying PowerCells properly

master
krzys-h 2017-05-23 20:19:47 +02:00
parent aa1a946336
commit 2d7911f155
2 changed files with 13 additions and 0 deletions

View File

@ -2157,6 +2157,9 @@ bool CPyro::BurnIsKeepPart(int part)
void CPyro::BurnTerminate()
{
if (m_object == nullptr)
return;
if (m_type == PT_BURNO) // organic object is burning?
{
DeleteObject(true, true); // removes the insect

View File

@ -682,6 +682,16 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
}
else
{
if (obj->Implements(ObjectInterfaceType::Old))
{
COldObject* oldobj = dynamic_cast<COldObject*>(obj);
if (oldobj->GetPower() != nullptr)
CObjectManager::GetInstancePointer()->DeleteObject(oldobj->GetPower());
if (oldobj->GetCargo() != nullptr)
CObjectManager::GetInstancePointer()->DeleteObject(oldobj->GetCargo());
oldobj->SetPower(nullptr);
oldobj->SetCargo(nullptr);
}
CObjectManager::GetInstancePointer()->DeleteObject(obj);
}
}