예제 #1
0
        /// <summary>
        ///     Configures the SQL Server services.
        /// </summary>
        /// <param name="services">The services collection to register services in.</param>
        /// <param name="configuration">The SQL Server configuration.</param>
        public static void Configure(IServiceCollection services, ISqlServerConfiguration configuration)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            // register configuration
            RegisterConfiguration(services: services, configuration: configuration);

            // Register shared services.
            RegisterDatabaseServices(services);

            SendTransactions.Configure(services);
            EventTransactions.Configure(services);
            ServerAccounts.Configure(services);
            ObjectLocking.Configure(services);
            FaucetTracking.Configure(services);
            Player.Configure(services);
            GameSupport.Configure(services);
        }
예제 #2
0
        void InitGameState(GameState state)
        {
            string absoluteGameDir;

            state.GameProcess.ReadString(state.GameOffsets.GameDirPtr, ReadStringType.UTF8, 260, out absoluteGameDir);
            state.GameDir = new DirectoryInfo(absoluteGameDir).Name.ToLower();
            Debug.WriteLine("gameDir = " + state.GameDir);

            state.CurrentMap = String.Empty;

            // inspect memory layout to determine CEntInfo's version
            const int SERIAL_MASK = 0x7FFF;
            int       serial;

            state.GameProcess.ReadValue(state.GameOffsets.GlobalEntityListPtr + (4 * 7), out serial);
            state.GameOffsets.EntInfoSize = (serial > 0 && serial < SERIAL_MASK) ? CEntInfoSize.Portal2 : CEntInfoSize.HL2;

            state.GameSupport = GameSupport.FromGameDir(state.GameDir);
            if (state.GameSupport != null)
            {
                Debug.WriteLine("running game-specific code for: " + state.GameDir);
                state.GameSupport.OnGameAttached(state);
            }
            this.SendSetTimingMethodEvent(state.GameSupport?.GameTimingMethod ?? GameTimingMethod.EngineTicks);
        }
예제 #3
0
        public void SetSettings(XmlNode settings)
        {
            var element = (XmlElement)settings;

            AutoStart            = SettingsHelper.ParseBool(settings["AutoStart"], DEFAULT_AUTOSTART);
            AutoReset            = SettingsHelper.ParseBool(settings["AutoReset"], DEFAULT_AUTOSTART);
            AutoSplitOnMapChange = SettingsHelper.ParseBool(settings["AutoSplitOnMapChange"], DEFAULT_AUTOSPLITONMAPCHANGE);
            AutoSplitOncePerMap  = SettingsHelper.ParseBool(settings["AutoSplitOncePerMap"], DEFAULT_AUTOSPLITONCEPERMAP);

            GameSupport game = null;

            if (!string.IsNullOrWhiteSpace(settings["Game"]?.InnerText))
            {
                game = SearchGameSupport(settings["Game"].InnerText);
            }

            if (game == null)
            {
                game = SearchGameSupport(_state.Run.GameName) ?? _gameSupportList.First();
            }

            cbGame.SelectedItem = game.GetType();

            if (settings["MapWhitelist"] != null)
            {
                var mapnames = from map in Maps
                               select map.Name;

                if (SettingsHelper.ParseVersion(settings["Version"]) > new Version(1, 6, 1))
                {
                    foreach (XmlElement elem in settings["MapWhitelist"].ChildNodes)
                    {
                        if (mapnames.Contains(elem.InnerText, StringComparer.OrdinalIgnoreCase))
                        {
                            var curMap = (from map in Maps
                                          where map.Name == elem.InnerText
                                          select map).First();
                            curMap.SplitOnEnter = bool.Parse(string.IsNullOrEmpty(elem.GetAttribute("SplitOnEnter")) ? "False" : elem.GetAttribute("SplitOnEnter"));
                            curMap.SplitOnLeave = bool.Parse(string.IsNullOrEmpty(elem.GetAttribute("SplitOnLeave")) ? "False" : elem.GetAttribute("SplitOnLeave"));
                        }
                    }
                }
                else
                //backwards compatibility
                {
                    foreach (XmlElement elem in settings["MapWhitelist"].ChildNodes)
                    {
                        if (mapnames.Contains(elem.InnerText, StringComparer.OrdinalIgnoreCase))
                        {
                            var curMap = (from map in Maps
                                          where map.Name == elem.InnerText
                                          select map).First();
                            curMap.SplitOnEnter = bool.Parse(string.IsNullOrEmpty(elem.GetAttribute("enabled")) ? "False" : elem.GetAttribute("enabled"));
                            curMap.SplitOnLeave = false;
                        }
                    }
                }
            }
        }
예제 #4
0
        Process GetGameProcess()
        {
            Process game = null;

            var processes = SupportedProcessesNames.SelectMany(n => Process.GetProcessesByName(n))
                            .OrderByDescending(p => p.StartTime);

            foreach (var p in processes)
            {
                if (p.HasExited || _ignorePIDs.Contains(p.Id))
                {
                    continue;
                }

                var ignoreProcess = true;
                foreach (var gameSupport in SupportedGames)
                {
                    if (!gameSupport.ProcessNames.Contains(p.ProcessName.ToLower()))
                    {
                        continue;
                    }

                    var modules = p.ModulesWow64Safe();
                    if (!gameSupport.GetHookModules().All(hook_m =>
                                                          modules.Any(m => hook_m.ToLower() == m.ModuleName.ToLower())))
                    {
                        ignoreProcess = false;
                        continue;
                    }

                    switch (gameSupport.IdentifyProcess(p))
                    {
                    case IdentificationResult.Success:
                        game = p;
                        Game = gameSupport;
                        break;

                    case IdentificationResult.Undecisive:
                        ignoreProcess = false;                                 // don't ignore if at least one game is unsure
                        break;
                    }

                    if (game != null)
                    {
                        break;
                    }
                }

                if (game != null)
                {
                    break;
                }

                if (ignoreProcess)
                {
                    _ignorePIDs.Add(p.Id);
                }
            }

            if (game == null)
            {
                return(null);
            }

            if (_lastPID != game.Id)
            {
                _watchers.Clear();

                if (!Patch(game))
                {
                    return(null);
                }

                var stringType = _loadMapHook == null || _loadMapHook.Encoding == StringType.ASCII
                                        ? ReadStringType.ASCII
                                        : ReadStringType.UTF16;
                _map = new StringWatcher(_mapPtr, stringType, MAP_SIZE)
                {
                    Name = "map"
                };

                _status = new MemoryWatcher <int>(_statusPtr)
                {
                    Name = "status"
                };
                _watchers.AddRange(new MemoryWatcher[] { _status, _map });
            }

            _lastPID = game.Id;
            return(game);
        }