Exemplo n.º 1
0
        private void Reboot()
        {
            if (_rebooting)
            {
                return;
            }

            _rebooting = true;

            WorldTimer tmr = null;
            var        s   = 30;
            Func <World, RealmTime, bool> rebootTick = (w, t) =>
            {
                s -= 1;

                if (s == 15)
                {
                    _manager.Chat.Announce("Server rebooting in 15 seconds...", true);
                }
                else if (s == 5)
                {
                    _manager.Chat.Announce("Server rebooting in 5 seconds...", true);
                }
                else if (s == 0)
                {
                    // this could help avoid unfinished transactions when rebooting
                    foreach (var world in _manager.Worlds.Values)
                    {
                        world.Closed = true;
                        foreach (var p in world.Players.Values)
                        {
                            p.Client?.Disconnect();
                        }
                    }
                    Program.Stop();
                    return(true);
                }


                tmr.Reset();
                return(false);
            };

            tmr = new WorldTimer(1000, rebootTick);
            _manager.Chat.Announce("Server rebooting in 30 seconds...", true);
            _manager.GetWorld(World.Realm).Timers.Add(tmr);
        }
Exemplo n.º 2
0
        public void UpdateGuildHall()
        {
            WorldTimer ghallTimer = null;

            UpgradeInProgress = true;
            GuildHall.Timers.Add(ghallTimer = new WorldTimer(60 * 1000, (w, t) =>
            {
                if (w.Players.Count > 0)
                {
                    ghallTimer.Reset();
                    GuildHall.Manager.Logic.AddPendingAction(_ => w.Timers.Add(ghallTimer), PendingPriority.Creation);
                }
                else
                {
                    RealmManager manager = GuildHall.Manager;
                    GuildHall.Manager.RemoveWorld(GuildHall);
                    GuildHall         = manager.AddWorld(new GuildHall(Name));
                    UpgradeInProgress = false;
                }
            }));
        }