Skip to content

Commit

Permalink
added debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gompocp committed Aug 30, 2021
1 parent 39b97f0 commit e493232
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion WorldPredownload/Cache/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)));
Expand Down
3 changes: 3 additions & 0 deletions WorldPredownload/DownloadManager/WorldDownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions WorldPredownload/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 5 additions & 2 deletions WorldPredownload/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace WorldPredownload
{

[HarmonyPatch(typeof(NetworkManager), "OnLeftRoom")]
internal class OnLeftRoomPatch
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -113,7 +117,6 @@ public static void Patch()
public static void Prefix(Notification __0)
{
SelectedNotification = __0;
MelonLogger.Msg("Called patch");
InviteButton.UpdateText();
}
}
Expand Down

0 comments on commit e493232

Please sign in to comment.