ALERROR CEffectCreator::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc) // OnCreateFromXML // // Load from XML. This is only called if we go through the EffectType path // (as opposed to plain Effect). { ALERROR error; // Basic info m_sUNID = strFromInt(GetUNID(), FALSE); m_dwSoundUNID = pDesc->GetAttributeInteger(SOUND_ATTRIB); m_iSound = -1; // Allow our subclass to initialize based on the effect // (We know we have one because we couldn't have gotten this far // without one. See CreateTypeFromXML.) CXMLElement *pEffect = pDesc->GetContentElementByTag(EFFECT_TAG); ASSERT(pEffect); if (pEffect->GetContentElementCount() == 1) error = OnEffectCreateFromXML(Ctx, pEffect->GetContentElement(0), m_sUNID); else error = OnEffectCreateFromXML(Ctx, pEffect, m_sUNID); if (error) return error; // Load damage descriptors CXMLElement *pDamageDesc = pDesc->GetContentElementByTag(DAMAGE_TAG); if (pDamageDesc) { m_pDamage = new CWeaponFireDesc; CString sUNID = strPatternSubst(CONSTLIT("%d/d"), GetUNID()); if (error = m_pDamage->InitFromXML(Ctx, pDamageDesc, sUNID, true)) return error; } return NOERROR; }
ALERROR CEffectCreator::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc) // OnCreateFromXML // // Load from XML. This is only called if we go through the EffectType path // (as opposed to plain Effect types). { ALERROR error; // Basic info m_sUNID = strFromInt(GetUNID(), false); if (error = InitBasicsFromXML(Ctx, pDesc)) return error; // Allow our subclass to initialize based on the effect // (We know we have one because we couldn't have gotten this far // without one. See CreateTypeFromXML.) CXMLElement *pEffect = pDesc->GetContentElementByTag(EFFECT_TAG); ASSERT(pEffect); // Continue if (pEffect->GetContentElementCount() == 1) { CXMLElement *pEffectDesc = pEffect->GetContentElement(0); // Load events for this effect, in case they're here. CXMLElement *pEventsDesc = pEffectDesc->GetContentElementByTag(EVENTS_TAG); if (pEventsDesc) { if (error = m_Events.InitFromXML(Ctx, pEventsDesc)) return error; } // Load the single effect error = OnEffectCreateFromXML(Ctx, pEffectDesc, m_sUNID); } else error = OnEffectCreateFromXML(Ctx, pEffect, m_sUNID); if (error) return error; // Load damage descriptors CXMLElement *pDamageDesc = pDesc->GetContentElementByTag(DAMAGE_TAG); if (pDamageDesc) { m_pDamage = new CWeaponFireDesc; CString sUNID = strPatternSubst(CONSTLIT("%d/d"), GetUNID()); if (error = m_pDamage->InitFromXML(Ctx, pDamageDesc, sUNID, true)) return error; } return NOERROR; }