private static void ReadReflexive(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine) { if (!reader.MoveToAttribute("entrySize")) { throw new ArgumentException("Reflexives must have an entrySize attribute." + PositionInfo(reader)); } uint entrySize = ParseUInt(reader.Value); int align = 4; if (reader.MoveToAttribute("align")) { align = ParseInt(reader.Value); } if (visitor.EnterReflexive(name, offset, visible, entrySize, align, pluginLine)) { reader.MoveToElement(); XmlReader subtree = reader.ReadSubtree(); subtree.ReadStartElement(); ReadElements(subtree, false, visitor); visitor.LeaveReflexive(); } else { reader.Skip(); } }
private void WritePlugin(MetaMap map, int size, IPluginVisitor writer) { for (int offset = 0; offset < size; offset += 4) { MetaValueGuess guess = map.GetGuess(offset); if (guess != null) { switch (guess.Type) { case MetaValueType.DataReference: if (offset <= size - 0x14) { writer.VisitDataReference("Unknown", (uint)offset, "bytes", false, 4, 0); offset += 0x10; continue; } break; case MetaValueType.TagReference: if (offset <= size - 0x10) { writer.VisitTagReference("Unknown", (uint)offset, false, true, true, 0); offset += 0xC; continue; } break; case MetaValueType.Reflexive: if (offset <= size - 0xC) { MetaMap subMap = map.GetSubMap(offset); if (subMap != null) { int subMapSize = subMap.GetBestSizeEstimate(); writer.EnterReflexive("Unknown", (uint)offset, false, (uint)subMapSize, 4, 0); WritePlugin(subMap, subMapSize, writer); writer.LeaveReflexive(); offset += 0x8; continue; } } break; } } // Just write an unknown value depending upon how much space we have left if (offset <= size - 4) { writer.VisitUndefined("Unknown", (uint)offset, false, 0); } else if (offset <= size - 2) { writer.VisitInt16("Unknown", (uint)offset, false, 0); } else { writer.VisitInt8("Unknown", (uint)offset, false, 0); } } }
private void ReadReflexive(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine) { uint entrySize = 0; if (reader.MoveToAttribute("entrySize") || reader.MoveToAttribute("size")) { if (!string.IsNullOrWhiteSpace(reader.Value)) { entrySize = ParseUInt(reader.Value); } } int align = 4; if (reader.MoveToAttribute("align")) { align = ParseInt(reader.Value); } if (visitor.EnterReflexive(name, offset, visible, entrySize, align, pluginLine)) { reader.MoveToElement(); XmlReader subtree = reader.ReadSubtree(); subtree.ReadStartElement(); ReadElements(subtree, false, visitor); visitor.LeaveReflexive(); } }
private static void ReadReflexive(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine) { if (!reader.MoveToAttribute("entrySize")) throw new ArgumentException("Reflexives must have an entrySize attribute." + PositionInfo(reader)); var entrySize = ParseUInt(reader.Value); if (visitor.EnterReflexive(name, offset, visible, entrySize, pluginLine)) { reader.MoveToElement(); var subtree = reader.ReadSubtree(); subtree.ReadStartElement(); ReadElements(subtree, false, visitor); visitor.LeaveReflexive(); } else { reader.Skip(); } }
private void ReadReflexive(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine) { uint entrySize = 0; if (reader.MoveToAttribute("entrySize") || reader.MoveToAttribute("size")) { if (!string.IsNullOrWhiteSpace(reader.Value)) entrySize = ParseUInt(reader.Value); } if (visitor.EnterReflexive(name, offset, visible, entrySize, pluginLine)) { reader.MoveToElement(); XmlReader subtree = reader.ReadSubtree(); subtree.ReadStartElement(); ReadElements(subtree, false, visitor); visitor.LeaveReflexive(); } }
private void WritePlugin(MetaMap map, int size, IPluginVisitor writer) { for (int offset = 0; offset < size; offset += 4) { MetaValueGuess guess = map.GetGuess(offset); if (guess != null) { switch (guess.Type) { case MetaValueType.DataReference: if (offset <= size - 0x14) { writer.VisitDataReference("Unknown", (uint) offset, "bytes", false, 4, 0); offset += 0x10; continue; } break; case MetaValueType.TagReference: if (offset <= size - 0x10) { writer.VisitTagReference("Unknown", (uint) offset, false, true, true, 0); offset += 0xC; continue; } break; case MetaValueType.Reflexive: if (offset <= size - 0xC) { MetaMap subMap = map.GetSubMap(offset); if (subMap != null) { int subMapSize = subMap.GetBestSizeEstimate(); writer.EnterReflexive("Unknown", (uint) offset, false, (uint)subMapSize, 4, 0); WritePlugin(subMap, subMapSize, writer); writer.LeaveReflexive(); offset += 0x8; continue; } } break; } } // Just write an unknown value depending upon how much space we have left if (offset <= size - 4) writer.VisitUndefined("Unknown", (uint) offset, false, 0); else if (offset <= size - 2) writer.VisitInt16("Unknown", (uint) offset, false, 0); else writer.VisitInt8("Unknown", (uint) offset, false, 0); } }