Skip to content

Commit

Permalink
DiscordRPC: Fixed all zeroes party GUID
Browse files Browse the repository at this point in the history
Enable DiscordRPC a bit later to (possibly) avoid crashes on CoreCLR
Use other method for joining lobbies
  • Loading branch information
AuriRex committed Mar 26, 2023
1 parent fe3ed61 commit 6afb41e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TheArchive.Core/Core/Managers/DiscordManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class DiscordManager
private static bool _hasDiscordDllBeenLoaded = false;
private static float _lastCheckedTime = 0f;

public static Guid PartyGuid { get; private set; } = new Guid();
public static Guid PartyGuid { get; private set; } = Guid.NewGuid();

private static RichPresenceSettings _settings = null;
private static bool _internalDisabled = false;
Expand Down
13 changes: 11 additions & 2 deletions TheArchive.IL2CPP/Features/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using CellMenu;
using System;
using System.Collections;
using TheArchive.Core;
using TheArchive.Core.Attributes;
using TheArchive.Core.FeaturesAPI;
Expand All @@ -16,6 +18,8 @@ public class DiscordRichPresence : Feature

public override string Description => "Show the current game state in detail on discord.";

public override bool SkipInitialOnEnable => true;

[FeatureConfig]
public static RichPresenceSettings DiscordRPCSettings { get; set; }

Expand All @@ -39,12 +43,17 @@ public override void OnEnable()
}
}

public override void OnGameDataInitialized()
{
OnEnable();
}

private void DiscordManager_OnActivityJoin(string secret)
{
ulong.TryParse(secret, out ulong value);
if (value == 0) return;

SNetwork.SNet.Lobbies.JoinLobby(value);
CM_Utils.JoinLobby(value, new Action(() => FeatureLogger.Success($"Successfully joined lobby \"{secret}\"!")), new Action(() => FeatureLogger.Fail($"Failed to join lobby \"{secret}\".")));
}

public override void OnDisable()
Expand Down

0 comments on commit 6afb41e

Please sign in to comment.