Esempio n. 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);
        }
Esempio n. 2
0
 public void OnGameHostResponse(HostedGameData data)
 {
     if (_waitingRequestId != data.Id)
     {
         return;
     }
     lock (_users)
     {
         Log.InfoFormat("[{0}] Got Hosted Game Data {1}", this, data);
         if (State != MatchmakingQueueState.WaitingForHostedGame)
         {
             // Actually this can happen if someone cancels out of the queue
             //Log.Fatal("Timeed out before hosted game could be returned. Need to increase timeout.");
             //this._hostGameTimeout.When = new TimeSpan(0,0,(int)_hostGameTimeout.When.TotalSeconds + 5);
             return;
         }
         // Send all users a message telling them the info they need to connect to game server
         // Kick all the users from the queue.
         var message = new Message(new Jid("*****@*****.**"), MessageType.normal, "", "gameready");
         message.ChildNodes.Add(data);
         Log.InfoFormat("[{0}] Sending users game data", this);
         foreach (var u in _users.Where(x => x.IsInReadyQueue).ToArray())
         {
             message.To = u.JidUser;
             message.GenerateId();
             this.Bot.Xmpp.Send(message);
             _users.Remove(u);
         }
         // set time to game
         AverageTime.Cycle();
         State = MatchmakingQueueState.WaitingForUsers;
     }
 }
Esempio n. 3
0
        public void SendGameReady(HostedGameData game)
        {
            var m = new Message(game.Username + "@of.octgn.net", MessageType.normal, "", "gameready");

            m.GenerateId();
            m.AddChild(game);
            Xmpp.Send(m);
        }
 public GameInviteNotification(InviteToGame invite, HostedGameData hostedGame, Game game)
 {
     HostedGame = hostedGame;
     Invite     = invite;
     Game       = game;
     Title      = "Game Invite";
     Message    = String.Format("{0} Has invited you to the game '{1}'", invite.From.UserName, hostedGame.Name);
     ImageUrl   = game.IconUrl;
 }
Esempio n. 5
0
        public HostedGameCellData(CancellationTokenSource cancellationTokenSource, Action <HostedGameCellData> onContentChange, HostedGameData game)
            : base("A game", "Getting details...", Sprites.BeatSaverIcon)
        {
            _cancellationTokenSource = cancellationTokenSource;
            _onContentChange         = onContentChange;

            Game = game;

            UpdateUi();
        }
        public GameInviteNotification(InviteToGame invite, GameDetails g, Game game)
        {
            var hg = new HostedGameData(g.Id, g.GameId, g.GameVersion, g.Port, g.Name, new User(g.Host + "@of.octgn.net"), g.DateCreated, g.GameName,
                                        g.GameIconUrl, g.PasswordProtected, IPAddress.Parse(g.IpAddress), HostedGameSource.Online, g.InProgress ? EHostedGame.GameInProgress : EHostedGame.StartedHosting, g.AllowsSpectators);

            HostedGame = hg;
            Invite     = invite;
            Game       = game;
            Title      = "Game Invite";
            Message    = String.Format("{0} Has invited you to the game '{1}'", invite.From.UserName, g.Name);
            ImageUrl   = game.IconUrl;
        }
        public static void ConnectToHostedGame(HostedGameData game)
        {
            if (game == null || string.IsNullOrEmpty(game.ServerCode))
            {
                return;
            }

            MpModeSelection.WeInitiatedConnection   = true;
            MpModeSelection.LastConnectToHostedGame = game;

            _mpLobbyConnectionController.ConnectToParty(game.ServerCode);
            _joiningLobbyViewController.Init($"{game.GameName} ({game.ServerCode})");

            ReplaceTopViewController(_joiningLobbyViewController, animationDirection: ViewController.AnimationDirection.Vertical);
        }
Esempio n. 8
0
        public static async Task <Sprite> GetCoverArtSprite(HostedGameData hostedGame, CancellationToken token)
        {
            if (!string.IsNullOrEmpty(hostedGame.CoverUrl))
            {
                // Server already knows cover art URL, saves us a trip to the beatsaver api
                var downloadedCover = await FetchCoverArtBytesForUrl(hostedGame.CoverUrl, token);

                if (downloadedCover != null)
                {
                    var sprite = Sprites.LoadSpriteRaw(downloadedCover);
                    sprite.name = hostedGame.LevelId;
                    return(sprite);
                }
            }

            return(await GetCoverArtSprite(hostedGame.LevelId, token));
        }
Esempio n. 9
0
        public HostedGameViewModel(HostedGameData data)
        {
            var game = Program.GamesRepository.Games.FirstOrDefault(x => x.Id == data.GameGuid);

            this.GameId      = data.GameGuid;
            this.GameVersion = data.GameVersion;
            this.Name        = data.Name;
            this.User        = data.UserHosting;
            this.Port        = data.Port;
            this.Status      = data.GameStatus;
            this.StartTime   = data.TimeStarted;
            this.GameName    = "{Unknown Game}";
            if (game == null)
            {
                return;
            }
            this.CanPlay  = true;
            this.GameName = game.Name;
        }
Esempio n. 10
0
        public HostedGameViewModel(HostedGameData data)
        {
            var game = GameManager.Get().GetById(data.GameGuid);

            this.GameId      = data.GameGuid;
            this.GameVersion = data.GameVersion;
            this.Name        = data.Name;
            this.User        = data.UserHosting;
            this.Port        = data.Port;
            this.Status      = data.GameStatus;
            this.StartTime   = data.TimeStarted;
            this.GameName    = "{Unknown Game}";
            if (game == null)
            {
                return;
            }
            this.CanPlay  = true;
            this.GameName = game.Name;
        }
Esempio n. 11
0
        private void OnGameReady(HostedGameData obj)
        {
            try
            {
                Log.InfoFormat("Game is ready {0}", obj);
                _lastMatchmakingMessage = DateTime.Now;
                Log.Info("Getting game...");
                var game = GameManager.Get().GetById(obj.GameGuid);
                Program.LobbyClient.CurrentHostedGamePort = (int)obj.Port;
                //Program.GameSettings.UseTwoSidedTable = true;
                Log.Info("Creating game engine");
                Program.GameEngine    = new GameEngine(game, Program.LobbyClient.Me.UserName, false, this._currentQueue.ToString().ToLower());
                Program.IsHost        = false;
                Program.IsMatchmaking = true;
                Program.GameMode      = this._mode;

                var hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).First();

                // Should use gameData.IpAddress sometime.
                Program.Client = new ClientSocket(hostAddress, (int)obj.Port);
                Log.Info("Connecting...");
                Program.Client.Connect();
                this._dispatcher.Invoke(new Action(() =>
                {
                    Log.Info("Launching play window");
                    WindowManager.PlayWindow = new PlayWindow();
                    WindowManager.PlayWindow.Show();
                    Log.Info("Finished launching play window");
                }));
            }
            catch (Exception e)
            {
                Log.Warn("Error joining matchmaking game", e);
                TopMostMessageBox.Show("Can't join matchmaking game, there is a problem with your connection.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ResetToBeginning();
        }
Esempio n. 12
0
        //public IHostedGameData Data { get; set; }

        public HostedGameViewModel(HostedGameData data)
        {
            //Data = data;
            var game = GameManager.Get().GetById(data.GameGuid);

            this.Id          = data.Id;
            this.GameId      = data.GameGuid;
            this.GameVersion = data.GameVersion;
            this.Name        = data.Name;
            this.User        = data.Username;
            this.Port        = data.Port;
            this.Status      = data.GameStatus;
            this.StartTime   = data.TimeStarted;
            this.GameName    = data.GameName;
            this.HasPassword = data.HasPassword;
            this.Visible     = true;
            this.Spectator   = data.Spectator;
            UpdateVisibility();
            switch (data.Source)
            {
            case HostedGameSource.Online:
                GameSource = "Online";
                break;

            case HostedGameSource.Lan:
                GameSource = "Lan";
                break;
            }
            if (game == null)
            {
                return;
            }
            this.CanPlay   = true;
            this.GameName  = game.Name;
            this.IPAddress = data.IpAddress;
        }
Esempio n. 13
0
 public HostedGameListItem(HostedGameData g)
 {
     InitializeComponent();
     Game = g;
 }
 private void ClearSelection()
 {
     GameList?.tableView?.ClearSelection();
     ConnectButton.interactable = false;
     _selectedGame = null;
 }
Esempio n. 15
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);
        }