Skip to content

Commit

Permalink
-Added HelperMethods for detecting client mods.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonFire47 committed Sep 5, 2022
1 parent ee9a2e7 commit 5d479e1
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions PulsarModLoader/MPModChecks/MPModCheckManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ public MPUserDataBlock GetNetworkedPeerMods(PhotonPlayer Photonplayer)
return null;
}
}

public bool NetworkedPeerHasMod(PhotonPlayer player, string HarmonyIdentifier)
{
MPUserDataBlock userData = GetNetworkedPeerMods(player);
if(userData != null)
{
foreach(MPModDataBlock modData in userData.ModData)
{
if(modData.HarmonyIdentifier == HarmonyIdentifier)
{
return true;
}
}
}
return false;
}

public List<PhotonPlayer> NetworkedPeersWithMod(string HarmonyIdentifier)
{
List<PhotonPlayer> playerList = new List<PhotonPlayer>();
foreach(KeyValuePair<PhotonPlayer,MPUserDataBlock> userEntry in NetworkedPeersModLists)
{
foreach(MPModDataBlock modData in userEntry.Value.ModData)
{
if(modData.HarmonyIdentifier == HarmonyIdentifier)
{
playerList.Add(userEntry.Key);
}
}
}
return playerList;
}

public void AddNetworkedPeerMods(PhotonPlayer Photonplayer, MPUserDataBlock modList)
{
Expand Down Expand Up @@ -487,18 +519,6 @@ public bool HostOnClientJoined(PhotonPlayer Player)
return true;
}

/*public IEnumerator ServerSendModsToClient(PhotonPlayer client)
{
foreach (PhotonPlayer player in NetworkedPeersModLists.Keys)
{
ModMessageHelper.Instance.photonView.RPC("ClientRecieveModList", client, new object[]
{
Instance.SerializeHashlessUserData()
});
yield return null;
}
}*/

[HarmonyPatch(typeof(PLUIPlayMenu), "ActuallyJoinRoom")] //allow/disallow local client to join server.
class JoinRoomPatch
{
Expand All @@ -508,14 +528,17 @@ static bool Prefix(RoomInfo room)
}
}

/*[HarmonyPatch(typeof(PLServer), "ServerOnClientVerified")] //Starts host mod verification coroutine
[HarmonyPatch(typeof(PLServer), "ServerOnClientVerified")] //Starts host mod verification coroutine
class ServerOnClientVerifiedPatch
{
static void Postfix(PhotonPlayer client)
{
PLServer.Instance.StartCoroutine(Instance.ServerSendModsToClient(client));
ModMessageHelper.Instance.photonView.RPC("ClientRecieveModList", client, new object[]
{
Instance.SerializeHashlessUserData()
});
}
}*/
}
[HarmonyPatch(typeof(PLServer), "AttemptGetVerified")]
class AttemptGetVerifiedRecievePatch
{
Expand Down

0 comments on commit 5d479e1

Please sign in to comment.