mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Added GtxdFile.cs and placeholder for loading dlc gtxd.meta
This commit is contained in:
parent
54acb80033
commit
a2bd06f9ce
@ -262,6 +262,7 @@
|
||||
<Compile Include="GameFiles\FileTypes\CutFile.cs" />
|
||||
<Compile Include="GameFiles\FileTypes\DlcContentFile.cs" />
|
||||
<Compile Include="GameFiles\FileTypes\DlcSetupFile.cs" />
|
||||
<Compile Include="GameFiles\FileTypes\GtxdFile.cs" />
|
||||
<Compile Include="GameFiles\FileTypes\Gxt2File.cs" />
|
||||
<Compile Include="GameFiles\FileTypes\JPsoFile.cs" />
|
||||
<Compile Include="GameFiles\FileTypes\RelFile.cs" />
|
||||
|
140
GameFiles/FileTypes/GtxdFile.cs
Normal file
140
GameFiles/FileTypes/GtxdFile.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeWalker.GameFiles
|
||||
{
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))] public class GtxdFile : GameFile, PackedFile
|
||||
{
|
||||
|
||||
public RbfFile Rbf { get; set; }
|
||||
|
||||
|
||||
public Dictionary<string, string> CMapParentTxds { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public GtxdFile() : base(null, GameFileType.Gtxd)
|
||||
{
|
||||
}
|
||||
public GtxdFile(RpfFileEntry entry) : base(entry, GameFileType.Gtxd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Load(byte[] data, RpfFileEntry entry)
|
||||
{
|
||||
RpfFileEntry = entry;
|
||||
Name = entry.Name;
|
||||
FilePath = Name;
|
||||
|
||||
|
||||
if (entry.NameLower.EndsWith(".ymt"))
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
if (RbfFile.IsRBF(ms))
|
||||
{
|
||||
Rbf = new RbfFile();
|
||||
var rbfstruct = Rbf.Load(ms);
|
||||
|
||||
if (rbfstruct.Name == "CMapParentTxds")
|
||||
{
|
||||
LoadMapParentTxds(rbfstruct);
|
||||
}
|
||||
|
||||
Loaded = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//not an RBF file...
|
||||
}
|
||||
}
|
||||
else if (entry.NameLower.EndsWith(".meta"))
|
||||
{
|
||||
string xml = Encoding.UTF8.GetString(data);
|
||||
LoadMapParentTxds(xml);
|
||||
Loaded = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void LoadMapParentTxds(RbfStructure rbfstruct)
|
||||
{
|
||||
|
||||
CMapParentTxds = new Dictionary<string, string>();
|
||||
//StringBuilder sblist = new StringBuilder();
|
||||
foreach (var child in rbfstruct.Children)
|
||||
{
|
||||
var childstruct = child as RbfStructure;
|
||||
if ((childstruct != null) && (childstruct.Name == "txdRelationships"))
|
||||
{
|
||||
foreach (var txdrel in childstruct.Children)
|
||||
{
|
||||
var txdrelstruct = txdrel as RbfStructure;
|
||||
if ((txdrelstruct != null) && (txdrelstruct.Name == "item"))
|
||||
{
|
||||
string parentstr = string.Empty;
|
||||
string childstr = string.Empty;
|
||||
foreach (var item in txdrelstruct.Children)
|
||||
{
|
||||
var itemstruct = item as RbfStructure;
|
||||
if ((itemstruct != null))
|
||||
{
|
||||
var strbytes = itemstruct.Children[0] as RbfBytes;
|
||||
string thisstr = string.Empty;
|
||||
if (strbytes != null)
|
||||
{
|
||||
thisstr = Encoding.ASCII.GetString(strbytes.Value).Replace("\0", "");
|
||||
}
|
||||
switch (item.Name)
|
||||
{
|
||||
case "parent":
|
||||
parentstr = thisstr;
|
||||
break;
|
||||
case "child":
|
||||
childstr = thisstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ((!string.IsNullOrEmpty(parentstr)) && (!string.IsNullOrEmpty(childstr)))
|
||||
{
|
||||
if (!CMapParentTxds.ContainsKey(childstr))
|
||||
{
|
||||
CMapParentTxds.Add(childstr, parentstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
//sblist.AppendLine(childstr + ": " + parentstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//string alltxdmap = sblist.ToString();
|
||||
//if (!string.IsNullOrEmpty(alltxdmap))
|
||||
//{
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void LoadMapParentTxds(string xml)
|
||||
{
|
||||
//TODO...
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -69,6 +69,7 @@ namespace CodeWalker.GameFiles
|
||||
Rel = 13,
|
||||
Ywr = 14,
|
||||
Yvr = 15,
|
||||
Gtxd = 16,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -940,9 +940,9 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
try
|
||||
{
|
||||
if (entry.NameLower == "gtxd.ymt")
|
||||
if ((entry.NameLower == "gtxd.ymt") || (entry.NameLower == "gtxd.meta"))
|
||||
{
|
||||
YmtFile ymt = RpfMan.GetFile<YmtFile>(entry);
|
||||
GtxdFile ymt = RpfMan.GetFile<GtxdFile>(entry);
|
||||
if (ymt.CMapParentTxds != null)
|
||||
{
|
||||
foreach (var kvp in ymt.CMapParentTxds)
|
||||
@ -959,9 +959,6 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (entry.NameLower == "gtxd.meta") //these still need to be handled!
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -973,25 +970,39 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
if (EnableDlc)
|
||||
{
|
||||
//foreach (var dlcfile in DlcActiveRpfs)
|
||||
//{
|
||||
// foreach (RpfEntry entry in dlcfile.AllEntries)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (entry.NameLower == "gtxd.meta") //these still need to be handled!
|
||||
// {
|
||||
// //update\x64\dlcpacks\mpheist\dlc.rpf
|
||||
// //update\x64\dlcpacks\mpluxe\dlc.rpf
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// string errstr = entry.Path + "\n" + ex.ToString();
|
||||
// ErrorLog(errstr);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
foreach (var dlcfile in DlcActiveRpfs)
|
||||
{
|
||||
foreach (RpfEntry entry in dlcfile.AllEntries)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (entry.NameLower == "gtxd.meta")
|
||||
{
|
||||
GtxdFile ymt = RpfMan.GetFile<GtxdFile>(entry);
|
||||
if (ymt.CMapParentTxds != null)
|
||||
{
|
||||
foreach (var kvp in ymt.CMapParentTxds)
|
||||
{
|
||||
uint chash = JenkHash.GenHash(kvp.Key.ToLowerInvariant());
|
||||
uint phash = JenkHash.GenHash(kvp.Value.ToLowerInvariant());
|
||||
if (!parentTxds.ContainsKey(chash))
|
||||
{
|
||||
parentTxds.Add(chash, phash);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string errstr = entry.Path + "\n" + ex.ToString();
|
||||
ErrorLog(errstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user