Skip to content

Commit 8c7f90e

Browse files
committed
Get rid of JSON dependency
1 parent db83878 commit 8c7f90e

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

TACTSharp/Build.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Text.Json;
2-
using System.Text.Json.Nodes;
3-
using TACTSharp.Interfaces;
1+
using TACTSharp.Interfaces;
42

53
namespace TACTSharp
64
{
@@ -76,15 +74,18 @@ public void LoadConfigs(string buildConfig, string cdnConfig, string productConf
7674

7775
try
7876
{
79-
var parsedJSON = JsonSerializer.Deserialize<JsonNode>(ProductConfig);
80-
if (parsedJSON == null || parsedJSON["all"] == null || parsedJSON["all"]!["config"] == null)
81-
throw new Exception("Product config has missing keys");
82-
83-
if (parsedJSON["all"]!["config"]!["decryption_key_name"] != null && !string.IsNullOrEmpty(parsedJSON["all"]!["config"]!["decryption_key_name"]!.GetValue<string>()))
77+
if (ProductConfig.Contains("decryption_key_name"))
8478
{
85-
cdn.ArmadilloKeyName = parsedJSON["all"]!["config"]!["decryption_key_name"]!.GetValue<string>();
86-
if (Settings.LogLevel <= TSLogLevel.Info)
87-
Console.WriteLine("Set Armadillo key name to " + cdn.ArmadilloKeyName);
79+
var valueStart = ProductConfig.IndexOf("decryption_key_name") + 22; // +22 goes to start of value
80+
var valueEnd = ProductConfig.IndexOf('"', valueStart); // get next quote after value start
81+
var decryptionKeyName = ProductConfig[valueStart..valueEnd];
82+
83+
if (!string.IsNullOrEmpty(decryptionKeyName))
84+
{
85+
cdn.ArmadilloKeyName = decryptionKeyName;
86+
if (Settings.LogLevel <= TSLogLevel.Info)
87+
Console.WriteLine("Set Armadillo key name to " + cdn.ArmadilloKeyName);
88+
}
8889
}
8990
}
9091
catch (Exception ex)
@@ -202,7 +203,7 @@ public void Load()
202203

203204
if (!useTVFS)
204205
{
205-
var rootEncodingKeys = Encoding.FindContentKey(Convert.FromHexString(rootKey[0]));
206+
var rootEncodingKeys = Encoding.FindContentKey(Convert.FromHexString(rootKey![0]));
206207
if (!rootEncodingKeys)
207208
throw new Exception("Root key not found in encoding");
208209

@@ -245,9 +246,9 @@ public void Load()
245246
if (Settings.LogLevel <= TSLogLevel.Info)
246247
Console.WriteLine("TVFS loaded in " + Math.Ceiling(timer.Elapsed.TotalMilliseconds) + "ms");
247248
}
248-
249+
249250
timer.Stop();
250-
251+
251252

252253
timer.Restart();
253254
if (!BuildConfig.Values.TryGetValue("install", out var installKey))

0 commit comments

Comments
 (0)