Ejemplo n.º 1
0
        private void GetFileList(string path, string prefix)
        {
            var files = Directory.GetFiles(path);

            foreach (string file in files)
            {
                var fileInfo     = new FileInfo(file);
                var resourceFile = new FileListFile(fileInfo);

                FileSystemGenerator.AddFileAndTag(resourceFile);


                Logger.LogInfoLine("{0}File: {1}", prefix, fileInfo.FullName);
                CopyAudio(resourceFile);
            }

            var dirs = Directory.GetDirectories(path);

            foreach (string dir in dirs)
            {
                var directoryInfo = new DirectoryInfo(dir);
                Logger.LogInfoLine("{0}Dir:\t{1}", prefix, directoryInfo.Name);
                GetFileList(dir, prefix + "\t");
            }
        }
Ejemplo n.º 2
0
        public void Analyze()
        {
            Logger.LogAllLine("Analyze Scripts================>");
            MissionScripts.Clear();
            HeroScripts.Clear();
            MonsterScripts.Clear();
            SkillScripts.Clear();
            BufferScripts.Clear();


            {
                var files = SystemTool.GetDirectoryFiles(PathManager.InputMissionScriptPath);
                foreach (var scriptFile in files)
                {
                    MissionScripts.Add(scriptFile.Name, false);
                }
            }

            {
                var files = SystemTool.GetDirectoryFiles(PathManager.InputHeroScriptPath);
                foreach (var scriptFile in files)
                {
                    HeroScripts.Add(scriptFile.Name, false);
                }
            }

            {
                var files = SystemTool.GetDirectoryFiles(PathManager.InputMonsterScriptPath);
                foreach (var scriptFile in files)
                {
                    MonsterScripts.Add(scriptFile.Name, false);
                }
            }

            {
                var files = SystemTool.GetDirectoryFiles(PathManager.InputSkillScriptPath);
                foreach (var scriptFile in files)
                {
                    SkillScripts.Add(scriptFile.Name, false);
                }
            }

            {
                var files = SystemTool.GetDirectoryFiles(PathManager.InputBufferScriptPath);
                foreach (var scriptFile in files)
                {
                    BufferScripts.Add(scriptFile.Name, false);
                }
            }

            //copy all scripts
            {
                var files = SystemTool.GetDirectoryFiles(PathManager.InputScriptPath);
                foreach (var scriptFile in files)
                {
                    var resourceFile = new FileListFile(scriptFile, true, true);
                    FileSystemGenerator.CopyFileToOutput(resourceFile);
                }
            }
        }
Ejemplo n.º 3
0
        public static void Pack(PublishTarget target)
        {
            if (target.IsOptimzed)
            {
                Optimze();
            }


            Logger.LogInfoLine("Packing:");
            var merger = new ImageMerger();

            foreach (var imageGroup in ImageGroups)
            {
                if (imageGroup.Value.Count > 1 || PublishTarget.Current.IsPVR)
                {
                    var resultImages = merger.Generate(imageGroup.Key, imageGroup.Value);
                    foreach (var resultImage in resultImages)
                    {
                        resultImage.Key.Save();
                        resultImage.Key.TryConvertSelfToPVR();

                        uint id = FileSystemGenerator.AddFileAndTag(resultImage.Key);
                        if (id != uint.MaxValue)
                        {
                            foreach (var subImage in resultImage.Value.UsedImages)
                            {
                                FileSystemGenerator.AddImageTagItem(subImage, id);
                            }
                        }
                    }
                }
                else
                {
                    if (imageGroup.Value.Count > 0)
                    {
                        imageGroup.Value[0].IsPacked = false;
                    }
                    //FileSystemGenerator.AddFileAndTag(imageGroup.Value[0]);
                }

                OnPackingProgressEvent(1);
            }


            foreach (var image in Images)
            {
                if (!image.Key.IsPacked)
                {
                    FileSystemGenerator.CopyFileToOutput(image.Key);
                }
                else
                {
                    if (!PublishTarget.Current.IsPack)
                    {
                        Logger.LogErrorLine("Lose file:{0}", image.Key.FileInfo.FullName);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void Analyze()
        {
            Logger.LogAllLine("Analyze config================>");

            FileListFile fileListFile = new FileListFile(PathManager.InputConfigPaperConfigPath, true, true);

            FileSystemGenerator.CopyFileToOutput(fileListFile);

            fileListFile = new FileListFile(PathManager.InputConfigServerGameConfigPath, true, true);
            FileSystemGenerator.CopyFileToOutput(fileListFile);
        }
Ejemplo n.º 5
0
        public void Analyze()
        {
            Logger.LogAllLine("Analyze Other================>");

            var files = SystemTool.GetDirectoryFiles(PathManager.InputOtherPath);

            foreach (var animationFile in files)
            {
                var resourceFile = new FileListFile(animationFile);
                FileSystemGenerator.CopyFileToOutput(resourceFile);
            }
        }
Ejemplo n.º 6
0
        public void Analyze()
        {
            Logger.LogAllLine("Analyze Audio================>");

            var files = SystemTool.GetDirectoryFiles(PathManager.InputAudioPath);

            foreach (var file in files)
            {
                if (file.Extension == ".wav" || file.Extension == ".mp3")
                {
                    var resourceFile = new FileListFile(file);
                    FileSystemGenerator.CopyFileToOutput(resourceFile);
                }
            }
        }
Ejemplo n.º 7
0
        public void Analyze()
        {
            StringTables.Clear();
            mNameGroups.Clear();

            Logger.LogAllLine("Analyze StringTable================>");
            var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Jet\4.0\Engines\Excel", true);

            reg.SetValue("TypeGuessRows", 0);

            var validNames = Enum.GetNames(typeof(PublishLanguages));
            var tabelNames = ExcelHelper.GetExcelTableNames(PathManager.InputConfigStringTablePath.FullName);

            foreach (string tableName in tabelNames)
            {
                string pureTableName = tableName.Replace("$", String.Empty).Replace("'", String.Empty).Replace(TableName, String.Empty);
                bool   isValidTable  = validNames.Any(pureTableName.Contains);
                if (!isValidTable || !tableName.Contains(TableName))
                {
                    continue;
                }

                var    table        = ExcelHelper.LoadDataFromExcel(PathManager.InputConfigStringTablePath.FullName, tableName);
                string resourceName = tableName.Replace("$", String.Empty);
                var    packageInfo  = PublishInfo.GetPublishInfo(resourceName);


                var stringTable = GetOrCreateStringTable(packageInfo);
                foreach (DataRow row in table.Rows)
                {
                    bool isValid   = true;
                    bool isAllNull = true;
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        if (row.IsNull(i))
                        {
                            isValid = false;
                        }
                        else
                        {
                            isAllNull = false;
                        }
                    }


                    if (isValid)
                    {
                        try
                        {
                            string name  = Convert.ToString(row["name"]);
                            uint   order = Convert.ToUInt32(row["order"]);
                            string str   = Convert.ToString(row["value"]);

                            string resultStr = ExcelHelper.ConvertToUTF8(str);


                            Add(stringTable, name, order, resultStr);
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorLine(ex.Message);
                            ExcelHelper.PrintRow(row);
                        }
                    }
                    else if (!isAllNull)
                    {
                        Logger.LogErrorLine("Invalid string table line:");
                        ExcelHelper.PrintRow(row);
                    }
                }

                //print
                var stringTableResult = Parse(stringTable);

                if ((PublishTarget.Current.PublishInfo.Language & packageInfo.Language) == packageInfo.Language)
                {
                    string tempPath = PathManager.OutputConfigPath + "/" + TableName +
                                      pureTableName + ".bin";
                    using (var file = File.Open(tempPath, FileMode.Create, FileAccess.ReadWrite))
                    {
                        Serializer.Serialize(file, stringTableResult);
                        Logger.LogAllLine("Generate:{0}", tempPath);
                    }

                    var resourceFile = new FileListFile(new FileInfo(tempPath), true, true);
                    FileSystemGenerator.AddFileAndTag(resourceFile);
                }
                else
                {
                    Logger.LogAllLine("Ignore:\t{0}", pureTableName);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Generate a new, random world.
        /// </summary>
        public void CreateWorld(TerminalGame game, int companies)
        {
            DateTime beginWorld = DateTime.Now;

            Game = game;
            GameClock.Initialize();
            CurrentGameTime = GameClock.GameTime;
            Player          = new Player();
            Player.CreateNewPlayer("testPlayer", "abc123");
            Computers   = new List <Computer>();
            People      = new List <Person>();
            CompanyList = new List <Company>();

            Files.File testFile   = new Files.File("testFile", "this is a test", FileType.Text);
            Files.File testSubDir = new Files.File("test2");
            testSubDir.AddFile(testFile);
            Files.File testDir = new Files.File("test");
            testDir.AddFile(testSubDir);
            Files.File testRoot = new Files.File("");
            testRoot.AddFile(testDir);
            Files.File testFile2 = new Files.File("testFile2", "test 2", FileType.Text);
            testRoot.AddFile(testFile2);
            FileSystem pfs = new FileSystem(testRoot);
            var        bin = new Files.File("bin");

            bin.AddFile(new Files.File("terminal", "terminal executable", FileType.Binary, 48374));
            bin.AddFile(new Files.File("notepad", "notepad executable", FileType.Binary, 7522));
            bin.AddFile(new Files.File("remoteview", "remoteview executable", FileType.Binary, 61325));
            bin.AddFile(new Files.File("netmap", "netmap executable", FileType.Binary, 879820));
            pfs.RootDir.AddFile(bin);

            Company  mCorp = new Company("Mission Corp");
            Computer mComp = new Computer("Mission Hub", new int[] { 80 }, ComputerType.Server, mCorp, "123.123.123.123", "swordfish", FileSystemGenerator.GenerateDefaultFilesystem());

            mCorp.GetComputers.Add(mComp);
            CompanyList.Add(mCorp);

            Company pc = new Company("Unknown", new Person("Unknown", DateTime.Parse("1970-01-01"), (Gender)(-1), (EducationLevel)(-1)), new Person("Unknown", DateTime.Parse("1970-01-01"), (Gender)(-1), (EducationLevel)(-1)), 0, 0);;

            Computer PlayerComp = new Computer("localhost", new int[] { 69, 1337 }, ComputerType.Workstation, pc, "127.0.0.1", Player.Password, pfs)
            {
                Game = game
            };

            Computers.Add(PlayerComp);

            DateTime beginCompanies = DateTime.Now;

            for (int i = 0; i < companies; i++)
            {
                Console.Write($"Creating company {i}/{companies}...");
                Company comp   = Company.GetRandomCompany(game);
                int     whoops = 0;
                while (CheckIfNameExists(comp.Name))
                {
                    comp.Name = Companies.Generator.CompanyGenerator.GenerateName();
                    whoops++;
                }
                comp.GenerateComputers();
                Console.WriteLine($"Done: {comp.Name}, whoopses: {whoops}.");
                CompanyList.Add(comp);
            }
            Console.WriteLine("Generated {0} companies in {1} seconds.", CompanyList.Count, (DateTime.Now.Subtract(beginCompanies).TotalSeconds).ToString("N4"));

            List <string> names = new List <string>();

            foreach (Company c in CompanyList)
            {
                Computers.AddRange(c.GetComputers);
                People.AddRange(c.GetPeople);
                names.Add(c.Name);
            }

            List <string> test = SortByLength(names.AsEnumerable()).ToList();

            foreach (string s in test)
            {
                Console.WriteLine(s);
            }

            foreach (Computer c in Computers)
            {
                c.Init(Game);
                if (c.Owner == CompanyList[35])
                {
                    c.IsMissionObjective = true;
                }
            }

            PlayerComp.PlayerHasRoot = true;
            PlayerComp.AccessLevel   = AccessLevel.Root;

            Player.PlayerComp = PlayerComp;

            Console.WriteLine("Generated world in {0} seconds.", (DateTime.Now.Subtract(beginWorld).TotalSeconds).ToString("N4"));
        }
Ejemplo n.º 9
0
        public void Analyze()
        {
            mUsedItemIds.Clear();

            Logger.LogAllLine("Analyze ServerList================>");
            var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Jet\4.0\Engines\Excel", true);

            reg.SetValue("TypeGuessRows", 0);

            ServerList config = new ServerList();

            var table = ExcelHelper.LoadDataFromExcel(PathManager.InputConfigServerConfigPath.FullName, PathManager.ServerListTableName);

            foreach (DataRow row in table.Rows)
            {
                bool isValid   = true;
                bool isAllNull = true;
                for (int i = 0; i < row.ItemArray.Length; i++)
                {
                    if (row.IsNull(i))
                    {
                        isValid = false;
                    }
                    else
                    {
                        isAllNull = false;
                    }
                }

                if (isValid)
                {
                    try
                    {
                        var configItem = new ServerListItem();
                        configItem.Id = Convert.ToUInt32(row["Id"]);
                        var serverUsages = ParseServerUsages(Convert.ToString(row["ServerUsages"]));
                        configItem.ServerUsages.AddRange(serverUsages);

                        foreach (var serverUsageItem in serverUsages)
                        {
                            if (!mUsedItemIds.ContainsKey(serverUsageItem.ServerId))
                            {
                                mUsedItemIds.Add(serverUsageItem.ServerId, false);
                            }
                        }
                        config.Items.Add(configItem);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorLine(ex.Message);
                        ExcelHelper.PrintRow(row);
                    }
                }
                else if (!isAllNull)
                {
                    Logger.LogErrorLine("Invalid Server Config line:");
                    ExcelHelper.PrintRow(row);
                }
            }


            using (var file = PathManager.OutputConfigServerListPath.OpenWrite())
            {
                Serializer.Serialize(file, config);
            }

            var resourceFile = new FileListFile(PathManager.OutputConfigServerListPath, true, true);

            FileSystemGenerator.AddFileAndTag(resourceFile);

            Logger.LogAllLine("Generate:\t{0}", PathManager.OutputConfigServerListPath);
        }
Ejemplo n.º 10
0
        public void Analyze()
        {
            Logger.LogAllLine("Analyze FuckyString================>");
            var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Jet\4.0\Engines\Excel", true);

            reg.SetValue("TypeGuessRows", 0);

            var validNames = Enum.GetNames(typeof(PublishLanguages));
            var tabelNames = ExcelHelper.GetExcelTableNames(PathManager.InputConfigStringTablePath.FullName);

            foreach (string tableName in tabelNames)
            {
                string pureTableName = tableName.Replace("$", String.Empty).Replace("'", String.Empty).Replace(TableName, String.Empty);
                bool   isValidTable  = validNames.Any(pureTableName.Contains);
                if (!isValidTable || !tableName.Contains(TableName))
                {
                    continue;
                }

                var    table        = ExcelHelper.LoadDataFromExcel(PathManager.InputConfigStringTablePath.FullName, tableName);
                string resourceName = tableName.Replace("$", String.Empty);
                var    packageInfo  = PublishInfo.GetPublishInfo(resourceName);

                SortedDictionary <char, MyFuckyStringNode> rootNodes = new SortedDictionary <char, MyFuckyStringNode>();

                foreach (DataRow row in table.Rows)
                {
                    bool isValid   = true;
                    bool isAllNull = true;
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        if (row.IsNull(i))
                        {
                            isValid = false;
                        }
                        else
                        {
                            isAllNull = false;
                        }
                    }


                    if (isValid)
                    {
                        try
                        {
                            string str       = Convert.ToString(row["Value"]).Trim();
                            string resultStr = ExcelHelper.ConvertToUTF8(str);

                            SortedDictionary <char, MyFuckyStringNode> nodes = rootNodes;
                            var chars = resultStr.ToCharArray();
                            for (int i = 0; i < chars.Length; ++i)
                            {
                                MyFuckyStringNode node;
                                if (!nodes.TryGetValue(chars[i], out node))
                                {
                                    node = new MyFuckyStringNode {
                                        Char = chars[i], IsFucky = i == chars.Length - 1
                                    };
                                    nodes.Add(chars[i], node);
                                }
                                nodes = node.Childs;
                                if (!node.IsFucky)
                                {
                                    node.IsFucky = i == chars.Length - 1;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorLine(ex.Message);
                            ExcelHelper.PrintRow(row);
                        }
                    }
                    else if (!isAllNull)
                    {
                        Logger.LogErrorLine("Invalid string table line:");
                        ExcelHelper.PrintRow(row);
                    }
                }

                if ((PublishTarget.Current.PublishInfo.Language & packageInfo.Language) == packageInfo.Language)
                {
                    var config = new FuckyString();
                    foreach (var fuckyStringNode in rootNodes)
                    {
                        FuckyStringNode node = new FuckyStringNode();
                        fuckyStringNode.Value.Fill(node);
                        config.rootNodes.Add(node);
                    }

                    string tempPath = PathManager.OutputConfigPath + "/" + TableName +
                                      pureTableName + ".bin";
                    using (var file = File.Open(tempPath, FileMode.Create, FileAccess.ReadWrite))
                    {
                        Serializer.Serialize(file, config);
                        Logger.LogAllLine("Generate:{0}", tempPath);
                    }

                    var resourceFile = new FileListFile(new FileInfo(tempPath), true, true);
                    FileSystemGenerator.AddFileAndTag(resourceFile);
                }
                else
                {
                    Logger.LogAllLine("Ignore:\t{0}", pureTableName);
                }
            }
        }