static void FixPowersXmlUndefinedTechPrereqs(IO.XmlElementStream s, XML.BListXmlParams op, Engine.PhxEngineBuild build) { string xpath_target = string.Format( "/{0}/{1}/Attributes/TechPrereq", op.RootName, op.ElementName); XmlNodeList elements; if (build == Engine.PhxEngineBuild.Release) { elements = s.Document.SelectNodes(xpath_target); foreach (XmlElement e in elements) { if ( // UnscOdstDrop e.InnerText != "unsc_odst_upgrade1" && // CpgnOdstDrop e.InnerText != "cpgn_odst_upgrade" && // UnscCpgn13OrbitalBombard e.InnerText != "unsc_age4") { continue; } FixXmlTraceFixEvent(s, e, "Removing undefined TechPrereq from Power '{0}'", e.InnerText); var p = e.ParentNode; p.RemoveChild(e); } } }
bool ReadInternal() { bool result = true; if (ProgressOutput != null) { ProgressOutput.WriteLine("Trying to read source listing {0}...", mSourceFile); } if (!File.Exists(mSourceFile)) { result = false; } else { mPkgFile = new CaPackageFile(); using (var xml = new IO.XmlElementStream(mSourceFile, FileAccess.Read, this)) { xml.InitializeAtRootElement(); PkgDefinition.Serialize(xml); } } if (result == false) { if (ProgressOutput != null) { ProgressOutput.WriteLine("\tFailed!"); } } return(result); }
static void FixTacticsXmlBadActionWeaponNames(IO.XmlElementStream s, string name) { string xpath; XmlNodeList elements; // see: fx_proj_rocket_01,02,03 xpath = "Action[contains(Weapon, '>')]"; elements = s.Cursor.SelectNodes(xpath); if (elements.Count > 0) { foreach (XmlElement e in elements) { var fc = e["Weapon"].FirstChild; fc.Value = fc.Value.Substring(1); } FixTacticsTraceFixEvent(s, name, xpath); return; } // see: pow_gp_rage_impact if (gRemoveUndefined) { xpath = "Action[Weapon='RageShockwave']"; elements = s.Cursor.SelectNodes(xpath); if (RemoveAllElements(elements)) { FixTacticsTraceFixEvent(s, name, xpath); return; } } }
bool ReadInternal() { bool result = true; if (ProgressOutput != null) { ProgressOutput.WriteLine("Trying to read source listing {0}...", mSourceFile); } if (!File.Exists(mSourceFile)) { result = false; } else { mEraFile = new EraFile(); mEraFile.BuildModeDefaultTimestamp = EraFile.GetMostRecentTimeStamp(mSourceFile); using (var xml = new IO.XmlElementStream(mSourceFile, FA.Read, this)) { xml.InitializeAtRootElement(); result &= mEraFile.ReadDefinition(xml); } } if (result == false) { if (ProgressOutput != null) { ProgressOutput.WriteLine("\tFailed!"); } } return(result); }
private void WriteChunks(IO.XmlElementStream s) { for (int x = FileChunksFirstIndex; x < mFiles.Count; x++) { mFiles[x].Write(s, false); } }
static void FixObjectsXmlInvalidSoundsPowGpWave(IO.XmlElementStream s, XmlNode node) { //Birth->Exist var nodes = node.ChildNodes; foreach (XmlNode element in nodes) { if (element.Name == "Sound") { var en = (XmlElement)element; if (!en.HasAttribute("Type")) { continue; } var typeAttr = en.GetAttributeNode("Type"); if (typeAttr.Value != "Birth") { continue; } typeAttr.Value = "Exist"; } } }
void Encode() { var metadata = KBlam.RuntimeData.ContentMiniMetadata.Create(mGameBranchHandle); string xml_filename = Path.Combine(mOutputPath, mMiniMetadata) + kNameExtension; if (!File.Exists(xml_filename)) { Console.WriteLine("Error: metadata xml does not exist in source directory {0}", xml_filename); return; } using (var xml = new IO.XmlElementStream(xml_filename)) { xml.InitializeAtRootElement(); xml.StreamMode = FileAccess.Read; metadata.Serialize(xml); } if (metadata.BuildHandle != mGameBranchHandle) { Console.WriteLine("Error: {0}'s game parameter '{1}' differs from what you gave me. Weak sauce", xml_filename, metadata.BuildHandle); return; } Console.WriteLine("New mini metadata:"); Console.WriteLine(metadata.Encode()); }
void AttributesToXml(BinaryDataTree tree, IO.XmlElementStream s) { if (NameValues == null || NameValues.Count <= 1) { return; } if (tree.DecompileAttributesWithTypeData) { using (s.EnterCursorBookmark("Attributes")) { for (int x = 1; x < NameValues.Count; x++) { var name_value = NameValues[x]; using (s.EnterCursorBookmark(name_value.Name)) name_value.Variant.ToStream(s); } } } else { for (int x = 1; x < NameValues.Count; x++) { var name_value = NameValues[x]; name_value.Variant.ToStreamAsAttribute(name_value.Name, s); } } }
// Remove non-existent ProtoTechs that are referenced by effects static void FixTechsXmlEffectsInvalid(IO.XmlElementStream s, XML.BListXmlParams op, Engine.PhxEngineBuild build) { string xpath_target = string.Format( "/{0}/{1}/Effects/Effect/Target", op.RootName, op.ElementName); XmlNodeList elements; if (build == Engine.PhxEngineBuild.Release) { elements = s.Document.SelectNodes(xpath_target); foreach (XmlElement e in elements) { if (e.InnerText != "unsc_turret_upgrade3") { continue; } FixXmlTraceFixEvent(s, e, "Removing undefined Target from Tech Effect", e.InnerText); var p = e.ParentNode; p.ParentNode.RemoveChild(p); } } }
protected override void FixGameDataXml(IO.XmlElementStream s) { string xpath = null; XmlNodeList elements = null; #region Fix LeaderPowerChargeResource if (gRemoveUndefined) { xpath = "LeaderPowerChargeResource"; elements = s.Cursor.SelectNodes(xpath); if (elements.Count > 0) { foreach (XmlElement e in elements) { if (e.InnerText != "LeaderPowerCharge") { continue; } Debug.Trace.XML.TraceEvent(System.Diagnostics.TraceEventType.Warning, TypeExtensions.kNone, "Fixing GameData XPath={0}"); e.InnerText = ""; } } } #endregion FixGameDataXmlInfectionMap(Database.Engine.Build, s); FixGameDataAmbientLife(s); }
static void RemoveAllButTheLastElement(IO.XmlElementStream s, XmlElement node, string elementName) { if (node == null) { return; } XmlElement prevNode = null; foreach (XmlNode n in node.ChildNodes) { if (!(n is XmlElement) || n.Name != elementName) { continue; } if (prevNode == null) { prevNode = (XmlElement)n; continue; } FixXmlTraceFixEvent(s, node, "Removing duplicate node {0}", n.Name); node.RemoveChild(prevNode); } }
/// <remarks>For streaming directly from weapontypes.xml</remarks> void StreamXmlWeaponTypes(IO.XmlElementStream s) { XmlUtil.Serialize(s, Database.WeaponTypes, Phx.BWeaponType.kBListXmlParams, ForceNoRootElementStreaming); if (s.IsReading) { FixWeaponTypes(); } }
/// <remarks>For streaming directly from powers.xml</remarks> void StreamXmlPowers(IO.XmlElementStream s) { if (s.IsReading) { FixPowersXml(s); } XmlUtil.Serialize(s, mPowersSerializer, ForceNoRootElementStreaming); }
/// <remarks>For streaming directly from techs_update.xml</remarks> void StreamXmlTechsUpdate(IO.XmlElementStream s) { if (s.IsReading) { FixTechsXml(s); } XmlUtil.SerializeUpdate(s, mTechsSerializer, ForceNoRootElementStreaming); }
void StreamTactic(IO.XmlElementStream s, Phx.BTacticData tactic) { if (s.IsReading && IsNotPreloading) { FixTacticsXml(s, tactic.Name); } tactic.Serialize(s); }
static void FixObjectsXmlInvalidLifeSpan(IO.XmlElementStream s, params string[] objectNames) { foreach (string name in objectNames) { var node = XPathSelectNodeByName(s, Phx.BProtoObject.kBListXmlParams, name); FixObjectXmlInvalidLifeSpan(s.Document, node); } }
/// <remarks>For streaming directly from gamedata.xml</remarks> void StreamXmlGameData(IO.XmlElementStream s) { if (s.IsReading) { FixGameDataXml(s); } Database.GameData.StreamGameData(s); }
static void SetupStream(IO.XmlElementStream s, FA mode, XML.BXmlSerializerInterface xs) { s.IgnoreCaseOnEnums = true; s.ExceptionOnEnumParseFail = true; s.StreamMode = mode; s.InitializeAtRootElement(); s.SetSerializerInterface(xs); }
protected void ReadFlags(IO.XmlElementStream s) { var compType = EcfCompressionType.Stored; if (s.ReadAttributeEnumOpt("Compression", ref compType)) { CompressionType = compType; } }
static void FixSquadsXmlSounds(IO.XmlElementStream s) { XmlNode node; node = XPathSelectNodeByName(s, Phx.BProtoSquad.kBListXmlParams, "cov_veh_bruteChopper_01"); FixSquadsXmlSoundsKillEnemy(node); node = XPathSelectNodeByName(s, Phx.BProtoSquad.kBListXmlParams, "cov_veh_ghost_01"); FixSquadsXmlSoundsKillEnemy(node); }
protected void WriteFlags(IO.XmlElementStream s) { if (Flags == 0) { return; } s.WriteAttributeEnum("Compression", CompressionType); }
/// <remarks>For streaming directly from objects.xml</remarks> void StreamXmlObjects(IO.XmlElementStream s) { if (s.IsReading) { FixObjectsXml(s); } XmlUtil.Serialize(s, mObjectsSerializer, ForceNoRootElementStreaming); }
public void WriteDefinition(IO.XmlElementStream s) { using (s.EnterCursorBookmark("Files")) WriteChunks(s); using (var bm = s.EnterCursorBookmarkOpt("LocalFiles", mLocalFiles, Predicates.HasItems)) if (bm.IsNotNull) { WriteLocalFiles(s); } }
void InnerTextToXml(IO.XmlElementStream s) { var inner_text_variant = NodeVariant; if (inner_text_variant.Type == BinaryDataTreeVariantType.Null) { return; } inner_text_variant.ToStream(s); }
static void FixObjectsXmlInvalidSingles(Engine.PhxEngineBuild build, IO.XmlElementStream s) { if (build == Engine.PhxEngineBuild.Alpha) { FixObjectsXmlInvalidSinglesAlpha(s); } else { FixObjectsXmlInvalidSinglesCobra(s); } }
static void FixSquadsXmlAphaUndefinedObjects(IO.XmlElementStream s, params string[] squadNames) { foreach (string name in squadNames) { var node = XPathSelectNodeByName(s, Phx.BProtoSquad.kBListXmlParams, name); if (node != null) { node.ParentNode.RemoveChild(node); } } }
/// <remarks>For streaming directly from squads.xml</remarks> void StreamXmlSquads(IO.XmlElementStream s) { if (s.IsReading) { FixSquadsXml(s); } XmlUtil.Serialize(s, mSquadsSerializer, ForceNoRootElementStreaming); XML.XmlUtil.Serialize(s, Database.MergedSquads, Phx.BProtoMergedSquads.kBListXmlParams); Database.ShieldBubbleTypes.Serialize(s); }
static void FixSquadsXmlAlpha(IO.XmlElementStream s) { if (gRemoveUndefined) { FixSquadsXmlAphaUndefinedObjects(s, "unsc_air_shortsword_01", "unsc_con_turret_01", "unsc_con_base_01", "cov_inf_kamikazeGrunt_01", // needs to be 'cpgn_inf_kamikazegrunt_01', but f**k updating it "cov_con_turret_01", "cov_con_node_01", "cov_con_base_01" ); } FixSquadsXmlAlphaCostElements(s); }
protected override void FixSquadsXml(IO.XmlElementStream s) { if (Database.Engine.Build == Engine.PhxEngineBuild.Alpha) { FixSquadsXmlAlpha(s); } else { FixSquadsXmlSounds(s); FixSquadsXml_for_air_sentinel_03(s, (XmlElement)XPathSelectNodeByName(s, Phx.BProtoSquad.kBListXmlParams, "for_air_sentinel_03")); } }
static void FixGameDataXmlInfectionMap(Engine.PhxEngineBuild build, IO.XmlElementStream s) { string xpath; XmlNodeList elements; if (!ToLowerName(Phx.DatabaseObjectKind.Object)) { xpath = "InfectionMap/InfectionMapEntry[contains(@base, 'needlergrunt')]"; elements = s.Cursor.SelectNodes(xpath); if (elements.Count > 0) { foreach (XmlElement e in elements) { var attr = e.Attributes["base"]; attr.Value = attr.Value.Replace("needlergrunt", "needlerGrunt"); } } FixGameDataXmlInfectionMapEntryInfected(s, "fld_inf_InfectedBrute_01"); FixGameDataXmlInfectionMapEntryInfected(s, "fld_inf_InfectedJackal_01"); FixGameDataXmlInfectionMapEntryInfected(s, "fld_inf_InfectedGrunt_01"); } if (!ToLowerName(Phx.DatabaseObjectKind.Squad)) { xpath = "InfectionMap/InfectionMapEntry[contains(@infectedSquad, '_Inf')]"; elements = s.Cursor.SelectNodes(xpath); if (elements.Count > 0) { foreach (XmlElement e in elements) { var attr = e.Attributes["infectedSquad"]; attr.Value = attr.Value.Replace("_Inf", "_inf"); } } } #region Alpha only if (build == Engine.PhxEngineBuild.Alpha) { xpath = "InfectionMap/InfectionMapEntry[contains(@base, 'unsc_inf_heavymarine_01')]"; elements = s.Cursor.SelectNodes(xpath); if (elements.Count > 0) { foreach (XmlElement e in elements) { e.ParentNode.RemoveChild(e); } } } #endregion }