Exemple #1
0
        static void MyHandler(object sender, UnhandledExceptionEventArgs args)
        {
            Logging.DisablePrimaryWriting(true);
            Exception e = (Exception)args.ExceptionObject;

            Logging.LogCriticalException("SYSTEM CRITICAL EXCEPTION: " + e.ToString());
            PiciEnvironment.SendMassMessage("A fatal error crashed the server, server shutting down.");
            PiciEnvironment.PreformShutDown(true);
        }
Exemple #2
0
 internal static void SendMassMessage(string Message)
 {
     try
     {
         ServerMessage HotelAlert = new ServerMessage(808);
         HotelAlert.Append("Important Notice from Hotel Management");
         HotelAlert.Append(Message);
         PiciEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(HotelAlert);
     }
     catch (Exception e) { Logging.HandleException(e, "PiciEnvironment.SendMassMessage"); }
 }
Exemple #3
0
        internal static void InitEnvironment()
        {
            if (!PiciEnvironment.isLive)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.CursorVisible   = false;
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

                PiciEnvironment.Initialize();
            }
        }
Exemple #4
0
        internal static void Initialize()
        {
            Console.Clear();
            DateTime Start = DateTime.Now;

            SystemMute = false;

            IrcEnabled           = false;
            ServerStarted        = DateTime.Now;
            Console.Title        = PiciEnvironment.Title + " " + PiciEnvironment.Version;
            Console.WindowHeight = 30;
            DefaultEncoding      = Encoding.Default;

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("");
            Console.WriteLine("          ______ _       _    _______             ");
            Console.WriteLine("         (_____ (_)     (_)  (_______)            ");
            Console.WriteLine("          _____) )  ____ _    _____   ____  _   _ ");
            Console.WriteLine(@"         |  ____/ |/ ___) |  |  ___) |    \| | | |");
            Console.WriteLine(@"         | |    | ( (___| |  | |_____| | | | |_| |");
            Console.WriteLine(@"         |_|    |_|\____)_|  |_______)_|_|_|____/ ");


            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("                              " + PiciEnvironment.Title + " " + PiciEnvironment.Version + " (Build " + PiciEnvironment.Build + ")");


            Console.WriteLine();

            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine();

            cultureInfo = CultureInfo.CreateSpecificCulture("en-GB");
            LanguageLocale.Init();

            try
            {
                ChatCommandRegister.Init();
                PetCommandHandeler.Init();
                PetLocale.Init();
                Configuration = new ConfigurationData(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, @"config.conf"));

                DateTime Starts = DateTime.Now;

                dbType = DatabaseType.MySQL;

                manager = new DatabaseManager(uint.Parse(PiciEnvironment.GetConfig().data["db.pool.maxsize"]), uint.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), int.Parse(PiciEnvironment.GetConfig().data["db.pool.minsize"]), dbType);
                manager.setServerDetails(
                    PiciEnvironment.GetConfig().data["db.hostname"],
                    uint.Parse(PiciEnvironment.GetConfig().data["db.port"]),
                    PiciEnvironment.GetConfig().data["db.username"],
                    PiciEnvironment.GetConfig().data["db.password"],
                    PiciEnvironment.GetConfig().data["db.name"]);
                manager.init();

                TimeSpan TimeUsed2 = DateTime.Now - Starts;

                LanguageLocale.InitSwearWord();

                Game = new Game(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]));
                Game.ContinueLoading();

                ConnectionManager = new ConnectionHandeling(int.Parse(PiciEnvironment.GetConfig().data["game.tcp.port"]),
                                                            int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conlimit"]),
                                                            int.Parse(PiciEnvironment.GetConfig().data["game.tcp.conperip"]),
                                                            PiciEnvironment.GetConfig().data["game.tcp.enablenagles"].ToLower() == "true");
                ConnectionManager.init();

                ConnectionManager.Start();

                StaticClientMessageHandler.Initialize();
                ClientMessageFactory.Init();

                string[] arrayshit = PiciEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(Convert.ToChar(","));

                MusSystem = new MusSocket(PiciEnvironment.GetConfig().data["mus.tcp.bindip"], int.Parse(PiciEnvironment.GetConfig().data["mus.tcp.port"]), arrayshit, 0);

                //InitIRC();

                groupsEnabled = true;

                useSSO = true;

                TimeSpan TimeUsed = DateTime.Now - Start;

                Logging.WriteLine("Server -> Started! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
                isLive = true;

                Console.Beep();


                if (bool_0_12)
                {
                    Console.WriteLine("Coffee team, I appreciate you testing. ;-*");
                    System.Threading.Thread.Sleep(2500);
                    PreformShutDown(true);
                    return;
                }
            }
            catch (KeyNotFoundException e)
            {
                Logging.WriteLine("Please check your configuration file - some values appear to be missing.");
                Logging.WriteLine("Press any key to shut down ...");
                Logging.WriteLine(e.ToString());
                Console.ReadKey(true);
                PiciEnvironment.Destroy();

                return;
            }
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to initialize PiciEmulator: " + e.Message);
                Logging.WriteLine("Press any key to shut down ...");

                Console.ReadKey(true);
                PiciEnvironment.Destroy();

                return;
            }

            catch (Exception e)
            {
                Console.WriteLine("Fatal error during startup: " + e.ToString());
                Console.WriteLine("Press a key to exit");

                Console.ReadKey();
                Environment.Exit(1);
            }
        }