diff --git a/colobot-base/level/robotmain.cpp b/colobot-base/level/robotmain.cpp index 92270cb6..61072531 100644 --- a/colobot-base/level/robotmain.cpp +++ b/colobot-base/level/robotmain.cpp @@ -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(obj->GetType())); line->AddParam("id", std::make_unique(obj->GetID())); line->AddParam("pos", std::make_unique(obj->GetPosition()/g_unit)); diff --git a/colobot-base/object/old_object.cpp b/colobot-base/object/old_object.cpp index f3b2485a..68f3af12 100644 --- a/colobot-base/object/old_object.cpp +++ b/colobot-base/object/old_object.cpp @@ -286,8 +286,8 @@ void COldObject::DeleteObject(bool bAll) if (m_power->Implements(ObjectInterfaceType::Old)) { dynamic_cast(*m_power).SetTransporter(nullptr); - dynamic_cast(*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(*m_cargo).SetTransporter(nullptr); - dynamic_cast(*m_cargo).DeleteObject(bAll); } + CObjectManager::GetInstance().DeleteObject(m_cargo); m_cargo = nullptr; } }