Fix some save file corruption (type 0 objects) caused by children of deleted objects not getting properly deleted.
parent
d22b32477e
commit
b98edec8f8
|
@ -4654,6 +4654,7 @@ bool CRobotMain::IOIsBusy()
|
|||
//! Writes an object into the backup file
|
||||
void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj, const std::string& programDir, int objRank, bool directProgramStorageIndex)
|
||||
{
|
||||
assert(obj->GetType() != OBJECT_NULL);
|
||||
line->AddParam("type", std::make_unique<CLevelParserParam>(obj->GetType()));
|
||||
line->AddParam("id", std::make_unique<CLevelParserParam>(obj->GetID()));
|
||||
line->AddParam("pos", std::make_unique<CLevelParserParam>(obj->GetPosition()/g_unit));
|
||||
|
|
|
@ -286,8 +286,8 @@ void COldObject::DeleteObject(bool bAll)
|
|||
if (m_power->Implements(ObjectInterfaceType::Old))
|
||||
{
|
||||
dynamic_cast<COldObject&>(*m_power).SetTransporter(nullptr);
|
||||
dynamic_cast<COldObject&>(*m_power).DeleteObject(bAll);
|
||||
}
|
||||
CObjectManager::GetInstance().DeleteObject(m_power);
|
||||
m_power = nullptr;
|
||||
}
|
||||
if (m_cargo != nullptr)
|
||||
|
@ -295,8 +295,8 @@ void COldObject::DeleteObject(bool bAll)
|
|||
if (m_cargo->Implements(ObjectInterfaceType::Old))
|
||||
{
|
||||
dynamic_cast<COldObject&>(*m_cargo).SetTransporter(nullptr);
|
||||
dynamic_cast<COldObject&>(*m_cargo).DeleteObject(bAll);
|
||||
}
|
||||
CObjectManager::GetInstance().DeleteObject(m_cargo);
|
||||
m_cargo = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue