Skip to content

Commit

Permalink
Add .yld support
Browse files Browse the repository at this point in the history
  • Loading branch information
indilo53 committed May 6, 2019
1 parent 6b00768 commit ea65791
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
59 changes: 31 additions & 28 deletions gtautil/Program/GenPedDefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,20 +354,17 @@ static void HandleGenPedDefsOptions(string[] args)
if (Directory.Exists(targetDirectory))
{
string[] addonFiles = Directory.GetFiles(targetDirectory).Where(e => e.EndsWith(".ydd")).ToArray();
string[] addonFiles = Directory.GetFiles(targetDirectory).Where(e => e.EndsWith(".ydd")).OrderBy(e => e).ToArray();
var addons = new List<int>();
for (int k = 0; k < addonFiles.Length; k++)
{
string numStr = addonFiles[k].Substring(0, addonFiles[k].Length - 4);
int num = int.Parse(numStr.Split('\\').Last());
addons.Add(num);
addons.Add(k);
}
if (addons.Count > 0)
{
addons.Sort();
// Create addon component entries
var def = ymt.Unk_376833625.Components[component] ?? new MUnk_3538495220();
Expand All @@ -377,22 +374,18 @@ static void HandleGenPedDefsOptions(string[] args)
string textureDirectory = targetDirectory + "\\" + addons[k];
var addonTextures = new List<int>();
var item = new MUnk_1535046754();
string[] textures = Directory.GetFiles(textureDirectory).Where(e => e.EndsWith(".ytd")).ToArray();
string[] textures = Directory.GetFiles(textureDirectory).Where(e => e.EndsWith(".ytd")).OrderBy(e => e).ToArray();
string yddFileName = prefix + "_" + addonPos.ToString().PadLeft(3, '0') + "_u.ydd";
cYddMapping[targetDirectory + "\\" + addons[k] + ".ydd"] = new Tuple<string, int, int, int, string, string>(prefix, addons[k], addonPos, addons.Count, targetDirectory, yddFileName);
cYddMapping[addonFiles[k]] = new Tuple<string, int, int, int, string, string>(prefix, addons[k], addonPos, addons.Count, targetDirectory, yddFileName);
// Create addon texture entries
for (int l = 0; l < textures.Length; l++)
{
string numStr = textures[l].Substring(0, textures[l].Length - 4).Split('\\').Last();
int num = int.Parse(numStr);
addonTextures.Add(num);
addonTextures.Add(l);
}
addonTextures.Sort();
cTextureCount[targetDirectory + "\\" + addons[k] + ".ydd"] = addonTextures.Count;
cTextureCount[addonFiles[k]] = addonTextures.Count;
for (int l = 0; l < addonTextures.Count; l++)
{
Expand All @@ -409,6 +402,11 @@ static void HandleGenPedDefsOptions(string[] args)
ymt.Unk_376833625.CompInfos.Add(cInfo);
}
if(File.Exists(addonFiles[k].Replace(".ydd", ".yld")))
{
item.ClothData.Unk_2828247905 = 1;
}
def.Unk_1756136273.Add(item);
cCount[component]++;
Expand All @@ -429,20 +427,16 @@ static void HandleGenPedDefsOptions(string[] args)
if (Directory.Exists(targetDirectory))
{
string[] addonFiles = Directory.GetFiles(targetDirectory).Where(e => e.EndsWith(".ydd")).ToArray();
string[] addonFiles = Directory.GetFiles(targetDirectory).Where(e => e.EndsWith(".ydd")).OrderBy(e => e).ToArray();
var addons = new List<int>();
for (int k = 0; k < addonFiles.Length; k++)
{
string numStr = addonFiles[k].Substring(0, addonFiles[k].Length - 4);
int num = int.Parse(numStr.Split('\\').Last());
addons.Add(num);
addons.Add(k);
}
if (addons.Count > 0)
{
addons.Sort();
// Create addon prop entries
var defs = ymt.Unk_376833625.PropInfo.Props[anchor] ?? new List<MUnk_94549140>();
Expand All @@ -452,24 +446,20 @@ static void HandleGenPedDefsOptions(string[] args)
string textureDirectory = targetDirectory + "\\" + addons[k];
var addonTextures = new List<int>();
var item = new MUnk_94549140(ymt.Unk_376833625.PropInfo);
string[] textures = Directory.GetFiles(textureDirectory).Where(e => e.EndsWith(".ytd")).ToArray();
string[] textures = Directory.GetFiles(textureDirectory).Where(e => e.EndsWith(".ytd")).OrderBy(e => e).ToArray();
string yddFileName = "p_" + prefix + "_" + addonPos.ToString().PadLeft(3, '0') + ".ydd";
item.AnchorId = (byte)anchor;
pYddMapping[targetDirectory + "\\" + addons[k] + ".ydd"] = new Tuple<string, int, int, int, string, string>(prefix, addons[k], addonPos, addons.Count, targetDirectory, yddFileName);
pYddMapping[addonFiles[k]] = new Tuple<string, int, int, int, string, string>(prefix, addons[k], addonPos, addons.Count, targetDirectory, yddFileName);
// Create addon texture entries
for (int l = 0; l < textures.Length; l++)
{
string numStr = textures[l].Substring(0, textures[l].Length - 4).Split('\\').Last();
int num = int.Parse(numStr);
addonTextures.Add(num);
addonTextures.Add(l);
}
addonTextures.Sort();
pTextureCount[targetDirectory + "\\" + addons[k] + ".ydd"] = addonTextures.Count;
pTextureCount[addonFiles[k]] = addonTextures.Count;
for (int l = 0; l < addonTextures.Count; l++)
{
Expand Down Expand Up @@ -703,6 +693,7 @@ static void HandleGenPedDefsOptions(string[] args)
public static void GenPedDefs_CreateComponentFiles(GenPedDefsOptions opts, string targetDirName, KeyValuePair<string, Tuple<string, int, int, int, string, string>> entry, int textureCount)
{
string sourceYddFile = entry.Key;
string sourceYldFile = sourceYddFile.Replace(".ydd", ".yld");
string prefix = entry.Value.Item1;
int origPos = entry.Value.Item2;
int pos = entry.Value.Item3;
Expand All @@ -717,6 +708,12 @@ public static void GenPedDefs_CreateComponentFiles(GenPedDefsOptions opts, strin

File.Copy(sourceYddFile, targetYddFile, true);

if(File.Exists(sourceYldFile))
{
string targetYldFile = targetYddFile.Replace(".ydd", ".yld");
File.Copy(sourceYldFile, targetYldFile, true);
}

int texCount = 0;

for (int k = pos; k < textureCount + pos; k++)
Expand Down Expand Up @@ -778,6 +775,7 @@ public static void GenPedDefs_CreatePropFiles(GenPedDefsOptions opts, string tar
public static void GenPedDefs_CreateComponentFiles_FiveM(GenPedDefsOptions opts, string targetFileName, KeyValuePair<string, Tuple<string, int, int, int, string, string>> entry, int textureCount)
{
string sourceYddFile = entry.Key;
string sourceYldFile = sourceYddFile.Replace(".ydd", ".yld");
string prefix = entry.Value.Item1;
int origPos = entry.Value.Item2;
int pos = entry.Value.Item3;
Expand All @@ -789,6 +787,11 @@ public static void GenPedDefs_CreateComponentFiles_FiveM(GenPedDefsOptions opts,

File.Copy(sourceYddFile, targetYddFile, true);

if (File.Exists(sourceYldFile))
{
string targetYldFile = targetYddFile.Replace(".ydd", ".yld");
File.Copy(sourceYldFile, targetYldFile, true);
}
int texCount = 0;

for (int k = pos; k < textureCount + pos; k++)
Expand Down
2 changes: 1 addition & 1 deletion gtautil/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.1.2.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit ea65791

Please sign in to comment.