ALERROR CGameSettings::ParseCommandLine (char *pszCmdLine) // ParseCommandLine // // Allow command line to override settings { ALERROR error; int i; char *argv[2]; argv[0] = "Transcendence"; argv[1] = pszCmdLine; CXMLElement *pCmdLine; if (error = CreateXMLElementFromCommandLine(2, argv, &pCmdLine)) return error; // Loop over all command line arguments for (i = 0; i < COMMAND_LINE_DATA_COUNT; i++) { bool bValue; if (pCmdLine->FindAttributeBool(CString(g_CommandLineData[i].pszParam, -1, true), &bValue)) SetValueBoolean(g_CommandLineData[i].iOption, bValue); } // If we have an arg then use it as the save file name if (pCmdLine->GetContentElementCount() > 0) m_sSaveFile = pCmdLine->GetContentText(0); // Done delete pCmdLine; return NOERROR; }
ALERROR CEnergyFieldType::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc) // OnCreateFromXML // // Create from XML { ALERROR error; // Effect CXMLElement *pEffect = pDesc->GetContentElementByTag(EFFECT_TAG); if (pEffect) { if (error = CEffectCreator::CreateFromXML(Ctx, pEffect, strPatternSubst(CONSTLIT("%d:e"), GetUNID()), &m_pEffect)) { Ctx.sError = strPatternSubst(CONSTLIT("energy field %x: Unable to load effect"), GetUNID()); return error; } } pEffect = pDesc->GetContentElementByTag(HIT_EFFECT_TAG); if (pEffect == NULL) pEffect = pDesc->GetContentElementByTag(EFFECT_WHEN_HIT_TAG); if (pEffect) { if (error = CEffectCreator::CreateFromXML(Ctx, pEffect, strPatternSubst(CONSTLIT("%d:h"), GetUNID()), &m_pHitEffect)) { Ctx.sError = strPatternSubst(CONSTLIT("energy field %x: Unable to load hit effect"), GetUNID()); return error; } // For compatibility with previous versions, if we're using the old // <ShipEnergyFieldType> then altEffect defaults to TRUE. Otherwise, for new // <OverlayType> altEffect defaults to false. bool bAltEffect; if (pEffect->FindAttributeBool(ALT_EFFECT_ATTRIB, &bAltEffect)) m_bAltHitEffect = bAltEffect; else m_bAltHitEffect = strEquals(pDesc->GetTag(), SHIP_ENERGY_FIELD_TYPE_TAG); } else m_bAltHitEffect = false; // Rotation m_bRotateWithShip = !pDesc->GetAttributeBool(IGNORE_SHIP_ROTATION_ATTRIB); // Damage adjustment LoadDamageAdj(pDesc, ABSORB_ADJ_ATTRIB, m_iAbsorbAdj); // Bonus adjustment LoadDamageAdj(pDesc, BONUS_ADJ_ATTRIB, m_iBonusAdj); // Load the weapon suppress if (error = m_WeaponSuppress.InitFromXML(pDesc->GetAttribute(WEAPON_SUPPRESS_ATTRIB))) { Ctx.sError = CONSTLIT("Unable to load weapon suppress attribute"); return error; } // Keep track of the events that we have m_bHasOnUpdateEvent = FindEventHandler(ON_UPDATE_EVENT); // Done return NOERROR; }
ALERROR COverlayType::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc) // OnCreateFromXML // // Create from XML { ALERROR error; // Effect CXMLElement *pEffect = pDesc->GetContentElementByTag(EFFECT_TAG); if (pEffect) { if (error = CEffectCreator::CreateFromXML(Ctx, pEffect, strPatternSubst(CONSTLIT("%d:e"), GetUNID()), &m_pEffect)) { Ctx.sError = strPatternSubst(CONSTLIT("energy field %x: Unable to load effect"), GetUNID()); return error; } } pEffect = pDesc->GetContentElementByTag(HIT_EFFECT_TAG); if (pEffect == NULL) pEffect = pDesc->GetContentElementByTag(EFFECT_WHEN_HIT_TAG); if (pEffect) { if (error = CEffectCreator::CreateFromXML(Ctx, pEffect, strPatternSubst(CONSTLIT("%d:h"), GetUNID()), &m_pHitEffect)) { Ctx.sError = strPatternSubst(CONSTLIT("energy field %x: Unable to load hit effect"), GetUNID()); return error; } // For compatibility with previous versions, if we're using the old // <ShipEnergyFieldType> then altEffect defaults to TRUE. Otherwise, for new // <OverlayType> altEffect defaults to false. bool bAltEffect; if (pEffect->FindAttributeBool(ALT_EFFECT_ATTRIB, &bAltEffect)) m_fAltHitEffect = bAltEffect; else m_fAltHitEffect = strEquals(pDesc->GetTag(), SHIP_ENERGY_FIELD_TYPE_TAG); } else m_fAltHitEffect = false; // Rotation m_fRotateWithShip = !pDesc->GetAttributeBool(IGNORE_SHIP_ROTATION_ATTRIB); // Damage adjustment int iAbsorbCount; LoadDamageAdj(pDesc, ABSORB_ADJ_ATTRIB, m_iAbsorbAdj, &iAbsorbCount); // Bonus adjustment LoadDamageAdj(pDesc, BONUS_ADJ_ATTRIB, m_iBonusAdj); // Load the weapon suppress if (error = m_WeaponSuppress.InitFromXML(pDesc->GetAttribute(WEAPON_SUPPRESS_ATTRIB))) { Ctx.sError = CONSTLIT("Unable to load weapon suppress attribute"); return error; } // Keep track of the events that we have m_fHasOnUpdateEvent = FindEventHandler(ON_UPDATE_EVENT); // Are we a field/shield overlay (or part of hull)? // By default, we are a shield overlay if we absorb damage. bool bValue; if (pDesc->FindAttributeBool(SHIELD_OVERLAY_ATTRIB, &bValue)) m_fShieldOverlay = bValue; else m_fShieldOverlay = (iAbsorbCount > 0); // Counter CXMLElement *pCounter = pDesc->GetContentElementByTag(COUNTER_TAG); if (pCounter) { CString sStyle = pCounter->GetAttribute(STYLE_ATTRIB); if (strEquals(sStyle, COUNTER_PROGRESS)) m_iCounterType = counterProgress; else if (strEquals(sStyle, COUNTER_RADIUS)) m_iCounterType = counterRadius; else { Ctx.sError = strPatternSubst(CONSTLIT("Unknown counter style: %s"), sStyle); return ERR_FAIL; } m_sCounterLabel = pCounter->GetAttribute(LABEL_ATTRIB); m_iCounterMax = pCounter->GetAttributeIntegerBounded(MAX_ATTRIB, 0, -1, 100); m_wCounterColor = ::LoadRGBColor(pCounter->GetAttribute(COLOR_ATTRIB)); } else { m_iCounterType = counterNone; m_iCounterMax = 0; m_wCounterColor = 0; } // Options m_fDisarmShip = pDesc->GetAttributeBool(DISARM_ATTRIB); m_fParalyzeShip = pDesc->GetAttributeBool(PARALYZE_ATTRIB); m_fDisableShipScreen = pDesc->GetAttributeBool(DISABLE_SHIP_SCREEN_ATTRIB); m_fSpinShip = pDesc->GetAttributeBool(SPIN_ATTRIB); int iDrag; if (pDesc->FindAttributeInteger(DRAG_ATTRIB, &iDrag)) m_rDrag = Min(Max(0, iDrag), 100) / 100.0; else m_rDrag = 1.0; // Done return NOERROR; }