Skip to content

Commit

Permalink
[CCK.Debugger] Added testing env var.
Browse files Browse the repository at this point in the history
  • Loading branch information
kafeijao committed Sep 15, 2022
1 parent 3a1f753 commit 92a3dd4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CCK.Debugger/Components/MenuHandlers/AvatarMenuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ static AvatarMenuHandler() {

// Todo: Allow to inspect other people's avatars if they give permission
// Todo: Waiting for bios
List<CVRPlayerEntity> players = new();
//List<CVRPlayerEntity> players = CVRPlayerManager.Instance.NetworkPlayers;
var players = CCKDebugger.TestMode ? CVRPlayerManager.Instance.NetworkPlayers : new List<CVRPlayerEntity>();

bool IsValid(CVRPlayerEntity entity) {
if (entity?.PuppetMaster == null) return false;
Expand Down
19 changes: 19 additions & 0 deletions CCK.Debugger/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,27 @@ namespace CCK.Debugger;

public class CCKDebugger : MelonMod {

internal static bool TestMode;

private const string _assetPath = "Assets/Prefabs/CCKDebuggerMenu.prefab";

public override void OnApplicationStart() {

// Check if it is in debug mode (to test functionalities that are waiting for bios to be enabled)
// Keeping it hard-ish to enable so people don't abuse it
foreach (var commandLineArg in Environment.GetCommandLineArgs()) {
if (!commandLineArg.StartsWith("--cck-debugger-test=")) continue;
var input = commandLineArg.Split(new[] { "=" }, StringSplitOptions.None)[1];
using System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
var inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
var hashBytes = md5.ComputeHash(inputBytes);
var sb = new System.Text.StringBuilder();
foreach (var t in hashBytes) sb.Append(t.ToString("X2"));
TestMode = sb.ToString().Equals("738A9A4AD5E2F8AB10E702D44C189FA8");
if (TestMode) MelonLogger.Msg("Test Mode is ENABLED!");
}
}

[HarmonyPatch]
private class HarmonyPatches
{
Expand Down

0 comments on commit 92a3dd4

Please sign in to comment.