diff --git a/PulsarModLoader/CustomGUI/GUIMain.cs b/PulsarModLoader/CustomGUI/GUIMain.cs index 35da7bf..17f2a41 100644 --- a/PulsarModLoader/CustomGUI/GUIMain.cs +++ b/PulsarModLoader/CustomGUI/GUIMain.cs @@ -120,7 +120,7 @@ void WindowFunction(int WindowID) Label($"Short Description: {mod.ShortDescription}"); if (mod.LongDescription != string.Empty) Label($"Long Description: {mod.LongDescription}"); - Label($"MPFunctionality: {((MPFunction)mod.MPFunctionality).ToString()}"); + Label($"MPFunctionality: {((MPModChecks.MPFunction)mod.MPFunctionality).ToString()}"); } EndScrollView(); } diff --git a/PulsarModLoader/MPModChecks/MPModCheckManager.cs b/PulsarModLoader/MPModChecks/MPModCheckManager.cs index 152aaad..426028c 100644 --- a/PulsarModLoader/MPModChecks/MPModCheckManager.cs +++ b/PulsarModLoader/MPModChecks/MPModCheckManager.cs @@ -43,16 +43,16 @@ private void UpdateLobbyModList() //Update Photon Lobby Listing with mod list private MPModDataBlock[] MyModList = null; - private Dictionary NetworkedPeersModLists = new Dictionary(); + private Dictionary NetworkedPeersModLists = new Dictionary(); private bool ServerHasMPMods = false; - public MPModDataBlock[] GetNetworkedPeerMods(PhotonPlayer Photonplayer) + public MPUserDataBlock GetNetworkedPeerMods(PhotonPlayer Photonplayer) { return NetworkedPeersModLists[Photonplayer]; } - public void AddNetworkedPeerMods(PhotonPlayer Photonplayer, MPModDataBlock[] modList) + public void AddNetworkedPeerMods(PhotonPlayer Photonplayer, MPUserDataBlock modList) { if (NetworkedPeersModLists.ContainsKey(Photonplayer)) { @@ -109,7 +109,7 @@ private void UpdateMyModList() Logger.Info("Finished Building MyModList, time elapsted: " + stopwatch.ElapsedMilliseconds.ToString()); } - private MemoryStream GetModListForLobbyListing() + public byte[] GetModListForLobbyListing() { MemoryStream dataStream = new MemoryStream(); using (BinaryWriter writer = new BinaryWriter(dataStream)) @@ -127,11 +127,12 @@ private MemoryStream GetModListForLobbyListing() writer.Write(dataBlock.ModID); //string ModID } } - return dataStream; + return dataStream.ToArray(); } - public static MPUserDataBlock GetModListFromLobbyListingData(MemoryStream memoryStream) + public static MPUserDataBlock GetModListFromLobbyListingData(byte[] byteData) { + MemoryStream memoryStream = new MemoryStream(byteData); memoryStream.Position = 0; MPUserDataBlock UserData = null; using (BinaryReader reader = new BinaryReader(memoryStream)) @@ -161,7 +162,7 @@ public static MPUserDataBlock GetModListFromLobbyListingData(MemoryStream memory return UserData; } - private static string GetModListAsString(MPModDataBlock[] ModDatas) + public static string GetModListAsString(MPModDataBlock[] ModDatas) { string ModList = string.Empty; foreach (MPModDataBlock DataBlock in ModDatas) @@ -175,7 +176,7 @@ private static MPUserDataBlock GetHostModList(RoomInfo room) { if (room.CustomProperties.ContainsKey("modList")) { - return GetModListFromLobbyListingData((MemoryStream)room.CustomProperties["modList"]); + return GetModListFromLobbyListingData((byte[])room.CustomProperties["modList"]); } return new MPUserDataBlock(); } @@ -287,7 +288,7 @@ public void HostOnClientJoined(PhotonPlayer Player) bool foundplayer = false; if (NetworkedPeersModLists.ContainsKey(Player)) //checks if server has received mod list from client. { - ClientMods = NetworkedPeersModLists[Player]; + ClientMods = NetworkedPeersModLists[Player].ModData; foundplayer = true; } Logger.Info("HostOnClientJoined checking for player mods, returned " + foundplayer.ToString()); @@ -398,6 +399,7 @@ public void HostOnClientJoined(PhotonPlayer Player) string message = $"You have been disconnected for not having the mod loader installed"; ModMessageHelper.Instance.photonView.RPC("RecieveErrorMessage", Player, new object[] { message }); KickClient(Player); + return; } Utilities.Logger.Info("Didn't receive message or proper modlist, but the server doesn't have multiplayer explicit mods. Proceeding onwards"); } @@ -446,10 +448,10 @@ static void Postfix(PhotonPlayer player, PhotonMessageInfo pmi) { if (player == PhotonNetwork.player) { + Logger.Info("Sending 'RecieveConnectionMessage' RPC"); ModMessageHelper.Instance.photonView.RPC("ReceiveConnectionMessage", pmi.sender, new object[] { - MPModCheckManager.Instance.MyModList, - Patches.GameVersion.PMLVersion + MPModCheckManager.Instance.GetModListForLobbyListing() }); } player.Verified = true; diff --git a/PulsarModLoader/ModMessage/ModMessageHelper.cs b/PulsarModLoader/ModMessage/ModMessageHelper.cs index b208ded..70e2ec9 100644 --- a/PulsarModLoader/ModMessage/ModMessageHelper.cs +++ b/PulsarModLoader/ModMessage/ModMessageHelper.cs @@ -92,10 +92,11 @@ public void RecieveErrorMessage(string message) } [PunRPC] - public void ReceiveConnectionMessage(MPModDataBlock[] modList, string PMLVersion, PhotonMessageInfo pmi) //Pong + public void ReceiveConnectionMessage(byte[] recievedData, PhotonMessageInfo pmi) //Pong { - Logger.Info($"recieved modlist and connection info from user with the following info:\nPMLVersion: {PMLVersion}\nModlist:{MPModCheckManager.GetModListAsString(modList)}"); - MPModCheckManager.Instance.AddNetworkedPeerMods(pmi.sender, modList); + MPUserDataBlock userDataBlock = MPModCheckManager.GetModListFromLobbyListingData(recievedData); + Logger.Info($"recieved modlist and connection info from user with the following info:\nPMLVersion: {userDataBlock.PMLVersion}\nModlist:{MPModCheckManager.GetModListAsString(userDataBlock.ModData)}"); + MPModCheckManager.Instance.AddNetworkedPeerMods(pmi.sender, userDataBlock); } } } diff --git a/PulsarModLoader/Patches/PhotonProperties.cs b/PulsarModLoader/Patches/PhotonProperties.cs index 2813cac..814bcb1 100644 --- a/PulsarModLoader/Patches/PhotonProperties.cs +++ b/PulsarModLoader/Patches/PhotonProperties.cs @@ -25,6 +25,9 @@ private static void Prefix(RoomOptions roomOptions) "playerList", "modList", }); + + //MPModCheck + roomOptions.CustomRoomProperties["modList"] = MPModChecks.MPModCheckManager.Instance.GetModListForLobbyListing(); } public static void UpdatePlayerList()