Пример #1
0
        public static void Start(bool repair)
        {
            if (!ScriptCompiler.Compile(true))
            {
                return;
            }

            m_ItemCount   = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries)
            {
                int itemCount = 0, mobileCount = 0;
                l.Verify(ref itemCount, ref mobileCount);
                log.InfoFormat("Library {0} verified: {1} items, {2} mobiles",
                               l.Name, itemCount, mobileCount);
                m_ItemCount   += itemCount;
                m_MobileCount += mobileCount;
            }
            log.InfoFormat("All libraries verified: {0} items, {1} mobiles)",
                           m_ItemCount, m_MobileCount);

            try {
                TileData.Configure();

                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                log.Fatal("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
            {
                config.Save();
            }

            World.Load();
            if (World.LoadErrors > 0)
            {
                log.ErrorFormat("There were {0} errors during world load.", World.LoadErrors);
                if (repair)
                {
                    log.Error("The world load errors are being ignored for now, and will not reappear once you save this world.");
                }
                else
                {
                    log.Error("Try 'SunUO --repair' to repair this world save, or restore an older non-corrupt save.");
                    return;
                }
            }

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                log.Fatal("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump();
            foreach (IPEndPoint ipep in Config.Network.Bind)
            {
                m_MessagePump.AddListener(new Listener(ipep));
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";
            timerThread.Start();

            NetState.Initialize();
            Encryption.Initialize();

            EventSink.InvokeServerStarted();

            log.Info("SunUO initialized, entering main loop");

            try
            {
                Run();
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }

            if (timerThread.IsAlive)
            {
                timerThread.Abort();
            }
        }
Пример #2
0
 /// <summary>
 /// Update the visible state of a tile.
 /// </summary>
 /// <param name="tile"></param>
 public void UpdateTile(TileData tile)
 {
     currentState.UpdateTile(tile);
 }