public override void Stop() { base.Stop(); Cheetah.Console.WriteLine("gameserver stopped."); Root.Instance.ServerConnection.RemoveAllClients(); Root.Instance.Scene.Clear(); if (qs != null) { Root.Instance.LocalObjects.Remove(qs); qs.Dispose(); qs = null; } if (reporter != null) { Root.Instance.LocalObjects.Remove(reporter); reporter.Dispose(); reporter = null; } //Restart(); }
public override void Start() { base.Start(); Config c = Root.Instance.ResourceManager.LoadConfig("config/global.config"); Root.Instance.Scene.Clear(); if (NextMap == null || NextRule == null) SetDefault(); Root.Instance.Scene.Spawn(NextMap); NextMap = null; if (NextRule == null || NextRule is Mission) NextRule = Root.Instance.Scene.FindEntityByType<GameRule>(); else Root.Instance.Scene.Spawn(NextRule); Rule = NextRule; NextRule = null; Rule.AnnounceEvent += Cheetah.Console.WriteLine; if (Root.Instance.UserInterface==null && c.GetBool("server.queryport.enable")) { int queryport = c.GetInteger("server.queryport"); if (queryport > 0 && qs == null) Root.Instance.LocalObjects.Add(qs = new QueryServer(queryport, new IQuery[] { new OldGameSpyQuery() })); } if (Root.Instance.UserInterface==null && c.GetBool("irc.enable") && reporter == null) { reporter = new IrcReporter(c.GetString("irc.host"), c.GetInteger("irc.port"), c.GetString("irc.nick"), c.GetString("irc.realname"), c.GetString("irc.channels").Split(',')); Root.Instance.LocalObjects.Add(reporter); Rule.AnnounceEvent += reporter.Announce; } int botcount = NextBotCount; Bots = new SpaceShipBotControl[botcount]; BotPlayers = new Player[botcount]; for (int i = 0; i < botcount; ++i) { int team = (Rule is TeamDeathMatch) ? c.GetInteger("server.bot" + i + ".team") : -1; string name = c.GetString("server.bot" + i + ".name"); SpawnBot(i, team, name); } //SpawnBot(1); }