Skip to content

Commit

Permalink
Merge pull request #1 from emcifuntik/master
Browse files Browse the repository at this point in the history
Fixed ymt name
  • Loading branch information
indilo53 authored Aug 8, 2019
2 parents 2762fd3 + 3e0bbeb commit 371971e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
11 changes: 9 additions & 2 deletions RageLib.GTA5/ResourceWrappers/PC/Common/Convert/MetaXmlBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ public static void ErrorXml(StringBuilder sb, int indent, string msg)
sb.Append("</error>");
sb.AppendLine();
}
public static void OpenTag(StringBuilder sb, int indent, string name, bool appendLine = true)
public static void OpenTag(StringBuilder sb, int indent, string name, bool appendLine = true, string nameAttribute = "")
{
Indent(sb, indent);
sb.Append("<");
sb.Append(name);
sb.Append(">");
if (string.IsNullOrWhiteSpace(nameAttribute))
{
sb.Append(">");
}
else
{
sb.Append(" name=\"" + nameAttribute + "\">");
}
if (appendLine) sb.AppendLine();
}
public static void CloseTag(StringBuilder sb, int indent, string name, bool appendLine = true)
Expand Down
10 changes: 5 additions & 5 deletions RageLib.GTA5/ResourceWrappers/PC/Meta/Convert/MetaXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public static string GetXml(MetaFile meta)
{
var cont = new MetaCont(meta);

WriteNode(sb, 0, cont, meta.RootBlockIndex, 0, XmlTagMode.Structure);
WriteNode(sb, 0, cont, meta.RootBlockIndex, 0, XmlTagMode.Structure, 0, (string)meta.Name);
}

return sb.ToString();
}

private static void WriteNode(StringBuilder sb, int indent, MetaCont cont, int blockId, int offset, XmlTagMode tagMode = XmlTagMode.None, MetaName structName = 0)
private static void WriteNode(StringBuilder sb, int indent, MetaCont cont, int blockId, int offset, XmlTagMode tagMode = XmlTagMode.None, MetaName structName = 0, string metaName = "")
{

var block = cont.Meta.GetBlock(blockId);
Expand Down Expand Up @@ -80,13 +80,13 @@ private static void WriteNode(StringBuilder sb, int indent, MetaCont cont, int b
switch (tagMode)
{
case XmlTagMode.Structure:
OpenTag(sb, indent, name);
OpenTag(sb, indent, name, true, metaName);
break;
case XmlTagMode.Item:
OpenTag(sb, indent, "Item");
OpenTag(sb, indent, "Item", true, metaName);
break;
case XmlTagMode.ItemAndType:
OpenTag(sb, indent, "Item type=\"" + name + "\"");
OpenTag(sb, indent, "Item type=\"" + name + "\"", true, metaName);
break;
}

Expand Down
8 changes: 6 additions & 2 deletions RageLib.GTA5/ResourceWrappers/PC/Meta/Convert/XmlMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ public static MetaFile GetMeta(XmlDocument doc)

Traverse(doc.DocumentElement, mb, 0, true);

var meta = mb.GetMeta();
XmlNode metaName = doc.DocumentElement.Attributes.GetNamedItem("name");

return meta;
if(metaName != null)
return mb.GetMeta(metaName.Value);
else
return mb.GetMeta();

}

private static byte[] Traverse(XmlNode node, MetaBuilder mb, MetaName type = 0, bool isRoot = false)
Expand Down
4 changes: 3 additions & 1 deletion RageLib.GTA5/Resources/PC/Meta/MetaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void AddEnumInfo(MetaName name)



public MetaFile GetMeta()
public MetaFile GetMeta(string metaName = "")
{
MetaFile m = new MetaFile();
m.Unknown_10h = 0x50524430;
Expand Down Expand Up @@ -395,6 +395,8 @@ public MetaFile GetMeta()
}
m.DataBlocksCount = (short)m.DataBlocks.Count;

m.Name = (string_r)metaName;

return m;
}

Expand Down
2 changes: 1 addition & 1 deletion RageLib.GTA5/Resources/PC/Meta/MetaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public override void Write(ResourceDataWriter writer, params object[] parameters
this.StructureInfosPointer = this.StructureInfos?.Position ?? 0;
this.EnumInfosPointer = this.EnumInfos?.Position ?? 0;
this.DataBlocksPointer = this.DataBlocks?.Position ?? 0;
//this.NamePointer = this.Name?.Position ?? 0;
this.NamePointer = this.Name?.Position ?? 0;
this.UselessPointer = 0;
this.StructureInfosCount = (short)(this.StructureInfos?.Count ?? 0);
this.EnumInfosCount = (short)(this.EnumInfos?.Count ?? 0);
Expand Down
1 change: 1 addition & 0 deletions Tools/MetaTool/Lists/MetaNames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ CPedModelInfo__InitData
CPedModelInfo__InitDataList
CPedModelInfo__PersonalityDataList
CPedPropExpressionData
CPedPropInfo
CPedTargetEvaluator__Tunables
CPedTargetting__Tunables
CPlayerCoverClipVariationHelper__Tunables
Expand Down

0 comments on commit 371971e

Please sign in to comment.