Ejemplo n.º 1
0
        public static void Main()
        {
            ClockTimer.RecordRunTime();

            Console.WriteLine("    ====================================================    ");
            Console.WriteLine("    Welcome to the BBLegacy Dedicated Server [prototype]    ");
            Console.WriteLine();
            Console.WriteLine("     INIFile Management Code by S.T.A. snc (C)2009-2013     ");
            Console.WriteLine("    Networking System by FatalSleep from The GMCommunity    ");
            Console.WriteLine("    ====================================================    ");
            Console.WriteLine();

            //Fetch the External IP Address, if they're not using local.
            string TheIPAddress;

            if (IsLocal == 1)
            {
                TheIPAddress = "127.0.0.1";
            }
            else
            {
                Console.Write("Fetching IP Address... ");
                TheIPAddress = getExternalIp();
                Console.WriteLine("done.");
            }
            UpdateINI Backupper = new UpdateINI(60000);

            TcpListenerSocket myTcpSocket = new TcpListenerSocket(TheIPAddress, Port, MaxClients, ReadSize, WriteSize, Alignment, PacketHeader);

            Console.WriteLine("TCP Connection Listener Established (" + TheIPAddress + " :: " + Port + ")");
            Console.WriteLine(" - The connection is set to have a maximum of " + MaxClients + " BBLegacy connections.");
            UdpServerSocket myUdpSocket = new UdpServerSocket(Port, ReadSize, WriteSize, Alignment, PacketHeader);

            Console.WriteLine("UDP Connection Listener Established (" + TheIPAddress + " :: " + Port + ")");
            string Command = "";

            Thread.Sleep(3000);

            Thread.Sleep(1000);
            Console.WriteLine("You can now type 'help' for some commands.");
            Console.WriteLine();
            Console.WriteLine("    ====================================================    ");

            while (myTcpSocket.Status == true || myUdpSocket.Status == true)
            {
                Command = Console.ReadLine();
                CmdSystem.RunCmd(Command, myTcpSocket, myUdpSocket);
            }

            ClockTimer.StopRunTime();
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            ClockTimer.RecordRunTime();

            Console.Clear();
            Console.WriteLine("    ====================================================    ");
            Console.WriteLine("    Welcome to the BBLegacy Dedicated Server [prototype]    ");
            Console.WriteLine();
            Console.WriteLine("     INIFile Management Code by S.T.A. snc (C)2009-2013     ");
            Console.WriteLine("    Networking System by FatalSleep from the GMCommunity    ");
            Console.WriteLine("    ====================================================    ");
            Console.WriteLine();

            //Fetch the External IP Address, if they're not using local.

            if (IsLocal)
            {
                TheIPAddress = "127.0.0.1";
            }
            else
            {
                Console.WriteLine("Fetching IP Address... ");
                TheIPAddress = getExternalIp();

                Console.WriteLine("     " + TheIPAddress + ", LAN " + getInternalIP());
            }

            Console.WriteLine("Loading player database...");
            new UpdateINI(3600000);
            MessageUpdate = new MessageUpdater(120000);
            Event         = new Automation();

            var tmp = 1;

            while (tmp <= SettingsFile.GetValue("Server Configuration", "NumberOfPlayers", 1))
            {
                PlayerListItem tmpp = new PlayerListItem();
                tmpp.ID   = SettingsFile.GetValue("PlayerListItem" + tmp, "ID", 0.00);
                tmpp.Name = SettingsFile.GetValue("PlayerListItem" + tmp, "Name", "{NULL}");
                tmpp.Tag  = (byte)SettingsFile.GetValue("PlayerListItem" + tmp, "Tag", 0);
                Console.WriteLine("    PL" + tmpp.ID + " " + tmpp.Name + " (" + tmpp.Tag + ")");
                tmp++;

                if (tmpp.Tag == 0)
                {
                    tmpp.Automate();
                }
            }

            Console.WriteLine("done.");

            myTcpSocket = new TcpListenerSocket(TheIPAddress, Port, MaxClients, ReadSize, WriteSize, Alignment, PacketHeader);

            myUdpSocket = new UdpServerSocket(Port, ReadSize, WriteSize, Alignment, PacketHeader);

            Console.WriteLine("UDP Connection Listener Established (" + TheIPAddress + " :: " + Port + ")");
            string Command = "";

            if (!CanCreateRooms)
            {
                Console.WriteLine("WARNING: Player creation of rooms is disabled. You MUST use room creation commands in order for them to play on your server!");
            }

            Thread.Sleep(2000);
            Console.WriteLine("You can now type 'help' for some commands.");
            Console.WriteLine();
            Console.WriteLine("    ====================================================    ");

            while (myTcpSocket.Status == true || myUdpSocket.Status == true)
            {
                try
                {
                    Command = Console.ReadLine();
                    CmdSystem.RunCmd(Command);
                }
                catch (Exception e)
                {
                    CmdSystem.AddLog("UNCAUGHT EXCEPTION: " + e.GetType() + " :: " + e.Message);
                    CmdSystem.AddLog("Stack Trace: ");
                    Console.WriteLine();
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine();
                }
            }
            ClockTimer.StopRunTime();
        }