CBaseFX* CClientFXMgr::CreateFX(const char *sName, FX_BASEDATA *pBaseData, CBaseFXProps* pProps) { //track our performance CTimedSystemBlock TimingBlock(g_tsClientFXUpdateCreate); CBaseFX *pNewFX = NULL; // Locate the named FX const FX_REF *pFxRef = CClientFXDB::GetSingleton().FindFX(sName); if( pFxRef ) { pNewFX = pFxRef->m_pfnCreate(); } // If we have a new fx, go ahead and add it onto the active list if( pNewFX ) { //initialize the effect if( !pNewFX->Init(pBaseData, pProps) ) { //if this failed to initialize, then destroy the effect pNewFX->Term(); CClientFXDB::GetSingleton().DeleteEffect(pNewFX); pNewFX = NULL; } } // All done.... return pNewFX; }
void CLIENTFX_INSTANCE::DeleteFX(CLinkListNode<FX_LINK> *pDelNode) { if( !pDelNode ) return; CBaseFX* pDelFX = pDelNode->m_Data.m_pFX; if(pDelFX) { // Make sure no other active FX in this instance have this pDelFX has their parent... CLinkListNode<FX_LINK> *pActiveNode = m_collActiveFX.GetHead(); while( pActiveNode ) { CBaseFX *pPossibleChildFX = pActiveNode->m_Data.m_pFX; if( pPossibleChildFX && (pPossibleChildFX->GetParent() == pDelFX->GetFXObject())) { // NULL out the parent otherwise it will reference an object that is no longer there pPossibleChildFX->SetParent( LTNULL ); } pActiveNode = pActiveNode->m_pNext; } // Give the FX a chance to clean itself up pDelFX->Term(); CClientFXDB::GetSingleton().DeleteEffect(pDelFX); } //now remove this node from our list m_collActiveFX.Remove(pDelNode); }
CBaseFX* CClientFXMgr::CreateFX(const char *sName, FX_BASEDATA *pBaseData, CBaseFXProps* pProps, HOBJECT hInstParent) { CBaseFX *pNewFX = NULL; // Locate the named FX FX_REF *pFxRef = CClientFXDB::GetSingleton().FindFX(sName); if( pFxRef ) { pNewFX = pFxRef->m_pfnCreate(); } // If we have a new fx, go ahead and add it onto the active list if( pNewFX ) { // Assign a unique ID for this FX pBaseData->m_dwID = GetUniqueID(); if( !pNewFX->Init(m_pClientDE, pBaseData, pProps) ) { // See if the FX->Init() filled out data to create a new instance... if( pBaseData->m_sNode[0] ) { CLIENTFX_CREATESTRUCT fxCS( pBaseData->m_sNode, pBaseData->m_dwFlags, pBaseData->m_vPos, pBaseData->m_rRot ); fxCS.m_vTargetNorm = pBaseData->m_vTargetNorm; fxCS.m_hParent = hInstParent; CreateClientFX( fxCS, LTTRUE ); } pNewFX->Term(); CClientFXDB::GetSingleton().DeleteEffect(pNewFX); pNewFX = NULL; } } // All done.... return pNewFX; }