예제 #1
0
        public override void Init(string[] args)
        {
            Tick      = 0;
            StartTime = 0;
            SendRconCommandsClients = new Queue <int>();
            GameTypes       = new Dictionary <string, Type>();
            SnapshotIdPool  = new SnapshotIdPool();
            SnapshotBuilder = new SnapshotBuilder();

            Config        = Kernel.Get <BaseConfig>();
            GameContext   = Kernel.Get <BaseGameContext>();
            Storage       = Kernel.Get <BaseStorage>();
            NetworkServer = Kernel.Get <BaseNetworkServer>();
            Console       = Kernel.Get <BaseGameConsole>();
            Register      = Kernel.Get <BaseRegister>();
            NetworkBan    = Kernel.Get <BaseNetworkBan>();

            if (Config == null ||
                GameContext == null ||
                Storage == null ||
                NetworkServer == null ||
                Console == null)
            {
                throw new Exception("Register components fail");
            }

            Clients = new BaseServerClient[MaxClients];
            for (var i = 0; i < Clients.Length; i++)
            {
                Clients[i] = Kernel.Get <BaseServerClient>();
            }

            Storage.Init("TeeSharp", StorageType.Server);
            Config.Init(ConfigFlags.Server | ConfigFlags.Econ);
            Console.CommandAdded += ConsoleOnCommandAdded;
            Console.Init();
            PrintCallbackInfo = Console.RegisterPrintCallback(
                (OutputLevel)Config["ConsoleOutputLevel"].AsInt(), OnConsolePrint);
            NetworkServer.Init();

            GameContext.BeforeInit();

            var useDefaultConfig = args.Any(a => a == "--default" || a == "-d");

            if (useDefaultConfig)
            {
            }
            else
            {
                RegisterConsoleCommands();
                Console.ExecuteFile("autoexec.cfg");
                Console.ParseArguments(args);
            }

            Config.RestoreString();
        }