Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 8c1c557

Browse files
committed
Optimizations
Update 0.9.2 Added Default to Nitebeam Added Default to Crusher Added Default to Finesse Finisher Added Default to Havoc Added Default to Crackabella Added Default to Domino Optimized Oodle Compression (Thanks Tamely) Optimized themes & startup times Launching Fortnite through Pro Swapper will automatically close Epic Games Launcher (after existing Fortnite) Added "Revert All Lobby Swaps" button in lobby swapper tab.
1 parent cc42feb commit 8c1c557

23 files changed

Lines changed: 196 additions & 187 deletions

CUE4Parse/CUE4Parse/Compression/Compression.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public static void Decompress(byte[] compressed, int compressedOffset, int compr
4242
gzip.Dispose();
4343
return;
4444
case CompressionMethod.Oodle:
45+
Pro_Swapper.Swap.RawExport = compressed;
4546
Oodle.Decompress(compressed, compressedOffset, compressedSize, uncompressed, uncompressedOffset, uncompressedSize, reader);
4647
return;
4748
case CompressionMethod.LZ4:

Properties/Resources.Designer.cs

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Resources.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@
127127
<data name="Eclipse_0_7s_104px__1_" type="System.Resources.ResXFileRef, System.Windows.Forms">
128128
<value>..\Resources\Eclipse-0.7s-104px (1).gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
129129
</data>
130-
<data name="oo2core_5_win64" type="System.Resources.ResXFileRef, System.Windows.Forms">
131-
<value>..\Resources\oo2core_5_win64.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
132-
</data>
133130
<data name="pro_swapper_splash" type="System.Resources.ResXFileRef, System.Windows.Forms">
134131
<value>..\Resources\pro swapper splash.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
135132
</data>

Resources/oo2core_5_win64.dll

-928 KB
Binary file not shown.

src/Classes/EpicGamesLauncher.cs

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,93 +3,78 @@
33
using System.Linq;
44
using Newtonsoft.Json;
55
using System.Windows.Forms;
6+
using System.Diagnostics;
7+
using System.Collections.Generic;
68
namespace Pro_Swapper
79
{
810
public class EpicGamesLauncher
911
{
10-
11-
private class InstallationList
12+
private static readonly string LauncherJson = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Epic\UnrealEngineLauncher\LauncherInstalled.dat";
13+
public class InstallationList
1214
{
1315
public string InstallLocation { get; set; }
16+
public string NamespaceId { get; set; }
17+
public string ItemId { get; set; }
18+
public string ArtifactId { get; set; }
19+
public string AppVersion { get; set; }
1420
public string AppName { get; set; }
15-
//public string AppVersion { get; set; }
1621
}
1722

18-
private class Root
23+
public class Root
1924
{
20-
public InstallationList[] InstallationList { get; set; }
25+
public List<InstallationList> InstallationList { get; set; }
2126
}
2227
public static void FindPakFiles()
2328
{
24-
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Epic\UnrealEngineLauncher\LauncherInstalled.dat";
25-
if (File.Exists(path))
29+
if (File.Exists(LauncherJson))
2630
{
2731
try
2832
{
29-
Root launcherdata = JsonConvert.DeserializeObject<Root>(File.ReadAllText(path));
30-
foreach (var d in launcherdata.InstallationList)
31-
{
32-
if (d.AppName == "Fortnite")
33-
{
34-
global.CurrentConfig.Paks = d.InstallLocation + @"\FortniteGame\Content\Paks";
35-
global.SaveConfig();
36-
return;
37-
}
38-
}
33+
Root launcherdata = JsonConvert.DeserializeObject<Root>(File.ReadAllText(LauncherJson));
34+
InstallationList fortnite = launcherdata.InstallationList.Where(x => x.AppName == "Fortnite").FirstOrDefault();
35+
global.CurrentConfig.Paks = fortnite.InstallLocation + @"\FortniteGame\Content\Paks";
36+
global.SaveConfig();
3937
}
4038
catch
4139
{
42-
goto error;
40+
MessageBox.Show("Could not find your pak files! Please select them manually!", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Error);
4341
}
4442
}
45-
error: MessageBox.Show("Could not find your pak files! Please select them manually!", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Error);
4643
}
4744

4845

4946
public static string GetOodleDll()
5047
{
51-
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Epic\UnrealEngineLauncher\LauncherInstalled.dat";
52-
if (File.Exists(path))
53-
{
54-
foreach (InstallationList d in JsonConvert.DeserializeObject<Root>(File.ReadAllText(path)).InstallationList)
55-
{
56-
if (d.AppName == "Fortnite")
57-
{
58-
string oodledll = d.InstallLocation + @"\FortniteGame\Binaries\Win64\oo2core_5_win64.dll";
59-
if (File.Exists(oodledll))
60-
return oodledll;
61-
else
62-
return "";
63-
}
64-
}
65-
return "";
66-
}
48+
Root launcherdata = JsonConvert.DeserializeObject<Root>(File.ReadAllText(LauncherJson));
49+
InstallationList fortnite = launcherdata.InstallationList.Where(x => x.AppName == "Fortnite").First();
50+
51+
string oodlefile = fortnite.InstallLocation + @"\FortniteGame\Binaries\Win64\oo2core_5_win64.dll";
52+
if (File.Exists(oodlefile))
53+
return oodlefile;
6754
else
68-
{
69-
return "";
70-
}
55+
return null;
7156
}
72-
/*
73-
public static string InstalledFortniteVersion()
57+
58+
public static bool CloseFNPrompt()
7459
{
75-
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Epic\UnrealEngineLauncher\LauncherInstalled.dat";
76-
if (File.Exists(path))
60+
Process[] procs = Process.GetProcesses();
61+
string[] blacklistedprocs = { "easyanticheat", "FortniteClient-Win64-Shipping", "epicgameslauncher"};
62+
foreach (var proc in procs)
7763
{
78-
try
64+
if (blacklistedprocs.Any(proc.ProcessName.ToLower().Contains))
7965
{
80-
Root launcherdata = JsonConvert.DeserializeObject<Root>(File.ReadAllText(path));
81-
foreach (var d in launcherdata.InstallationList)
66+
try
8267
{
83-
if (d.AppName == "Fortnite")
84-
return d.AppVersion;
68+
proc.Kill();
69+
}
70+
catch
71+
{
72+
MessageBox.Show($"{proc.ProcessName} ({proc.Id}) is running! Please close this before swapping anything!", "Pro Swapper", MessageBoxButtons.OK, MessageBoxIcon.Information);
73+
return false;
8574
}
86-
}
87-
catch
88-
{
89-
return "";
9075
}
9176
}
92-
return "";
93-
}*/
77+
return true;
78+
}
9479
}
9580
}

src/Classes/Oodle/Oodle.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
2+
using System.IO;
23
using Pro_Swapper.Oodle.Utils;
34
namespace Pro_Swapper.Oodle
45
{
56
public class OodleClass
67
{
7-
8+
//Pro Swapper doesnt need this so we'll just comment it out.
9+
/*
810
public static void Compress(string decompressedFilePath, string outputPath) // Leaving incase you want a save file one
911
{
1012
Utils.Oodle.Prepare(decompressedFilePath); // Gets the source prepared
@@ -23,25 +25,35 @@ public static void Compress(string decompressedFilePath, string outputPath) // L
2325
OodleFormat.Kraken, OodleCompressionLevel.Level5, @uint);
2426
2527
26-
Helper.Write(compressed, outputPath); // Writing the data
28+
WriteFile(compressed, outputPath); // Writing the data
2729
}
28-
30+
31+
public static void WriteFile(byte[] writableData, string filePath)
32+
{
33+
FileInfo fileInfo = new FileInfo(filePath);
34+
if (fileInfo.IsReadOnly && File.Exists(filePath))
35+
fileInfo.IsReadOnly = false;
36+
FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite);
37+
BinaryWriter binaryWriter = new BinaryWriter(fileStream);
38+
binaryWriter.Write(writableData);
39+
binaryWriter.Close();
40+
fileStream.Close();
41+
}*/
42+
2943
public static byte[] Compress(byte[] array) // Leaving incase you want a save file one
3044
{
3145
Utils.Oodle.Prepare(array); // Gets the source prepared
3246
uint @uint; // Needs to be outside so it always has a value
3347
try
3448
{
35-
@uint = OodleStream.GetCompressedLength(Utils.Oodle.SourceArray, Utils.Oodle.SourceLength,
36-
OodleFormat.Kraken, OodleCompressionLevel.Level5);
49+
@uint = OodleStream.GetCompressedLength(Utils.Oodle.SourceArray, Utils.Oodle.SourceArray.Length, OodleFormat.Kraken, OodleCompressionLevel.Level5);
3750
}
3851
catch (AccessViolationException)
3952
{
4053
@uint = 64U;
4154
}
4255

43-
return OodleStream.OodleCompress(Utils.Oodle.SourceArray, Utils.Oodle.SourceLength,
44-
OodleFormat.Kraken, OodleCompressionLevel.Level5, @uint);
56+
return OodleStream.OodleCompress(Utils.Oodle.SourceArray, Utils.Oodle.SourceArray.Length, OodleFormat.Kraken, OodleCompressionLevel.Level5, @uint);
4557
}
4658
}
4759
}

src/Classes/Oodle/Utils/Helper.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Classes/Oodle/Utils/Oodle.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ public class Oodle
1010
{
1111
public static byte[]? SourceArray;
1212
private static readonly byte[] DestinationArray = new byte[4];
13-
public static int SourceLength;
13+
//public static int SourceLength;
1414

15+
/* Pro Swapper doesn't use filepath (uses byte array)
1516
public static void Prepare(string filePath)
1617
{
1718
SourceArray = null; // Note: (Tamely) Need to assign null for reuse... just in case
@@ -27,7 +28,7 @@ public static void Prepare(string filePath)
2728
}
2829
2930
SourceLength = SourceArray.Length;
30-
}
31+
}*/
3132

3233
public static void Prepare(byte[] array)
3334
{
@@ -43,7 +44,7 @@ public static void Prepare(byte[] array)
4344
Array.Copy(SourceArray, 24, targetArray, 0, targetLength);
4445
}
4546

46-
SourceLength = SourceArray.Length;
47+
// SourceLength = SourceArray.Length;
4748
}
4849
}
4950
}

src/Classes/Swap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public static async Task SwapItem(api.Item item, bool Converting)
9292
tasklist.Add(Task.Run(() => PasteInLocationBytes(pastes)));
9393

9494

95-
9695
await Task.WhenAll(tasklist);
9796
}
9897

@@ -110,6 +109,8 @@ public FinalPastes(string Ucasfile, byte[] ToWrite, long offset)
110109
}
111110
}
112111

112+
public static byte[] RawExport { get; set; }
113+
113114
//Edits a byte array in memory
114115
public static byte[] EditAsset(byte[] file, api.Asset asset, bool Converting, out bool Compress)
115116
{
@@ -161,7 +162,6 @@ public static byte[] SameLength(byte[] search, byte[] replace)
161162

162163
return result.ToArray();
163164
}
164-
165165
public static byte[] SetLength(byte[] search, byte[] longerbyte)
166166
{
167167
List<byte> result = new List<byte>(search);

src/Classes/api.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,37 @@ public enum AESSource
6464

6565
public static void UpdateAPI()
6666
{
67+
GlobalAPI.Root globalapi = null;
6768
#if DEBUG
6869
apidata = JsonConvert.DeserializeObject<APIRoot>(File.ReadAllText("api.json"));
6970
apidata.timestamp = global.GetEpochTime();
71+
globalapi = JsonConvert.DeserializeObject<GlobalAPI.Root>(File.ReadAllText("global.json"));
7072
string json = JsonConvert.SerializeObject(apidata, Formatting.None, new JsonSerializerSettings
7173
{
7274
NullValueHandling = NullValueHandling.Ignore//Makes filesize smaller hehe
7375
});
7476
byte[] compressedapi = MessagePackSerializer.ConvertFromJson(json, MessagePackSerializerOptions.Standard);
7577
File.WriteAllBytes($"{global.version}.json", ByteCompression.Compress(compressedapi));
78+
7679
#else
7780
try
7881
{
79-
byte[] apidatas = ByteCompression.Decompress(new WebClient().DownloadData($"{ProSwapperEndpoint}/{global.version}.json"));
80-
string json = MessagePackSerializer.ConvertToJson(apidatas);
81-
apidata = JsonConvert.DeserializeObject<APIRoot>(json);
82+
using (WebClient web = new WebClient())
83+
{
84+
byte[] apidatas = ByteCompression.Decompress(web.DownloadData($"{ProSwapperEndpoint}/{global.version}.json"));
85+
string json = MessagePackSerializer.ConvertToJson(apidatas);
86+
apidata = JsonConvert.DeserializeObject<APIRoot>(json);
87+
globalapi = JsonConvert.DeserializeObject<GlobalAPI.Root>(web.DownloadString($"{ProSwapperEndpoint}/global.json"));
88+
}
8289
}
8390
catch (Exception ex)
8491
{
8592
Main.ThrowError($"Pro Swapper needs an internet connection to run, if you are already connected to the internet Pro Swapper's API may be blocked in your country, please use a VPN or try disabling your firewall, if you are already doing this please refer to this error: \n\n{ex.Message}");
8693
}
8794
#endif
95+
apidata.discordurl = globalapi.discordurl;
96+
apidata.version = globalapi.version;
97+
apidata.status[0] = globalapi.status[0];
8898
}
8999

90100
public class Asset
@@ -131,8 +141,19 @@ public class APIRoot
131141
public string discordurl { get; set; }
132142
public long timestamp { get; set; }
133143
public Item[] items { get; set; }
134-
public Status[] status { get; set; }
144+
public Status[] status = new Status[1];
135145
public OptionMenu[] OptionMenu { get; set; }
136146
}
147+
148+
149+
public class GlobalAPI
150+
{
151+
public class Root
152+
{
153+
public Status[] status { get; set; }
154+
public string version { get; set; }
155+
public string discordurl { get; set; }
156+
}
157+
}
137158
}
138159
}

0 commit comments

Comments
 (0)