Exemple #1
0
        static int Main(string[] args)
        {
            Console.Title = "Dedicated server";
            int port = 870;
            if (args.Length > 0)
            {
                port = Convert.ToInt32(args[0]);
            }
            try
            {
                TheServer = new GameServer(port);
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not host server on port {0}.", port);
                return -1;
            }

            new Thread(RunServer).Start();

            while (true)
            {
                string command = Console.ReadLine();
                ServerConsole.ConsoleInput(command);
                if (GameServer.ServerNetworkManager.NetServer.Status == NetPeerStatus.NotRunning || GameServer.ServerNetworkManager.NetServer.Status == NetPeerStatus.ShutdownRequested)
                    break;
            }

            return 0;
        }
Exemple #2
0
        protected override void Initialize()
        {
            ConsoleManager.InitConsole();
            ConsoleManager.Log("Width: " + graphics.PreferredBackBufferWidth + " Height: " + graphics.PreferredBackBufferHeight);
            ConsoleManager.AddConVar("window_title", "Window title", "Mining thing");

            ConsoleManager.AddConCommand("reset_textures", "Reload the textures", LoadTextures);

            ConsoleManager.AddConCommandArgs("host", "Host a game", (string[] ls) =>
            {
                int port = Convert.ToInt32(ls[0]);
                GameServer = new GameServer(port);
            }, 1);

            Center = new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2);
            PlayerBindManager.InitBinds();
            ConsoleManager.ConsoleInput("exec exec", true);

            base.Initialize();
        }