Exemplo n.º 1
0
        public bool Equals(GameLaunchData other)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            if (ReferenceEquals(other, this))
            {
                return(true);
            }

            if (other.RequestId != RequestId)
            {
                return(false);
            }

            if (other.LaunchId != LaunchId)
            {
                return(false);
            }

            if (other.EndReason != EndReason)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void MergeFrom(GameLaunchData other)
        {
            if (other.RequestId != null)
            {
                RequestId = other.RequestId;
            }

            if (other.LaunchId != null)
            {
                LaunchId = other.LaunchId;
            }

            if (other.EndReason.HasValue)
            {
                EndReason = other.EndReason;
            }
        }
Exemplo n.º 3
0
        public void Launch(string gameKey, GameLaunchData data)
        {
            try
            {
                GameConfig gameConfig = _gamesConfigProvider.Get(gameKey);

                string launchString = gameConfig.LaunchParams
                                      .Replace("%LOGIN%", data.Login).Replace("%PASS%", data.Password);
                string launchParams = string.Join(" ", launchString, data.Arguments);

                InstalledGameInfo gameInfo = _gameRepository.GetOrDefault(gameConfig.EnvKey);

                string gameLaunchPath = GetFullGamePath(gameInfo.Path, data.Version);

                if (!File.Exists(gameLaunchPath))
                {
                    throw new GameStartException(
                              gameKey,
                              "game_exe_not_found",
                              $"Not found game exe by path {gameLaunchPath}");
                }

                string directoryName = Path.GetDirectoryName(gameLaunchPath);

                ProcessStartInfo startInfo = new ProcessStartInfo {
                    FileName         = gameLaunchPath,
                    WorkingDirectory = directoryName,
                    Arguments        = launchParams
                };

                Process process = Process.Start(startInfo);

                if (process == null || process.HasExited)
                {
                    throw new GameStartException(
                              gameKey, "game_exe_not_found", $"Not started game exe {gameLaunchPath}");
                }
            }
            catch (Exception)
            {
            }
        }