static void ServerMain(string[] args) { Root r = new Root(args, true); r.ServerServer(args); r.NextIndex += 10; while (!Root.Instance.Quit) { Flow f = new SpaceWar2006.Flows.GameServer(); r.CurrentFlow = f; f.Start(); r.ServerRun(true); f.Stop(); } r.ServerStop(); r.Dispose(); }
private void ServerStart_Click(object sender, EventArgs e) { if (HostSinglePlayer.Checked) { SingleStart(); return; } if (GameRunning) { Root.Instance.Quit = true; return; } //start non-dedicated or dedicated server GameRunning = true; ServerStart.Text = "Stop"; Helper h = null; if (HostDedicated.Checked) { //SimpleUserInterface sui = new SimpleUserInterface(); Cheetah.Root.Instance.LocalObjects.Add(h = new Helper()); } Root r = Root.Instance; if (HostNonDedicated.Checked) { //bring up the userinterface //ViewerForm vf = new ViewerForm(); //vf.Show(); //r.ClientClient(new string[] { }, vf.glControl1); r.ClientClient(new string[] {}); } r.ServerServer(new string[] { }); r.Authoritive = true; r.Scene = new Scene(); if (HostRecordDemo.Checked) { string name = string.Format("{2}{3,02}{4,2}{5,2}{6,2}-{0}-{1}.demo", ((Type)HostRule.SelectedItem).Name, ((Type)HostMap.SelectedItem).Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute); name = name.Replace(' ', '0'); FileSystemNode demo = Root.Instance.FileSystem.Get("demos"); demo = demo.CreateFile(name); Root.Instance.Recorder = new DemoRecorder(demo.getStream(), true, 20); } Flow f; if (CurrentGameSettings is IRuleCreator) { if (HostDedicated.Checked) { f = new SpaceWar2006.Flows.GameServer( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value ); } else { f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); } } else { if (HostNonDedicated.Checked) { throw new Exception(); } f = new SpaceWar2006.Flows.GameServer(); } Root.Instance.ResourceManager.LoadConfig("config/global.config").Set("server.password", this.HostPassword.Text); r.CurrentFlow = f; f.Start(); r.ServerRun(HostDedicated.Checked); f.Stop(); r.ServerStop(); r.ResourceManager.UnloadAll(); if (r.UserInterface != null) { r.Dispose(); r.UserInterface = null; } if (h != null) { Cheetah.Root.Instance.LocalObjects.Remove(h); } Root.Instance.Recorder = null; GameRunning = false; if (HostRecordDemo.Checked) { LoadDemos(); } ServerStart.Text = "Start"; //StatusBar.Text = "Dedicated Server stopped. Ready."; }
private void ServerStart_Click(object sender, EventArgs e) { if (HostSinglePlayer.Checked) { SingleStart(); return; } if (GameRunning) { Root.Instance.Quit = true; return; } //start non-dedicated or dedicated server GameRunning = true; ServerStart.Text = "Stop"; Helper h=null; if(HostDedicated.Checked) { //SimpleUserInterface sui = new SimpleUserInterface(); Cheetah.Root.Instance.LocalObjects.Add(h = new Helper()); } Root r = Root.Instance; if(HostNonDedicated.Checked) { //bring up the userinterface //ViewerForm vf = new ViewerForm(); //vf.Show(); //r.ClientClient(new string[] { }, vf.glControl1); r.ClientClient(new string[]{}); } r.ServerServer(new string[] { }); r.Authoritive = true; r.Scene = new Scene(); if (HostRecordDemo.Checked) { string name = string.Format("{2}{3,02}{4,2}{5,2}{6,2}-{0}-{1}.demo", ((Type)HostRule.SelectedItem).Name, ((Type)HostMap.SelectedItem).Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute); name=name.Replace(' ','0'); FileSystemNode demo=Root.Instance.FileSystem.Get("demos"); demo=demo.CreateFile(name); Root.Instance.Recorder = new DemoRecorder(demo.getStream(), true, 20); } Flow f; if (CurrentGameSettings is IRuleCreator) { if (HostDedicated.Checked) { f = new SpaceWar2006.Flows.GameServer( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value ); } else { f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); } } else { if (HostNonDedicated.Checked) throw new Exception(); f = new SpaceWar2006.Flows.GameServer(); } Root.Instance.ResourceManager.LoadConfig("config/global.config").Set("server.password", this.HostPassword.Text); r.CurrentFlow = f; f.Start(); r.ServerRun(HostDedicated.Checked); f.Stop(); r.ServerStop(); r.ResourceManager.UnloadAll(); if (r.UserInterface != null) { r.Dispose(); r.UserInterface = null; } if(h!=null) Cheetah.Root.Instance.LocalObjects.Remove(h); Root.Instance.Recorder = null; GameRunning = false; if (HostRecordDemo.Checked) { LoadDemos(); } ServerStart.Text = "Start"; //StatusBar.Text = "Dedicated Server stopped. Ready."; }