private void CheckForAvailablePatch(string FileName, ref RouteData Data, ref Expression[] Expressions, bool PreviewOnly) { if (Plugin.CurrentOptions.EnableBveTsHacks == false) { return; } string fileHash = GetChecksum(FileName); if (availableRoutefilePatches.ContainsKey(fileHash)) { RoutefilePatch patch = availableRoutefilePatches[fileHash]; Data.LineEndingFix = patch.LineEndingFix; Data.IgnorePitchRoll = patch.IgnorePitchRoll; if (!string.IsNullOrEmpty(patch.LogMessage)) { Plugin.CurrentHost.AddMessage(MessageType.Warning, false, patch.LogMessage); } EnabledHacks.CylinderHack = patch.CylinderHack; EnabledHacks.DisableSemiTransparentFaces = patch.DisableSemiTransparentFaces; Data.AccurateObjectDisposal = patch.AccurateObjectDisposal; for (int i = 0; i < patch.ExpressionFixes.Count; i++) { Expressions[patch.ExpressionFixes.ElementAt(i).Key].Text = patch.ExpressionFixes.ElementAt(i).Value; } if (patch.XParser != null) { Plugin.CurrentOptions.CurrentXParser = (XParsers)patch.XParser; } Plugin.CurrentOptions.Derailments = patch.Derailments; Plugin.CurrentOptions.Toppling = patch.Toppling; SplitLineHack = patch.SplitLineHack; AllowTrackPositionArguments = patch.AllowTrackPositionArguments; foreach (int i in patch.DummyRailTypes) { if (Data.Structure.RailObjects == null) { Data.Structure.RailObjects = new ObjectDictionary(); } Data.Structure.RailObjects.Add(i, new StaticObject(Plugin.CurrentHost)); } foreach (int i in patch.DummyGroundTypes) { if (Data.Structure.Ground == null) { Data.Structure.Ground = new ObjectDictionary(); } Data.Structure.Ground.Add(i, new StaticObject(Plugin.CurrentHost)); } if (!string.IsNullOrEmpty(patch.CompatibilitySignalSet) && !PreviewOnly) { CompatibilitySignalObject.ReadCompatibilitySignalXML(Plugin.CurrentHost, patch.CompatibilitySignalSet, out Data.CompatibilitySignals, out CompatibilityObjects.SignalPost, out Data.SignalSpeeds); } } }
internal static void ParsePatchNode(XmlNode node, ref Dictionary <string, RoutefilePatch> routeFixes) { RoutefilePatch currentPatch = new RoutefilePatch(); string currentHash = string.Empty; foreach (XmlElement childNode in node.ChildNodes.OfType <XmlElement>()) { string t; switch (childNode.Name) { case "Hash": currentHash = childNode.InnerText; break; case "FileName": currentPatch.FileName = childNode.InnerText; break; case "LineEndingFix": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.LineEndingFix = true; } else { currentPatch.LineEndingFix = false; } break; case "IgnorePitchRoll": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.IgnorePitchRoll = true; } else { currentPatch.IgnorePitchRoll = false; } break; case "LogMessage": currentPatch.LogMessage = childNode.InnerText; break; case "CylinderHack": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.CylinderHack = true; } else { currentPatch.CylinderHack = false; } break; case "Expression": t = childNode.Attributes["Number"].InnerText; int expressionNumber; if (NumberFormats.TryParseIntVb6(t, out expressionNumber)) { currentPatch.ExpressionFixes.Add(expressionNumber, childNode.InnerText); } break; case "XParser": switch (childNode.InnerText.ToLowerInvariant()) { case "original": currentPatch.XParser = XParsers.Original; break; case "new": currentPatch.XParser = XParsers.NewXParser; break; case "assimp": currentPatch.XParser = XParsers.Assimp; break; } break; case "DummyRailTypes": string[] splitString = childNode.InnerText.Split(','); for (int i = 0; i < splitString.Length; i++) { int rt; if (NumberFormats.TryParseIntVb6(splitString[i], out rt)) { currentPatch.DummyRailTypes.Add(rt); } } break; case "DummyGroundTypes": splitString = childNode.InnerText.Split(','); for (int i = 0; i < splitString.Length; i++) { int gt; if (NumberFormats.TryParseIntVb6(splitString[i], out gt)) { currentPatch.DummyGroundTypes.Add(gt); } } break; case "Derailments": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "0" || t == "false") { currentPatch.Derailments = false; } else { currentPatch.Derailments = true; } break; case "Toppling": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "0" || t == "false") { currentPatch.Derailments = false; } else { currentPatch.Derailments = true; } break; case "SignalSet": string signalFile = Path.CombineFile(Plugin.FileSystem.GetDataFolder("Compatibility\\Signals"), childNode.InnerText.Trim()); if (File.Exists(signalFile)) { currentPatch.CompatibilitySignalSet = signalFile; } break; case "AccurateObjectDisposal": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.AccurateObjectDisposal = true; } else { currentPatch.AccurateObjectDisposal = false; } break; case "SplitLineHack": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.SplitLineHack = true; } else { currentPatch.SplitLineHack = false; } break; case "AllowTrackPositionArguments": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.AllowTrackPositionArguments = true; } else { currentPatch.AllowTrackPositionArguments = false; } break; case "DisableSemiTransparentFaces": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.DisableSemiTransparentFaces = true; } else { currentPatch.DisableSemiTransparentFaces = false; } break; case "ReducedColorTransparency": t = childNode.InnerText.Trim().ToLowerInvariant(); if (t == "1" || t == "true") { currentPatch.ReducedColorTransparency = true; } else { currentPatch.ReducedColorTransparency = false; } break; } } if (!routeFixes.ContainsKey(currentHash)) { routeFixes.Add(currentHash, currentPatch); } else { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "The RoutePatches database contains a duplicate entry with hash " + currentHash); } }