From c2164286068f6706011c1e55a4355e536a48a2d5 Mon Sep 17 00:00:00 2001 From: DragonFire47 <46509577+DragonFire47@users.noreply.github.com> Date: Mon, 3 Apr 2023 16:07:06 -0700 Subject: [PATCH] Cleanup, Documentation. --- .../MPModChecks/MPModCheckManager.cs | 29 ++++++++++++------- PulsarModLoader/MPModChecks/MPModDataBlock.cs | 23 +++++++++++++++ PulsarModLoader/PulsarMod.cs | 6 ++++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/PulsarModLoader/MPModChecks/MPModCheckManager.cs b/PulsarModLoader/MPModChecks/MPModCheckManager.cs index 95c2a2a..1a54713 100644 --- a/PulsarModLoader/MPModChecks/MPModCheckManager.cs +++ b/PulsarModLoader/MPModChecks/MPModCheckManager.cs @@ -320,7 +320,7 @@ public static MPUserDataBlock DeserializeHashfullMPUserData(byte[] byteData) } /// - /// Converts a ModDataBlock array to a string list, Ussually for logging purposes. + /// Converts a ModDataBlock array to a string list, Usually for logging purposes. Starts with a new line /// /// /// Converts ModDataBLocks to a string list. @@ -383,16 +383,20 @@ public bool ClientClickJoinRoom(RoomInfo room) } MPModDataBlock[] HostModList = HostModData.ModData; + //Debug Logging string HostModListString = GetModListAsString(HostModList); string LocalModListString = GetModListAsString(MyModList); Logger.Info($"Joining room: {room.Name} ServerPMLVersion: {HostModData.PMLVersion}\n--Hostmodlist: {HostModListString}\n--Localmodlist: {LocalModListString}"); - string missingMods = string.Empty; + //Variable Initiallization + string hostMPLimitedMods = string.Empty; string localMPLimitedMods = string.Empty; string outdatedMods = string.Empty; - int MyModListLength = MyModList.Length; + int LocalModListLength = MyModList.Length; int HostModListLength = HostModList.Length; - for (int a = 0; a < MyModListLength; a++) + + //Check all local mods and compare against host mods + for (int a = 0; a < LocalModListLength; a++) { bool found = false; int b = 0; @@ -404,25 +408,30 @@ public bool ClientClickJoinRoom(RoomInfo room) break; } } + + //Mod not found in host list, Check if mod mandates host installation via Host, All. if (!found) - { //didn't find mod in host list, checking if mod function mandates host installation + { if (MyModList[a].MPRequirement == MPRequirement.Host || MyModList[a].MPRequirement == MPRequirement.All) { localMPLimitedMods += $"\n{MyModList[a].ModName}"; } } + //Mod found in host list, check if mod versions match. -Should only reach this if mod was found in both lists. -Catches MPRequirements Host, All, or MatchVersion. else - { //found mod in host list, checking if mod versions match. + { if (MyModList[a].MPRequirement != MPRequirement.None && MyModList[a].Version != HostModList[b].Version) { outdatedMods += $"\nLocal: {MyModList[a].ModName} {MyModList[a].Version} Host: {HostModList[b].ModName} {HostModList[b].Version}"; } } } + + //Check all host mods and compare against local mods (Ensures the host doesn't have a mod requiring client installation) for (int a = 0; a < HostModListLength; a++) { bool found = false; - for (int b = 0; b < MyModListLength; b++) + for (int b = 0; b < LocalModListLength; b++) { if (HostModList[a].HarmonyIdentifier == MyModList[b].HarmonyIdentifier) { @@ -434,14 +443,14 @@ public bool ClientClickJoinRoom(RoomInfo room) { if (HostModList[a].MPRequirement == MPRequirement.All) { //Host MP mod not found locally - missingMods += $"\n{HostModList[a].ModName}"; + hostMPLimitedMods += $"\n{HostModList[a].ModName}"; } } } string message = string.Empty; - if (missingMods != string.Empty) + if (hostMPLimitedMods != string.Empty) { - message += $"\nYOU ARE MISSING THE FOLLOWING REQUIRED MODS{missingMods}"; + message += $"\nYOU ARE MISSING THE FOLLOWING REQUIRED MODS{hostMPLimitedMods}"; } if (localMPLimitedMods != string.Empty) { diff --git a/PulsarModLoader/MPModChecks/MPModDataBlock.cs b/PulsarModLoader/MPModChecks/MPModDataBlock.cs index 7954355..f527050 100644 --- a/PulsarModLoader/MPModChecks/MPModDataBlock.cs +++ b/PulsarModLoader/MPModChecks/MPModDataBlock.cs @@ -1,7 +1,19 @@ namespace PulsarModLoader.MPModChecks { + /// + /// Holds data about Mods for MPModChecks + /// public class MPModDataBlock { + /// + /// Creates an MPModDataBlock (With Hash) + /// + /// + /// + /// + /// + /// + /// public MPModDataBlock(string HarmonyIdentifier, string ModName, string Version, MPRequirement MPRequirement, string ModID, byte[] Hash) { this.HarmonyIdentifier = HarmonyIdentifier; @@ -12,6 +24,14 @@ public MPModDataBlock(string HarmonyIdentifier, string ModName, string Version, this.ModID = ModID; } + /// + /// Creates an MPModDataBlock (without Hash) + /// + /// + /// + /// + /// + /// public MPModDataBlock(string HarmonyIdentifier, string ModName, string Version, MPRequirement MPRequirement, string ModID) { this.HarmonyIdentifier = HarmonyIdentifier; @@ -22,11 +42,14 @@ public MPModDataBlock(string HarmonyIdentifier, string ModName, string Version, this.ModID = ModID; } + #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public string HarmonyIdentifier { get; } public string ModName { get; } public string Version { get; } public MPRequirement MPRequirement { get; } public byte[] Hash { get; } public string ModID { get; } + + #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } } diff --git a/PulsarModLoader/PulsarMod.cs b/PulsarModLoader/PulsarMod.cs index ff2ec5d..9728773 100644 --- a/PulsarModLoader/PulsarMod.cs +++ b/PulsarModLoader/PulsarMod.cs @@ -104,6 +104,7 @@ public virtual string Name } } + #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member [Obsolete]//Legacy support public virtual int MPFunctionality { @@ -112,6 +113,10 @@ public virtual int MPFunctionality return (int)MPRequirement.None; } } + #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member + + + #pragma warning disable CS0612 // Type or member is obsolete /// /// Mod's multiplayer requirements. use MPModChecks.MPRequirement.
/// None: No requirement
@@ -133,6 +138,7 @@ public virtual int MPRequirements } } } + #pragma warning restore CS0612 // Type or member is obsolete /// /// Up to the modder to implement