Ejemplo n.º 1
0
        public static void EnsureMinimalSetup()
        {
            if (!initialized)
            {
                initialized = true;

                if (!Directory.Exists(RunDir))
                {
                    // Maybe the CWD randomly moved to Run/Debug/TestResults/TestRunName123424239453285894983435/Out/
                    // Use Directory.SetCurrentDirectory(...); to change it
                    RunDir = "../../../../";
                    if (!Directory.Exists(RunDir))
                    {
                        throw new DirectoryNotFoundException(string.Format("RunDir was not found at {0} (CWD = {1})",
                                                                           new DirectoryInfo(RunDir).FullName,
                                                                           new DirectoryInfo(Directory.GetCurrentDirectory()).FullName));
                    }
                }

                if (!File.Exists(WCellRealmServerConsoleExe))
                {
                    throw new DirectoryNotFoundException(string.Format("WCellRealmServerConsole.exe was not found at {0} (CWD = {1})",
                                                                       new FileInfo(WCellRealmServerConsoleExe).FullName, new DirectoryInfo(Directory.GetCurrentDirectory()).FullName));
                }

                // since console will not show, lets echo console output to a file:
                Console.SetOut(m_output = new IndentTextWriter(LogFile)
                {
                    AutoFlush = true
                });
                LogUtil.SetupStreamLogging(m_output);

                RealmServer.EntryLocation = WCellRealmServerConsoleExe;
                var realmServ = RealmServer.Instance;                                           // make sure to create the RealmServer instance first

                RealmServerConfiguration.Instance.AutoSave = false;

                RealmServer.ConsoleActive = false;
                RealmServerConfiguration.ContentDirName = Path.GetFullPath(ContentDir);
                RealmServerConfiguration.Initialize();
                RealmAddonMgr.AddonDir = RealmAddonDir;

                DebugUtil.DumpDirName = DumpDir;
                DebugUtil.Init();

                LogUtil.ExceptionRaised += new Action <string, Exception>(LogUtil_ExceptionRaised);

                // some sample roles
                PrivilegeMgr.Instance.SetGroupInfo(new[] {
                    RoleGroupInfo.LowestRole  = new RoleGroupInfo("Guest", 1, RoleStatus.Player, true, true, true, true, false, true, null, new[] { "*" }),
                    RoleGroupInfo.HighestRole = new RoleGroupInfo("Admin", 1000, RoleStatus.Admin, true, true, true, true, true, false, null, new [] { "*" })
                });
            }
        }
Ejemplo n.º 2
0
        public static bool Init(string toolsRoot, params Assembly[] assemblies)
        {
            ToolConfig.ToolsRoot    = toolsRoot;
            RealmServ.EntryLocation = Path.GetFullPath(ToolConfig.WCellRealmServerConsoleExe);
            var realmServ = RealmServ.Instance;             // make sure to create the RealmServ instance first

            ToolConfig.InitCfg();

            LogUtil.SetupConsoleLogging();

            Log.Info("Output Directory: {0}", new DirectoryInfo(ToolConfig.OutputDir).FullName);
            if (!Directory.Exists(ToolConfig.OutputDir))
            {
                Directory.CreateDirectory(ToolConfig.OutputDir);
            }

            RealmServerConfiguration.Instance.AutoSave = false;
            RealmServerConfiguration.ContentDirName    = Path.GetFullPath(ToolConfig.ContentDir);
            RealmServerConfiguration.Initialize();
            RealmAddonMgr.AddonDir = ToolConfig.AddonDir;

            Log.Info("Content Directory: " + new DirectoryInfo(RealmServerConfiguration.ContentDir).FullName);

            if (!InitMgr.Initialize(typeof(Tools).Assembly) ||
                !InitMgr.Initialize(typeof(PacketAnalyzer).Assembly))
            {
                Log.Error("Cancelled - Press any key to exit...");
                Console.ReadKey();
                return(false);
            }

            foreach (var asm in assemblies)
            {
                if (!InitMgr.Initialize(asm))
                {
                    Log.Error("Unable to initialize Assembly: \"{0}\" - Press any key to exit...", asm);
                    return(false);
                }
                ToolCommandHandler.Instance.AddCmdsOfAsm(asm);
                Mgr.AddStaticMethodsOfAsm(asm);
            }

            Mgr.AddStaticMethodsOfAsm(typeof(Tools).Assembly);
            return(true);
        }
Ejemplo n.º 3
0
        public static void CreateCommandDocs(string dir)
        {
            RealmServ.EntryLocation = Path.GetFullPath(ToolConfig.WCellRealmServerConsoleExe);
            var realmServ = RealmServ.Instance;             // make sure to create the RealmServ instance first

            LogUtil.SetupConsoleLogging();

            Console.WriteLine("Output Directory: " + new DirectoryInfo(dir).FullName);

            RealmServerConfiguration.Instance.AutoSave = false;
            RealmServerConfiguration.Initialize();

            RealmCommandHandler.Initialize();
            AuthCommandHandler.Initialize();
            ToolCommandHandler.Initialize();

            CreateCommandDocs(Path.Combine(dir, "RealmServer"), RealmCommandHandler.Instance.Commands);
            CreateCommandDocs(Path.Combine(dir, "AuthServer"), AuthCommandHandler.Instance.Commands);
            CreateCommandDocs(Path.Combine(dir, "Tools"), ToolCommandHandler.Instance.Commands);
        }