diff --git a/WorldPredownload/Cache/CacheManager.cs b/WorldPredownload/Cache/CacheManager.cs index 80794c1..45012ce 100644 --- a/WorldPredownload/Cache/CacheManager.cs +++ b/WorldPredownload/Cache/CacheManager.cs @@ -47,6 +47,9 @@ public static bool HasDownloadedWorld(string url) public static string ComputeAssetHash(string url) { var id = Utilities.ExtractFileId(url); + #if DEBUG + MelonLogger.Msg($"File Id: {id}"); + #endif return Utilities.ByteArrayToString(SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(id))).ToUpper() .Substring(0, 16); } @@ -78,7 +81,7 @@ public static string ComputeVersionString(string url) //Int to Little Endian Hex foreach (var b in bytes) result += b.ToString("x2"); return result; } - + public static bool WorldFileExists(string url) { var expectedLocation = new DirectoryInfo(Path.Combine(GetCache().path, ComputeAssetHash(url))); diff --git a/WorldPredownload/DownloadManager/WorldDownloadManager.cs b/WorldPredownload/DownloadManager/WorldDownloadManager.cs index 468bd09..d004058 100644 --- a/WorldPredownload/DownloadManager/WorldDownloadManager.cs +++ b/WorldPredownload/DownloadManager/WorldDownloadManager.cs @@ -178,6 +178,9 @@ private static void Download(ApiWorld apiWorld, DownloadProgressChangedEventHand if (!Directory.Exists(assetVersionDir)) Directory.CreateDirectory(assetVersionDir); var fileName = Path.Combine(assetVersionDir, "__data"); + #if DEBUG + MelonLogger.Msg($"Calculated Directory: {assetVersionDir}"); + #endif MelonLogger.Msg($"Starting world download for: {apiWorld.name}"); file = fileName; diff --git a/WorldPredownload/Helpers/Utilities.cs b/WorldPredownload/Helpers/Utilities.cs index c2f7387..77efa01 100644 --- a/WorldPredownload/Helpers/Utilities.cs +++ b/WorldPredownload/Helpers/Utilities.cs @@ -20,15 +20,14 @@ public static class Utilities { private static readonly Regex fileIdRegex = new("/file_[0-9A-Za-z-]+/", RegexOptions.Compiled); - private static readonly Regex fileVersionRegex = - new("(?:\\/file_[0-9A-Za-z-]+\\/)([0-9]+)", RegexOptions.Compiled); + private static readonly Regex fileVersionRegex = new("(?:\\/file_[0-9A-Za-z-]+\\/)([0-9]+)", RegexOptions.Compiled); public static void AdvancedInvitesHandleInvite(Notification notification) { #if DEBUG try { - GetAdvancedInvitesInviteDelegate(notification); + //GetAdvancedInvitesInviteDelegate(notification); } catch (Exception e) { diff --git a/WorldPredownload/Patches.cs b/WorldPredownload/Patches.cs index 48706ff..b34ba6f 100644 --- a/WorldPredownload/Patches.cs +++ b/WorldPredownload/Patches.cs @@ -19,6 +19,7 @@ namespace WorldPredownload { + [HarmonyPatch(typeof(NetworkManager), "OnLeftRoom")] internal class OnLeftRoomPatch { @@ -78,7 +79,10 @@ public static void Postfix(IntPtr thisPtr, IntPtr apiWorldPtr, IntPtr apiWorldIn if (apiWorldPtr == IntPtr.Zero) return; var apiWorld = new ApiWorld(apiWorldPtr); if (apiWorld.assetUrl == null) return; // This patch gets called twice. First time with a null url & a second time with a valid one - WorldButton.UpdateText(new ApiWorld(apiWorldPtr)); + #if DEBUG + MelonLogger.Msg(apiWorld.assetUrl); +#endif + WorldButton.UpdateText(apiWorld); } catch (Exception e) { @@ -113,7 +117,6 @@ public static void Patch() public static void Prefix(Notification __0) { SelectedNotification = __0; - MelonLogger.Msg("Called patch"); InviteButton.UpdateText(); } }