Skip to content

Commit

Permalink
Add incompatible lobby host version message
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-r-elp committed Dec 29, 2024
1 parent f58befe commit f6a8421
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions MultiplayerCore/Patches/MultiplayerUnavailableReasonPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,47 @@ private static bool LocalizeMultiplayerUnavailableReason(MultiplayerUnavailableR
var metadata = PluginManager.GetPluginFromId(_requiredMod);
__result = $"Multiplayer Unavailable\nMod {metadata.Name} is missing or out of date\nPlease install version {_requiredVersion} or newer";
return false;
} else if (multiplayerUnavailableReason == (MultiplayerUnavailableReason)6)
}
if (multiplayerUnavailableReason == (MultiplayerUnavailableReason)6)
{
__result = $"Multiplayer Unavailable\nBeat Saber version is too new\nMaximum version: {_maximumBsVersion}\nCurrent version: {UnityGame.GameVersion.ToString()}";
__result = $"Multiplayer Unavailable\nBeat Saber version is too new\nMaximum version: {_maximumBsVersion}\nCurrent version: {UnityGame.GameVersion}";
return false;
}
return true;
}
}

[HarmonyPrefix]
[HarmonyPatch(typeof(ConnectionFailedReasonMethods), nameof(ConnectionFailedReasonMethods.LocalizedKey))]
private static bool LocalizeConnectionFailedReason(ConnectionFailedReason connectionFailedReason,
ref string __result)
{
if (connectionFailedReason == (ConnectionFailedReason)50)
{
//__result = "CONNECTION_FAILED_VERSION_MISMATCH"; // Would show an "Update the game message"
__result =
$"Game Version Mismatch\n" +
$"Your Beat Saber version is not compatible with the lobby hosts\n" +
$"You may need to either downgrade or update your game";
return false;
}

return true;
}

[HarmonyPrefix]
[HarmonyPatch(typeof(MultiplayerPlacementErrorCodeMethods), nameof(MultiplayerPlacementErrorCodeMethods.ToConnectionFailedReason))]
private static bool ToConnectionFailedReason(MultiplayerPlacementErrorCode errorCode,
ref ConnectionFailedReason __result)
{
Plugin.Logger.Debug($"Got MPEC-{errorCode}");
if ((int)errorCode >= 50)
{
__result = (ConnectionFailedReason)errorCode;
return false;
}

return true;
}

}
}

0 comments on commit f6a8421

Please sign in to comment.