Beispiel #1
0
        public void Start()
        {
            dispatcher = new Dispatcher();

            scheduler = new Scheduler(dispatcher);

            listeners = new List <Listener>();

            listeners.Add(new Listener(7171, socket => new LoginConnection(this, socket)));

            listeners.Add(new Listener(7172, socket => new GameConnection(this, socket)));

            Clock = new Clock(12, 0);

            Logger = new Logger();

            Channels = new ChannelCollection();

            RuleViolations = new RuleViolationCollection();

            PacketsFactory = new PacketsFactory();

            using (Logger.Measure("Loading items", true))
            {
                var otb = OtbFile.Load("data/items/items.otb");

                var dat = DatFile.Load("data/items/tibia.dat");

                var items = ItemsFile.Load("data/items/items.xml");

                ItemFactory = new ItemFactory(otb, dat, items);
            }

            using (Logger.Measure("Loading monsters", true))
            {
                var monsters = MonsterFile.Load("data/monsters");

                MonsterFactory = new MonsterFactory(monsters);
            }

            using (Logger.Measure("Loading npcs", true))
            {
                var npcs = NpcFile.Load("data/npcs");

                NpcFactory = new NpcFactory(npcs);
            }

            using (Logger.Measure("Loading map", true))
            {
                var otbm = OtbmFile.Load("data/map/pholium3.otbm");

                Map = new Map(ItemFactory, otbm);
            }

            Pathfinding = new Pathfinding(Map);

            Events = new EventsCollection();

            Scripts = new ScriptsCollection();

            using (Logger.Measure("Loading scripts", true))
            {
                Scripts.Start(this);
            }

            dispatcher.Start();

            scheduler.Start();

            foreach (var listener in listeners)
            {
                listener.Start();
            }

            Logger.WriteLine("Server online");
        }