// delete a portal instance by pointer void PCZSceneManager::destroyPortal(Portal * p) { // remove the portal from it's target portal Portal * targetPortal = p->getTargetPortal(); if (targetPortal) { targetPortal->setTargetPortal(0); // the targetPortal will still have targetZone value, but targetPortal will be invalid } // remove the Portal from it's home zone PCZone * homeZone = p->getCurrentHomeZone(); if (homeZone) { // inform zone of portal change. Do here since PCZone is abstract homeZone->setPortalsUpdated(true); homeZone->_removePortal(p); } // remove the portal from the master portal list PortalList::iterator it = std::find( mPortals.begin(), mPortals.end(), p ); if (it != mPortals.end()) { mPortals.erase(it); } // delete the portal instance OGRE_DELETE p; }
// delete a portal instance by pointer void PCZSceneManager::destroyPortal(const String & portalName) { // find the portal from the master portal list Portal * p; Portal * thePortal = 0; PortalList::iterator it = mPortals.begin(); while (it != mPortals.end()) { p = *it; if (p->getName() == portalName) { thePortal = p; // erase entry in the master list mPortals.erase(it); break; } it++; } if (thePortal) { // remove the portal from it's target portal Portal * targetPortal = thePortal->getTargetPortal(); if (targetPortal) { targetPortal->setTargetPortal(0); // the targetPortal will still have targetZone value, but targetPortal will be invalid } // remove the Portal from it's home zone PCZone * homeZone = thePortal->getCurrentHomeZone(); if (homeZone) { // inform zone of portal change homeZone->setPortalsUpdated(true); homeZone->_removePortal(thePortal); } // delete the portal instance OGRE_DELETE thePortal; } }