示例#1
0
        public static void Join(HostedGameData game)
        {
            if (game.MasterServerHost == null || game.MasterServerHost.EndsWith(OFFICIAL_MASTER_SUFFIX))
            {
                // Game is hosted on the player platform's official master server
                if (_usingModdedServer || _officialEndPoint == null)
                {
                    // If we normally use a modded server, we need to fall back to official servers manually
                    if (Plugin.PlatformId == Plugin.PLATFORM_OCULUS)
                    {
                        SetMasterServerOverride(OFFICIAL_MASTER_OCULUS);
                    }
                    else
                    {
                        SetMasterServerOverride(OFFICIAL_MASTER_STEAM);
                    }
                }
                else
                {
                    // Clearing the override should fall back to the correct official server
                    ClearMasterServerOverride();
                }
            }
            else
            {
                // Game is hosted on a custom master server, we need to override
                SetMasterServerOverride(game.MasterServerHost, game.MasterServerPort.HasValue ? game.MasterServerPort.Value : DEFAULT_MASTER_PORT);
            }

            // Trigger the actual join via server code
            MpModeSelection.ConnectToHostedGame(game);
        }
示例#2
0
        public static void Join(HostedGameData game)
        {
            // MpEx version check
            if (game.MpExVersion != null)
            {
                var ourMpExVersion = MpExHelper.GetInstalledVersion();

                if (ourMpExVersion == null || !ourMpExVersion.Equals(game.MpExVersion))
                {
                    var ourMpExVersionStr   = (ourMpExVersion != null ? ourMpExVersion.ToString() : "Not installed");
                    var theirMpExVersionStr = game.MpExVersion.ToString();

                    Plugin.Log.Warn($"Blocking game join because of MultiplayerExtensions version mismatch " +
                                    $"(ours: {ourMpExVersionStr}, theirs: {theirMpExVersionStr})");

                    var mpExError = new StringBuilder();
                    mpExError.AppendLine($"MultiplayerExtensions version difference detected!");
                    mpExError.AppendLine($"Please ensure you and the host are both using the latest version.");
                    mpExError.AppendLine();
                    mpExError.AppendLine($"Your version: {ourMpExVersionStr}");
                    mpExError.AppendLine($"Their version: {theirMpExVersionStr}");

                    MpModeSelection.PresentConnectionFailedError
                    (
                        errorTitle: "Incompatible game",
                        errorMessage: mpExError.ToString(),
                        canRetry: false
                    );
                    return;
                }
            }

            // Master server switching
            if (game.MasterServerHost == null || game.MasterServerHost.EndsWith(OFFICIAL_MASTER_SUFFIX))
            {
                // Game is hosted on the player platform's official master server
                if (_usingModdedServer || _officialEndPoint == null)
                {
                    // If we normally use a modded server (e.g. because BeatTogether is installed), we need to now force-connect to our official server
                    switch (MpLocalPlayer.Platform)
                    {
                    case UserInfo.Platform.Oculus:
                        SetMasterServerOverride(OFFICIAL_MASTER_OCULUS);
                        break;

                    case UserInfo.Platform.PS4:
                        // lmao
                        SetMasterServerOverride(OFFICIAL_MASTER_PS4);
                        break;

                    case UserInfo.Platform.Test:
                        // hmmm
                        SetMasterServerOverride(OFFICIAL_MASTER_TEST);
                        break;

                    default:
                    case UserInfo.Platform.Steam:
                    case null:
                        SetMasterServerOverride(OFFICIAL_MASTER_STEAM);
                        break;
                    }
                }
                else
                {
                    // Clearing the override should fall back to the correct official server
                    ClearMasterServerOverride();
                }
            }
            else
            {
                // Game is hosted on a custom master server, we need to override
                SetMasterServerOverride(game.MasterServerHost, game.MasterServerPort.HasValue ? game.MasterServerPort.Value : DEFAULT_MASTER_PORT);
            }

            // Trigger the actual join via server code
            MpModeSelection.ConnectToHostedGame(game);
        }