Skip to content

Commit

Permalink
Minor changes + comment out portal extraction for now
Browse files Browse the repository at this point in the history
  • Loading branch information
indilo53 committed Oct 30, 2018
1 parent 93ef152 commit 481ed10
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 33 deletions.
2 changes: 2 additions & 0 deletions gtautil/Program/ExtractEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static void HandleExtractEntitiesOptions(string[] args)
ymap.Save(opts.Name + "\\" + room.Name + ".ymap");
}
/*
for(int portalId=0; portalId < mlo.Portals.Count; portalId++)
{
var portal = mlo.Portals[portalId];
Expand Down Expand Up @@ -200,6 +201,7 @@ static void HandleExtractEntitiesOptions(string[] args)
File.WriteAllText(opts.Name + "\\portal_" + portalId.ToString().PadLeft(3, '0') + ".json", jsonString);
}
*/
});
}
}
Expand Down
6 changes: 5 additions & 1 deletion gtautil/Program/Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ static void HandleGenericOptions(string[] args)
{
var name = Path.GetFileNameWithoutExtension(infos[i].Name);
var ext = Path.GetExtension(infos[i].Name);
if (ext.Length > 0)
ext = ext.Substring(1);
var hash = Jenkins.Hash(name.ToLowerInvariant());
switch (ext)
{
case ".ydr":
case "ydr":
{
var ydr = new YdrFile();
ydr.Load(infos[i].FullName);
Expand Down
86 changes: 58 additions & 28 deletions gtautil/Program/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Reflection;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq;
using RageLib.Hash;
using Newtonsoft.Json.Linq;
using RageLib.Archives;
using RageLib.GTA5.Archives;
using RageLib.GTA5.ArchiveWrappers;
using RageLib.GTA5.Cryptography;
using RageLib.GTA5.Cryptography.Helpers;
using RageLib.Resources.GTA5;
using RageLib.GTA5.ResourceWrappers.PC.Meta.Structures;
using RageLib.GTA5.Utilities;
using RageLib.GTA5.ArchiveWrappers;
using RageLib.Archives;
using RageLib.GTA5.Archives;
using System.Text;
using System.IO.Compression;
using RageLib.Hash;
using RageLib.Resources.GTA5.PC.Drawables;
using RageLib.Resources;
using RageLib.GTA5.ResourceWrappers.PC.Meta.Structures;
using RageLib.Resources.GTA5.PC.GameFiles;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;

namespace GTAUtil
{
Expand Down Expand Up @@ -297,34 +294,67 @@ public static string[] GetDLCList()
public static int GetDLCLevel(string path) // path must be a sub dir/file of the dlc
{
path = path.ToLowerInvariant();
var pathRegex = new Regex(@"\\dlcpacks\\([a-z0-9_]*)\\");
var pathRegex2 = new Regex(@"\\dlc_patch\\([a-z0-9_]*)\\");

var match = pathRegex.Match(path);
var match2 = pathRegex2.Match(path);
string[] split = path.Replace('/', '\\').Split('\\');

if (match.Success)
return Array.IndexOf(DLCList, match.Groups[1].Value);
else if (match2.Success)
return Array.IndexOf(DLCList, match2.Groups[1].Value);
if(split.Length == 1)
{
string name = Path.GetFileNameWithoutExtension(path);
string ext = Path.GetExtension(path);

if (ext.Length > 0)
ext = ext.Substring(1);

uint hash = Jenkins.Hash(name.ToLowerInvariant());

if(Files.ContainsKey(ext) && Files[ext].ContainsKey(hash))
{
Files[ext].TryGetValue(hash, out RpfFileEntry rpfFileEntry);
return rpfFileEntry.DlcLevel;
}
else
{
return 0;
}
}
else
return 0;
{
var pathRegex = new Regex(@"\\dlcpacks\\([a-z0-9_]*)\\");
var pathRegex2 = new Regex(@"\\dlc_patch\\([a-z0-9_]*)\\");

var match = pathRegex.Match(path);
var match2 = pathRegex2.Match(path);

if (match.Success)
return Array.IndexOf(DLCList, match.Groups[1].Value);
else if (match2.Success)
return Array.IndexOf(DLCList, match2.Groups[1].Value);
else
return 0;
}

}

public static Drawable GetDrawable(uint hash)
{
if (!(DrawableCache.TryGetValue(hash, out Drawable drawable)))
Drawable drawable = null;

if(!DrawableCache.ContainsKey(hash))
{
if ((Files["ydr"].TryGetValue(hash, out RpfFileEntry rpfFileEntry)))
if(Files.ContainsKey("ydr") && Files["ydr"].ContainsKey(hash))
{
Files["ydr"].TryGetValue(hash, out RpfFileEntry rpfFileEntry);

Utils.ForFile(rpfFileEntry.FullFileName, (file, encryption) =>
{
DrawableCache[hash] = Utils.GetResourceData<Drawable>((IArchiveResourceFile)file);
drawable = DrawableCache[hash];
});
}

}
else
{
drawable = DrawableCache[hash];
}

return drawable;
Expand Down
4 changes: 0 additions & 4 deletions gtautil/Program/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ static void HandleTestOptions(string[] args)
CommandLine.Parse<TestOptions>(args, (opts, gOpts) =>
{
Init(args);
var ybn = new YbnFile();
ybn.Load(@"C:\Users\NGD\Desktop\hei_heist_ornate_bank.ybn");
});
}
}
Expand Down

0 comments on commit 481ed10

Please sign in to comment.