From 0a0e5ea98381c1336742da60f105094a3529167b Mon Sep 17 00:00:00 2001 From: D1GQ Date: Fri, 21 Aug 2026 17:29:34 -0500 Subject: [PATCH] Move to semversioning 2.0.0 --- src/BAUPlugin.ModInfo.cs | 50 ++++--- src/BAUPlugin.cs | 42 +----- src/BetterAmongUs.csproj | 7 +- src/BetterAmongUs.sln | 3 + src/Commands/DumpCommand.cs | 8 +- src/FodyWeavers.xml | 8 + src/FodyWeavers.xsd | 141 ++++++++++++++++++ src/MonoScripts/BetterPingTracker.cs | 2 +- src/Network/Configs/BAUUpdateData.cs | 79 ++-------- src/Network/Loaders/BAUUpdateLoader.cs | 6 +- src/Patches/Client/ClientPatch.cs | 4 +- src/Patches/Client/Discord/DiscordPatch.cs | 4 +- src/Patches/Client/VersionShowerPatch.cs | 2 +- .../Gameplay/Managers/HudManagerPatch.cs | 2 +- src/Patches/Unity/UnityWebRequestPatch.cs | 29 ++-- 15 files changed, 232 insertions(+), 155 deletions(-) create mode 100644 src/FodyWeavers.xml create mode 100644 src/FodyWeavers.xsd diff --git a/src/BAUPlugin.ModInfo.cs b/src/BAUPlugin.ModInfo.cs index f8dee4b..696f546 100644 --- a/src/BAUPlugin.ModInfo.cs +++ b/src/BAUPlugin.ModInfo.cs @@ -1,4 +1,4 @@ -using BetterAmongUs.Enums; +using Semver; using System.Reflection; namespace BetterAmongUs; @@ -11,9 +11,33 @@ internal partial class BAUPlugin internal static class ModInfo { /// - /// Gets the release type of the current build. + /// The base version number of the mod in MAJOR.MINOR.PATCH format. /// - internal static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Release; + internal const string VERSION_NUMBER = "1.3.4"; + + /// + /// The beta release number. Increment this for each beta release. + /// + internal const string BETA_NUMBER = "0"; + + /// + /// Gets the full version string for the current build configuration. + /// +#if RELEASE + internal const string VERSION = VERSION_NUMBER; +#elif BETA + internal const string VERSION = $"{VERSION_NUMBER}-beta-{BETA_NUMBER}"; +#endif + + /// + /// Gets the full version string with a v prefix for the current build configuration. + /// + internal const string VERSION_STRING = "v" + VERSION; + + /// + /// Gets the parsed semantic version of the mod. + /// + internal static readonly SemVersion SemVersion = SemVersion.Parse(VERSION); /// /// Gets the Git commit hash from assembly metadata. @@ -25,21 +49,6 @@ internal partial class BAUPlugin /// public static string BuildDate = ThisAssembly.Metadata.BuildDate; - /// - /// The beta number for beta releases. - /// - internal const string BETA_NUM = "0"; - - /// - /// The hotfix number for hotfix releases. - /// - internal const string HOTFIX_NUM = "1"; - - /// - /// Indicates whether this is a hotfix release. - /// - internal const bool IS_HOTFIX = true; - /// /// The name of BAU. /// @@ -50,11 +59,6 @@ internal partial class BAUPlugin /// internal const string PLUGIN_GUID = "com.d1gq.betteramongus"; - /// - /// The version of BAU. - /// - internal const string PLUGIN_VERSION = "1.3.3"; - /// /// Gets the list of supported Among Us versions. /// diff --git a/src/BAUPlugin.cs b/src/BAUPlugin.cs index f2a3405..87db49c 100644 --- a/src/BAUPlugin.cs +++ b/src/BAUPlugin.cs @@ -7,7 +7,6 @@ using BetterAmongUs.Attributes; using BetterAmongUs.Data; using BetterAmongUs.Data.Config; using BetterAmongUs.Data.Json; -using BetterAmongUs.Enums; using BetterAmongUs.Managers; using BetterAmongUs.Modules; using BetterAmongUs.Modules.OptionItems; @@ -22,42 +21,10 @@ using UnityEngine.SceneManagement; namespace BetterAmongUs; -[BepInPlugin(ModInfo.PLUGIN_GUID, ModInfo.PLUGIN_NAME, ModInfo.PLUGIN_VERSION)] +[BepInPlugin(ModInfo.PLUGIN_GUID, ModInfo.PLUGIN_NAME, ModInfo.VERSION)] [BepInProcess(ModInfo.AmongUs.PROCESS_NAME)] internal partial class BAUPlugin : BasePlugin { - /// - /// Gets the formatted version text for display. - /// - /// Whether to use newline separation for additional info. - /// Formatted version string. - internal static string GetVersionText(bool newLine = false) - { - string text = string.Empty; - - string newLineText = newLine ? "\n" : " "; - - switch (ModInfo.ReleaseBuildType) - { - case ReleaseTypes.Release: - text = $"v{BetterAmongUsVersion}"; - break; - case ReleaseTypes.Beta: - text = $"v{BetterAmongUsVersion}{newLineText}Beta {ModInfo.BETA_NUM}"; - break; - case ReleaseTypes.Dev: - text = $"v{BetterAmongUsVersion}{newLineText}Dev {ModInfo.CommitHash}-{ModInfo.BuildDate}"; - break; - default: - break; - } - - if (ModInfo.IS_HOTFIX) - text += $"{newLineText}Hotfix {ModInfo.HOTFIX_NUM}"; - - return text; - } - /// /// Gets the BAUPlugin instance. /// @@ -68,11 +35,6 @@ internal partial class BAUPlugin : BasePlugin /// internal static Harmony Harmony { get; } = new Harmony(ModInfo.PLUGIN_GUID); - /// - /// Gets the BetterAmongUs version string. - /// - internal static string BetterAmongUsVersion => ModInfo.PLUGIN_VERSION; - /// /// Gets the application version string. /// @@ -170,7 +132,7 @@ internal partial class BAUPlugin : BasePlugin Logger_.Log("Better Among Us successfully loaded!"); string SupportedVersions = string.Join(" ", ModInfo.SupportedAmongUsVersions); - Logger_.Log($"BetterAmongUs {BetterAmongUsVersion}-{ModInfo.BuildDate} - [{AppVersion} --> {SupportedVersions}] {Utils.GetPlatformName(PlatformData.Platform)}"); + Logger_.Log($"BetterAmongUs {ModInfo.VERSION_STRING}-{ModInfo.BuildDate} - [{AppVersion} --> {SupportedVersions}] {Utils.GetPlatformName(PlatformData.Platform)}"); } /// diff --git a/src/BetterAmongUs.csproj b/src/BetterAmongUs.csproj index 344b17c..1dc25e9 100644 --- a/src/BetterAmongUs.csproj +++ b/src/BetterAmongUs.csproj @@ -6,6 +6,7 @@ true Library preview + Debug;Release;Beta @@ -85,15 +86,19 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + runtime; compile; build; native; contentfiles; analyzers; buildtransitive + all + + all runtime; build; native; contentfiles; analyzers; buildtransitive - all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/BetterAmongUs.sln b/src/BetterAmongUs.sln index 6e51431..c2f354b 100644 --- a/src/BetterAmongUs.sln +++ b/src/BetterAmongUs.sln @@ -7,10 +7,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BetterAmongUs", "BetterAmon EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Beta|Any CPU = Beta|Any CPU Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {41193AE4-8181-49F8-9DA4-F4B7B275A0EA}.Beta|Any CPU.ActiveCfg = Beta|Any CPU + {41193AE4-8181-49F8-9DA4-F4B7B275A0EA}.Beta|Any CPU.Build.0 = Beta|Any CPU {41193AE4-8181-49F8-9DA4-F4B7B275A0EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {41193AE4-8181-49F8-9DA4-F4B7B275A0EA}.Debug|Any CPU.Build.0 = Debug|Any CPU {41193AE4-8181-49F8-9DA4-F4B7B275A0EA}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/Commands/DumpCommand.cs b/src/Commands/DumpCommand.cs index f6f9a01..f34c933 100644 --- a/src/Commands/DumpCommand.cs +++ b/src/Commands/DumpCommand.cs @@ -60,14 +60,14 @@ internal sealed class DumpCommand : BaseCommand { Directory.CreateDirectory(logFolderPath); } - string logFileName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bau" + ".log"; + string logFileName = "log-" + BAUPlugin.ModInfo.VERSION_STRING + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bau" + ".log"; string logFile = Path.Combine(logFolderPath, logFileName); File.WriteAllText(logFile, newLog); string bepInExLog = Path.Combine(Paths.BepInExRootPath, "LogOutput.log"); if (File.Exists(bepInExLog)) { - string logFileBepInExeName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bepinex" + ".log"; + string logFileBepInExeName = "log-" + BAUPlugin.ModInfo.VERSION_STRING + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bepinex" + ".log"; string logFileBepInExe = Path.Combine(logFolderPath, logFileBepInExeName); File.Copy(bepInExLog, logFileBepInExe); } @@ -93,14 +93,14 @@ internal sealed class DumpCommand : BaseCommand string androidLogContent = File.ReadAllText(logFilePath); string androidNewLog = DecryptLog(androidLogContent); - string androidLogFileName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bau" + ".log"; + string androidLogFileName = "log-" + BAUPlugin.ModInfo.VERSION_STRING + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bau" + ".log"; string androidNewLogFilePath = Path.Combine(logFolderPath, androidLogFileName); File.WriteAllText(androidNewLogFilePath, androidNewLog); string bepInExLog = Path.Combine(Paths.BepInExRootPath, "LogOutput.log"); if (File.Exists(bepInExLog)) { - string logFileBepInExeName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bepinex" + ".log"; + string logFileBepInExeName = "log-" + BAUPlugin.ModInfo.VERSION_STRING + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + "-bepinex" + ".log"; string logFileBepInExe = Path.Combine(logFolderPath, logFileBepInExeName); File.Copy(bepInExLog, logFileBepInExe); } diff --git a/src/FodyWeavers.xml b/src/FodyWeavers.xml new file mode 100644 index 0000000..7ab88d8 --- /dev/null +++ b/src/FodyWeavers.xml @@ -0,0 +1,8 @@ + + + + + Semver + + + \ No newline at end of file diff --git a/src/FodyWeavers.xsd b/src/FodyWeavers.xsd new file mode 100644 index 0000000..05e92c1 --- /dev/null +++ b/src/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/src/MonoScripts/BetterPingTracker.cs b/src/MonoScripts/BetterPingTracker.cs index 9137d68..aeace0b 100644 --- a/src/MonoScripts/BetterPingTracker.cs +++ b/src/MonoScripts/BetterPingTracker.cs @@ -84,7 +84,7 @@ internal sealed class BetterPingTracker : MonoBehaviour sb.AppendFormat("{0}: {1}\n", TranslationStrings.Timer.LocalizedString.ToUpper(), $"<{timeColor}>{lobbyTimerDisplay}"); } - sb.Append($"BetterAmongUs {BAUPlugin.GetVersionText(true)}\n"); + sb.Append($"BetterAmongUs {BAUPlugin.ModInfo.VERSION_STRING}\n"); sb.Append($"{BAUPlugin.ModInfo.GITHUB}\n".Size(52f)); if (BAUConfigs.ShowFPS.Value) diff --git a/src/Network/Configs/BAUUpdateData.cs b/src/Network/Configs/BAUUpdateData.cs index af87f85..291b1d8 100644 --- a/src/Network/Configs/BAUUpdateData.cs +++ b/src/Network/Configs/BAUUpdateData.cs @@ -1,5 +1,5 @@ -using BetterAmongUs.Enums; -using BetterAmongUs.Modules; +using BetterAmongUs.Modules; +using Semver; using System.Collections; using System.Text.Json.Serialization; using UnityEngine; @@ -12,6 +12,12 @@ namespace BetterAmongUs.Network.Configs; [Serializable] internal sealed class BAUUpdateData { + /// + /// Gets or sets the download link for the updated DLL file. + /// + [JsonPropertyName("valid")] + public bool Valid { get; set; } = false; + /// /// Gets or sets the download link for the updated DLL file. /// @@ -24,82 +30,23 @@ internal sealed class BAUUpdateData [JsonPropertyName("version")] public string Version { get; set; } = string.Empty; - /// - /// Gets or sets the release type as an integer value. - /// - [JsonPropertyName("releaseType")] - public int ReleaseType { get; set; } - - /// - /// Gets or sets whether this update is a hotfix. - /// - [JsonPropertyName("isHotfix")] - public bool IsHotfix { get; set; } - - /// - /// Gets or sets the hotfix number if this is a hotfix update. - /// - [JsonPropertyName("hotfixNumber")] - public int HotfixNumber { get; set; } - - /// - /// Gets or sets the beta number if this is a beta release. - /// - [JsonPropertyName("betaNumber")] - public int BetaNumber { get; set; } - /// /// Determines if this update is newer than the currently installed version. /// /// True if the update is newer, false otherwise. - /// - /// Compares version numbers, release types, and specific build numbers - /// to determine if an update should be applied. - /// internal bool IsNewUpdate() { try { - var updateVersion = new Version(Version); - var modVersion = new Version(BAUPlugin.ModInfo.PLUGIN_VERSION); - - // 1. Compare main version (major.minor.build) - if (updateVersion > modVersion) - { - return true; - } - else if (updateVersion < modVersion) + if (!Valid) { return false; } - // 2. Versions are equal, compare release types - var updateReleaseType = (ReleaseTypes)ReleaseType; - var currentReleaseType = BAUPlugin.ModInfo.ReleaseBuildType; + var updateVersion = SemVersion.Parse(Version); + var modVersion = BAUPlugin.ModInfo.SemVersion; - // Release is always preferred over Beta - if (updateReleaseType == ReleaseTypes.Release && currentReleaseType == ReleaseTypes.Beta) - return true; - - // Don't downgrade from Release to Beta - if (updateReleaseType == ReleaseTypes.Beta && currentReleaseType == ReleaseTypes.Release) - return false; - - // 3. Same version and release type, compare specific numbers - if (updateReleaseType == ReleaseTypes.Beta) - { - return BetaNumber > int.Parse(BAUPlugin.ModInfo.BETA_NUM); - } - - // Release version - check hotfixes - if (IsHotfix && !BAUPlugin.ModInfo.IS_HOTFIX) - return true; - - if (IsHotfix && BAUPlugin.ModInfo.IS_HOTFIX) - return HotfixNumber > int.Parse(BAUPlugin.ModInfo.HOTFIX_NUM); - - // Same version, same type, no newer hotfix - return false; + return updateVersion.ComparePrecedenceTo(modVersion) > 0; } catch (Exception ex) { @@ -152,6 +99,6 @@ internal sealed class BAUUpdateData /// A formatted string containing version information. public override string ToString() { - return $"{Version}:{ReleaseType}:{BetaNumber}:{HotfixNumber}"; + return $"{SemVersion.Parse(Version)}"; } } \ No newline at end of file diff --git a/src/Network/Loaders/BAUUpdateLoader.cs b/src/Network/Loaders/BAUUpdateLoader.cs index 194cf01..de9a25a 100644 --- a/src/Network/Loaders/BAUUpdateLoader.cs +++ b/src/Network/Loaders/BAUUpdateLoader.cs @@ -25,10 +25,6 @@ internal sealed class BAUUpdateLoader : MonoBehaviour /// Coroutine to fetch update data from the remote repository. /// /// IEnumerator for coroutine execution. - /// - /// If no internet connection is detected, it retries several times before giving up. - /// After successfully loading update data, it initializes the UpdateManager. - /// [HideFromIl2Cpp] internal IEnumerator CoFetchUpdateData() { @@ -47,7 +43,7 @@ internal sealed class BAUUpdateLoader : MonoBehaviour } string callBack = ""; - yield return GitHubFile.CoFetchTextFile(GitUrlPath.RepositoryApi.Combine("update.json").ToString(), (string text) => + yield return GitHubFile.CoFetchTextFile(GitUrlPath.RepositoryApi.Combine("update-V2.json").ToString(), (string text) => { callBack = text; }); diff --git a/src/Patches/Client/ClientPatch.cs b/src/Patches/Client/ClientPatch.cs index da3d86a..3f5f162 100644 --- a/src/Patches/Client/ClientPatch.cs +++ b/src/Patches/Client/ClientPatch.cs @@ -56,7 +56,7 @@ internal static class ClientPatch // Show warning popup for newer Among Us version Utils.ShowPopUp($"-= Warning =-\n\n" + - $"Better Among Us {BAUPlugin.GetVersionText()}\nsupports Among Us {verText},\n" + + $"Better Among Us {BAUPlugin.ModInfo.VERSION_STRING}\nsupports Among Us {verText},\n" + $"Among Us {BAUPlugin.AppVersion} is above the supported versions!\n" + $"You may encounter minor to game breaking bugs."); } @@ -71,7 +71,7 @@ internal static class ClientPatch // Show warning popup for older Among Us version Utils.ShowPopUp($"-= Warning =-\n\n" + - $"Better Among Us {BAUPlugin.GetVersionText()}\nsupports Among Us {verText},\n" + + $"Better Among Us {BAUPlugin.ModInfo.VERSION_STRING}\nsupports Among Us {verText},\n" + $"Among Us {BAUPlugin.AppVersion} is below the supported versions!\n" + $"You may encounter minor to game breaking bugs."); } diff --git a/src/Patches/Client/Discord/DiscordPatch.cs b/src/Patches/Client/Discord/DiscordPatch.cs index 895a98d..d93f9da 100644 --- a/src/Patches/Client/Discord/DiscordPatch.cs +++ b/src/Patches/Client/Discord/DiscordPatch.cs @@ -23,7 +23,7 @@ internal static class DiscordPatch if (activity == null) return; - string details = $"BAU {BAUPlugin.GetVersionText()}"; + string details = $"BAU {BAUPlugin.ModInfo.VERSION_STRING}"; activity.Details = details; // Skip lobby info processing if Discord already shows "In Menus" @@ -50,7 +50,7 @@ internal static class DiscordPatch { // Streamer mode hides lobby code, only show mode info if (GameState.IsHideNSeek) - details = $"BAU v{BAUPlugin.ModInfo.PLUGIN_VERSION} - Hide & Seek"; + details = $"BAU v{BAUPlugin.ModInfo.VERSION_STRING} - Hide & Seek"; } } catch diff --git a/src/Patches/Client/VersionShowerPatch.cs b/src/Patches/Client/VersionShowerPatch.cs index 9a10548..fdef30d 100644 --- a/src/Patches/Client/VersionShowerPatch.cs +++ b/src/Patches/Client/VersionShowerPatch.cs @@ -13,6 +13,6 @@ internal static class VersionShowerPatch { string mark = TranslationStrings.BAUMark.LocalizedString; string bau = TranslationStrings.BAU.LocalizedString; - __instance.text.text = $"{mark}{bau}{mark} {BAUPlugin.GetVersionText()} ~ {Utils.GetPlatformName(BAUPlugin.PlatformData.Platform)} v{BAUPlugin.AmongUsVersion} ({BAUPlugin.AppVersion})"; + __instance.text.text = $"{mark}{bau}{mark} {BAUPlugin.ModInfo.VERSION_STRING} ~ {Utils.GetPlatformName(BAUPlugin.PlatformData.Platform)} v{BAUPlugin.AmongUsVersion} ({BAUPlugin.AppVersion})"; } } diff --git a/src/Patches/Gameplay/Managers/HudManagerPatch.cs b/src/Patches/Gameplay/Managers/HudManagerPatch.cs index d5ae239..daf6449 100644 --- a/src/Patches/Gameplay/Managers/HudManagerPatch.cs +++ b/src/Patches/Gameplay/Managers/HudManagerPatch.cs @@ -13,7 +13,7 @@ namespace BetterAmongUs.Patches.Gameplay.Managers; [HarmonyPatch] internal static class HudManagerPatch { - internal static string WelcomeMessage => $"{TranslationStrings.WelcomeMsg_WelcomeToBAU.Format(TranslationStrings.BetterAmongUs)}\n{BAUPlugin.GetVersionText()}\n" + + internal static string WelcomeMessage => $"{TranslationStrings.WelcomeMsg_WelcomeToBAU.Format(TranslationStrings.BetterAmongUs)}\n{BAUPlugin.ModInfo.VERSION_STRING}\n" + $"{TranslationStrings.WelcomeMsg_ThanksForDownloading}\n \n" + TranslationStrings.WelcomeMsg_BAUDescription1.Format(TranslationStrings.BAU, TranslationStrings.BetterOption_AntiCheat); diff --git a/src/Patches/Unity/UnityWebRequestPatch.cs b/src/Patches/Unity/UnityWebRequestPatch.cs index cef2c01..deabc9d 100644 --- a/src/Patches/Unity/UnityWebRequestPatch.cs +++ b/src/Patches/Unity/UnityWebRequestPatch.cs @@ -10,21 +10,32 @@ namespace BetterAmongUs.Patches.Unity; [HarmonyPatch] internal static class UnityWebRequestPatch { - // Build mod version header string + /// + /// Builds a mod version header string for network transmission. + /// Format: "major;minor;patch;metadata1/metadata2/metadata3" + /// public static string GetHeader() { var stringBuilder = new StringBuilder(); + var version = BAUPlugin.ModInfo.SemVersion; - // Format: "Version;BuildType;IsHotfix/HotfixNum/BetaNum" - stringBuilder.Append(BAUPlugin.ModInfo.PLUGIN_VERSION); + stringBuilder.Append(version.Major); stringBuilder.Append(';'); - stringBuilder.Append(Enum.GetName(BAUPlugin.ModInfo.ReleaseBuildType)); + stringBuilder.Append(version.Minor); stringBuilder.Append(';'); - stringBuilder.Append(BAUPlugin.ModInfo.IS_HOTFIX); - stringBuilder.Append('/'); - stringBuilder.Append(BAUPlugin.ModInfo.HOTFIX_NUM); - stringBuilder.Append('/'); - stringBuilder.Append(BAUPlugin.ModInfo.BETA_NUM); + stringBuilder.Append(version.Patch); + stringBuilder.Append(';'); + + var buildMetadata = version.Metadata; + if (buildMetadata.Length > 0) + { + for (int i = 0; i < buildMetadata.Length; i++) + { + stringBuilder.Append(buildMetadata[i]); + if (i < buildMetadata.Length - 1) + stringBuilder.Append('/'); + } + } return stringBuilder.ToString(); }