Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Deleting __classImageRef.png will no longer break the class icon editor.
- Explicitly declared all known package manifest extraction directories.
- Simplified version info logic to reduce the necessity of fast version guids.
- StudioFonts package is extracted correctly now.
  • Loading branch information
MaximumADHD committed Jun 14, 2021
1 parent e2f622f commit 1038803
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 61 deletions.
123 changes: 63 additions & 60 deletions ProjectSrc/Bootstrapper/StudioBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class StudioBootstrapper
private readonly RegistryKey versionRegistry;
private readonly RegistryKey pkgRegistry;
private readonly RegistryKey fileRegistry;

private Dictionary<string, string> newManifestEntries;
private HashSet<string> writtenFiles;
private FileManifest fileManifest;
Expand All @@ -63,10 +63,46 @@ public class StudioBootstrapper
private int _maxProgress = -1;
private ProgressBarStyle _progressBarStyle;

private static readonly IReadOnlyDictionary<string, string> knownRoots = new Dictionary<string, string>()
public static readonly IReadOnlyDictionary<string, string> KnownRoots = new Dictionary<string, string>()
{
{ "BuiltInPlugins.zip", @"BuiltInPlugins\" },
{ "BuiltInStandalonePlugins.zip", @"BuiltInStandalonePlugins\" },

{ "content-qt_translations.zip", @"content\qt_translations\" },
{ "content-platform-fonts.zip", @"PlatformContent\pc\fonts\" },
{ "content-terrain.zip", @"PlatformContent\pc\terrain\" },
{ "content-textures3.zip", @"PlatformContent\pc\textures\" },

{ "extracontent-translations.zip", @"ExtraContent\translations\" },
{ "extracontent-luapackages.zip", @"ExtraContent\LuaPackages\" },
{ "extracontent-textures.zip", @"ExtraContent\textures\" },
{ "extracontent-scripts.zip", @"ExtraContent\scripts\" },

{ "content-sky.zip", @"content\sky\" },
{ "content-fonts.zip", @"content\fonts\" },
{ "content-avatar.zip", @"content\avatar\" },
{ "content-models.zip", @"content\models\" },
{ "content-sounds.zip", @"content\sounds\" },
{ "content-configs.zip", @"content\configs\" },
{ "content-textures2.zip", @"content\textures\" },

{ "Qml.zip", @"Qml\" },
{ "ssl.zip", @"ssl\" },
{ "Plugins.zip", @"Plugins\" },
{ "shaders.zip", @"shaders\" },
{ "StudioFonts.zip", @"StudioFonts\" },

{ "redist.zip", @"" },
{ "Libraries.zip", @"" },
{ "LibrariesQt5.zip", @"" },
{ "RobloxStudio.zip", @"" },
};

public static readonly IReadOnlyList<string> BadManifests = new List<string>()
{
{ "content-terrain.zip", @"PlatformContent\pc\terrain\" },
{ "content-textures3.zip", @"PlatformContent\pc\textures\" },
"Qml",
"Plugins",
"StudioFonts"
};

public int Progress
Expand Down Expand Up @@ -337,10 +373,9 @@ private void deleteUnusedFiles()
string filePath = Path.Combine(studioDir, fileName);
string lookupKey = fileName;

if (fileName.StartsWith("Plugins\\", Program.StringFormat))
lookupKey = fileName.Substring(8);
else if (fileName.StartsWith("Qml\\", Program.StringFormat))
lookupKey = fileName.Substring(4);
foreach (string pkgName in BadManifests)
if (fileName.StartsWith(pkgName, Program.StringFormat))
lookupKey = fileName.Substring(pkgName.Length + 1);

if (!fileManifest.ContainsKey(lookupKey))
{
Expand Down Expand Up @@ -410,10 +445,8 @@ public static async Task<ClientVersionInfo> GetTargetVersionInfo(string branch,
};
}

public static async Task<ClientVersionInfo> GetCurrentVersionInfo(string branch, RegistryKey versionRegistry = null, string fastGuid = "", string targetVersion = "")
public static async Task<ClientVersionInfo> GetCurrentVersionInfo(string branch, RegistryKey versionRegistry = null, string targetVersion = "")
{
Contract.Requires(fastGuid != null);

if (versionRegistry == null)
versionRegistry = Program.VersionRegistry;

Expand All @@ -423,25 +456,22 @@ public static async Task<ClientVersionInfo> GetCurrentVersionInfo(string branch,
return await result.ConfigureAwait(false);
}

string binaryType = GetStudioBinaryType();
bool is64Bit = Environment.Is64BitOperatingSystem;

try
{
string binaryType = GetStudioBinaryType();
var result = ClientVersionInfo.Get(binaryType, branch);

return await result.ConfigureAwait(false);
}
catch (WebException)
{
// Fall back to the DeployHistory strategy.

if (string.IsNullOrEmpty(fastGuid))
{
var getFastGuid = GetFastVersionGuid(branch);
fastGuid = await getFastGuid.ConfigureAwait(false);
}

var getFastGuid = GetFastVersionGuid(branch);
string fastGuid = await getFastGuid.ConfigureAwait(false);

string latestFastGuid = versionRegistry.GetString("LatestFastGuid");
bool is64Bit = Environment.Is64BitOperatingSystem;
var info = new ClientVersionInfo();

if (latestFastGuid == fastGuid)
Expand Down Expand Up @@ -495,8 +525,9 @@ private static string fixFilePath(string pkgName, string filePath)
{
string pkgDir = pkgName.Replace(".zip", "");

if ((pkgDir == "Plugins" || pkgDir == "Qml") && !filePath.StartsWith(pkgDir, Program.StringFormat))
filePath = pkgDir + '\\' + filePath;
if (BadManifests.Contains(pkgDir))
if (!filePath.StartsWith(pkgDir, Program.StringFormat))
filePath = pkgDir + '\\' + filePath;

return filePath.Replace('/', '\\');
}
Expand Down Expand Up @@ -598,8 +629,8 @@ private void extractPackage(Package package)
string localRootDir = null;
MaxProgress += numFiles;

if (knownRoots.ContainsKey(pkgName))
localRootDir = knownRoots[pkgName];
if (KnownRoots.ContainsKey(pkgName))
localRootDir = KnownRoots[pkgName];

foreach (ZipArchiveEntry entry in archive.Entries)
{
Expand Down Expand Up @@ -718,10 +749,10 @@ private void extractPackage(Package package)

private void WritePackageFile(string studioDir, string pkgName, string file, string newFileSig, ZipArchiveEntry entry)
{
if (file.EndsWith("/.robloxrc", Program.StringFormat))
if (file.EndsWith(".robloxrc", Program.StringFormat))
return;

if (file.EndsWith("/.luarc", Program.StringFormat))
if (file.EndsWith(".luarc", Program.StringFormat))
return;

string filePath = fixFilePath(pkgName, file);
Expand Down Expand Up @@ -871,40 +902,12 @@ public async Task<bool> Bootstrap(string targetVersion = "")
else
currentBranch = mainRegistry.GetString("BuildBranch", "roblox");

bool shouldInstall = (ForceInstall || currentBranch != Branch);
ClientVersionInfo versionInfo = null;

var getFastVersion = GetFastVersionGuid(currentBranch);
string fastVersion = await getFastVersion.ConfigureAwait(true);

if (!shouldInstall)
shouldInstall = (fastVersion != currentVersion);

string versionOverload = versionRegistry.GetString("VersionOverload");

if (targetVersion != versionOverload)
shouldInstall = true;

if (shouldInstall)
{
if (currentBranch != "roblox")
echo("Possible update detected, verifying...");

var getVersionInfo = GetCurrentVersionInfo(currentBranch, versionRegistry, fastVersion, targetVersion);
versionInfo = await getVersionInfo.ConfigureAwait(true);

if (targetVersion == versionOverload)
if (fastVersion != versionInfo.VersionGuid)
shouldInstall = false;

buildVersion = versionInfo.VersionGuid;
}
else
{
buildVersion = fastVersion;
}

if (currentVersion != buildVersion || shouldInstall)
var getVersionInfo = GetCurrentVersionInfo(currentBranch, versionRegistry, targetVersion);
ClientVersionInfo versionInfo = await getVersionInfo.ConfigureAwait(true);

buildVersion = versionInfo.VersionGuid;

if (currentVersion != buildVersion || ForceInstall)
{
echo("This build needs to be installed!");
bool studioClosed = true;
Expand Down
24 changes: 23 additions & 1 deletion ProjectSrc/Forms/ClassIconEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;

Expand All @@ -17,6 +18,7 @@ public partial class ClassIconEditor : Form

private const string iconPrefix = "explorer-icon-";
private const string iconManifest = @"content\textures\ClassImages.PNG";
private const string clientTracker = "https://raw.githubusercontent.com/CloneTrooper1019/Roblox-Client-Tracker";

private static readonly RegistryKey explorerRegistry = Program.GetSubKey("ExplorerIcons");
private static readonly RegistryKey manifestRegistry = Program.GetSubKey("FileManifest");
Expand Down Expand Up @@ -118,9 +120,29 @@ private static Image getExplorerIcons()
}

string imagePath = infoRegistry.GetString("SourceLocation");
Image explorerIcons = Image.FromFile(imagePath);

if (!File.Exists(imagePath))
{
// I tried to hide this file to prevent it from being deleted, but
// several users still somehow kept doing it by accident.

// As a result, I've added the textures folder to my client tracker
// so this texture can be pulled remotely as a failsafe ¯\_(ツ)_/¯

string branch = Program
.GetString("BuildBranch")
.Replace("sitetest3", "sitetest2");

using (var http = new WebClient())
{
byte[] restore = http.DownloadData($"{clientTracker}/{branch}/textures/ClassImages.PNG");
File.WriteAllBytes(imagePath, restore);
}
}

Image explorerIcons = Image.FromFile(imagePath);
numIcons = explorerIcons.Width / iconSize;

return explorerIcons;
}

Expand Down
Binary file modified RobloxStudioModManager.exe
Binary file not shown.

0 comments on commit 1038803

Please sign in to comment.