Skip to content

Commit

Permalink
idk :V
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Feb 9, 2022
1 parent 48c2003 commit a941af9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
3 changes: 1 addition & 2 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class ProfilesWindow : Window
public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
{
InitializeComponent();
main = (MainWindow)Application.Current.MainWindow;
main = (MainWindow)this.Owner;
selected = current;
ValCCApi = ValCCAPI;
}
Expand Down Expand Up @@ -97,7 +97,6 @@ private async Task<bool> RenderProfiles()
PublicProfile profile = PublicProfiles[i];
shareablesElement.Add(await this.GenerateRender(profile));
}
await Task.Delay(1);
return true;
}
private async void btnSearchCode_Click(object sender, RoutedEventArgs e)
Expand Down
8 changes: 7 additions & 1 deletion ValorantCC/ValorantCC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<Version>3.0</Version>
<Version>3.0.0</Version>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

Expand Down Expand Up @@ -102,4 +102,10 @@
<_DeploymentManifestIconFile Remove="Resources\vtools-colored.ico" />
</ItemGroup>

<ItemGroup>
<Page Update="Resources\BGdictionary.xaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
</ItemGroup>

</Project>
14 changes: 9 additions & 5 deletions ValorantCC/src/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ public static LockfileData ObtainLockfileData(string LockfilePath)
try
{
Utils.Log("Trying to open Lockfile");
FileStream File = new FileStream(LockfilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader Reader = new StreamReader(File, Encoding.UTF8);
LockfileRaw = Reader.ReadToEnd();
File.Close();
Reader.Close();
using (FileStream File = new FileStream(LockfilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (StreamReader Reader = new StreamReader(File, Encoding.UTF8))
{
LockfileRaw = (String)Reader.ReadToEnd().Clone();
File.Close();
Reader.Close();
}
}
}
catch (FileNotFoundException)
{
Expand Down
2 changes: 1 addition & 1 deletion ValorantCC/src/BackgroundAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async static Task<bool> LoginFlagExists()
{
using (StreamReader sr = new StreamReader(fileStream))
{
content = sr.ReadToEnd();
content = (String)sr.ReadToEnd().Clone();
}
}
bool t = false;
Expand Down
46 changes: 29 additions & 17 deletions ValorantCC/src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using ValorantCC;

Expand All @@ -21,34 +23,44 @@ public static Data Decompress(string value)
{
Log("Decompressing Response Data");
byte[] byteArray = Convert.FromBase64String(value);
var outputStream = new MemoryStream();
DeflateStream deflateStream = new DeflateStream(new MemoryStream(byteArray), CompressionMode.Decompress);
deflateStream.CopyTo(outputStream);

return JsonConvert.DeserializeObject<Data>(Encoding.UTF8.GetString(outputStream.ToArray()));
byte[] decompressed;
using (MemoryStream outputStream = new MemoryStream())
{
using (DeflateStream deflateStream = new DeflateStream(new MemoryStream(byteArray), CompressionMode.Decompress))
{
deflateStream.CopyTo(outputStream);
}
decompressed = (byte[])outputStream.ToArray().Clone();
}
return JsonConvert.DeserializeObject<Data>(Encoding.UTF8.GetString(decompressed));
}

public static string Compress(Object data)
{
Log("Compressing New Data");
string jsonString = JsonConvert.SerializeObject(data);
byte[] byteArray = Encoding.UTF8.GetBytes(jsonString);
MemoryStream output = new MemoryStream();
//Create stream from bytes of the json data and copy it to deflateStream as it only has write access
try
byte[] compressed;
using (MemoryStream output = new MemoryStream())
{
using (MemoryStream memoryStream = new MemoryStream(byteArray))
//Create stream from bytes of the json data and copy it to deflateStream as it only has write access
try
{
DeflateStream deflateStream = new DeflateStream(output, CompressionMode.Compress);
memoryStream.CopyTo(deflateStream);
deflateStream.Close();
using (MemoryStream memoryStream = new MemoryStream(byteArray))
{
using (DeflateStream deflateStream = new DeflateStream(output, CompressionMode.Compress))
{
memoryStream.CopyTo(deflateStream);
}
}
}
catch (Exception e)
{
Log(e.ToString());
}
compressed = (byte[])output.ToArray().Clone();
}
catch (Exception e)
{
Log(e.ToString());
}
return Convert.ToBase64String(output.ToArray());
return Convert.ToBase64String(compressed);
}

public static CrosshairColor parseCrosshairColor(string input)
Expand Down

0 comments on commit a941af9

Please # to comment.