Skip to content

Commit f6a8421

Browse files
committed
Add incompatible lobby host version message
1 parent f58befe commit f6a8421

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

MultiplayerCore/Patches/MultiplayerUnavailableReasonPatches.cs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,47 @@ private static bool LocalizeMultiplayerUnavailableReason(MultiplayerUnavailableR
6666
var metadata = PluginManager.GetPluginFromId(_requiredMod);
6767
__result = $"Multiplayer Unavailable\nMod {metadata.Name} is missing or out of date\nPlease install version {_requiredVersion} or newer";
6868
return false;
69-
} else if (multiplayerUnavailableReason == (MultiplayerUnavailableReason)6)
69+
}
70+
if (multiplayerUnavailableReason == (MultiplayerUnavailableReason)6)
7071
{
71-
__result = $"Multiplayer Unavailable\nBeat Saber version is too new\nMaximum version: {_maximumBsVersion}\nCurrent version: {UnityGame.GameVersion.ToString()}";
72+
__result = $"Multiplayer Unavailable\nBeat Saber version is too new\nMaximum version: {_maximumBsVersion}\nCurrent version: {UnityGame.GameVersion}";
7273
return false;
7374
}
7475
return true;
7576
}
76-
}
77+
78+
[HarmonyPrefix]
79+
[HarmonyPatch(typeof(ConnectionFailedReasonMethods), nameof(ConnectionFailedReasonMethods.LocalizedKey))]
80+
private static bool LocalizeConnectionFailedReason(ConnectionFailedReason connectionFailedReason,
81+
ref string __result)
82+
{
83+
if (connectionFailedReason == (ConnectionFailedReason)50)
84+
{
85+
//__result = "CONNECTION_FAILED_VERSION_MISMATCH"; // Would show an "Update the game message"
86+
__result =
87+
$"Game Version Mismatch\n" +
88+
$"Your Beat Saber version is not compatible with the lobby hosts\n" +
89+
$"You may need to either downgrade or update your game";
90+
return false;
91+
}
92+
93+
return true;
94+
}
95+
96+
[HarmonyPrefix]
97+
[HarmonyPatch(typeof(MultiplayerPlacementErrorCodeMethods), nameof(MultiplayerPlacementErrorCodeMethods.ToConnectionFailedReason))]
98+
private static bool ToConnectionFailedReason(MultiplayerPlacementErrorCode errorCode,
99+
ref ConnectionFailedReason __result)
100+
{
101+
Plugin.Logger.Debug($"Got MPEC-{errorCode}");
102+
if ((int)errorCode >= 50)
103+
{
104+
__result = (ConnectionFailedReason)errorCode;
105+
return false;
106+
}
107+
108+
return true;
109+
}
110+
111+
}
77112
}

0 commit comments

Comments
 (0)