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, 0, ""); offset += 0xC; continue; } break; case MetaValueType.TagBlock: if (offset <= size - 0xC) { MetaMap subMap = map.GetSubMap(offset); if (subMap != null) { int subMapSize = subMap.GetBestSizeEstimate(); writer.EnterTagBlock("Unknown", (uint)offset, false, (uint)subMapSize, 4, false, 0, ""); WritePlugin(subMap, subMapSize, writer); writer.LeaveTagBlock(); 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 static void ReadTagBlock(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine, string tooltip) { if (!reader.MoveToAttribute("elementSize") && !reader.MoveToAttribute("entrySize")) throw new ArgumentException("Tag Blocks must have an elementSize attribute." + PositionInfo(reader)); uint elementSize = ParseUInt(reader.Value); int align = 4; if (reader.MoveToAttribute("align")) align = ParseInt(reader.Value); bool sort = false; if (reader.MoveToAttribute("sort")) sort = ParseBool(reader.Value); if (visitor.EnterTagBlock(name, offset, visible, elementSize, align, sort, pluginLine, tooltip)) { reader.MoveToElement(); XmlReader subtree = reader.ReadSubtree(); subtree.ReadStartElement(); ReadElements(subtree, false, visitor); visitor.LeaveTagBlock(); } else { reader.Skip(); } }
private void ReadTagBlock(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine, string tooltip) { uint entrySize = 0; if (reader.MoveToAttribute("entrySize") || reader.MoveToAttribute("size") || reader.MoveToAttribute("elementSize")) { if (!string.IsNullOrWhiteSpace(reader.Value)) { entrySize = ParseUInt(reader.Value); } } int align = 4; if (reader.MoveToAttribute("align")) { align = ParseInt(reader.Value); } bool sort = false; if (reader.MoveToAttribute("sort")) { sort = ParseBool(reader.Value); } if (visitor.EnterTagBlock(name, offset, visible, entrySize, align, sort, pluginLine, tooltip)) { reader.MoveToElement(); XmlReader subtree = reader.ReadSubtree(); subtree.ReadStartElement(); ReadElements(subtree, false, visitor); visitor.LeaveTagBlock(); } }