コード例 #1
0
ファイル: FileExport.cs プロジェクト: OptimShi/ACViewer
        public static bool ExportRaw(DatType datType, uint fileID, string outFilename)
        {
            DatDatabase datDatabase = null;

            switch (datType)
            {
            case DatType.Cell:
                datDatabase = DatManager.CellDat;
                break;

            case DatType.Portal:
                datDatabase = DatManager.PortalDat;
                break;

            case DatType.HighRes:
                datDatabase = DatManager.HighResDat;
                break;

            case DatType.Language:
                datDatabase = DatManager.LanguageDat;
                break;
            }

            if (datDatabase == null)
            {
                return(false);
            }

            var datReader = datDatabase.GetReaderForFile(fileID);

            if (datReader == null)
            {
                return(false);
            }

            var maxFileSize = 10000000;

            using (var memoryStream = new MemoryStream(datReader.Buffer))
            {
                using (var reader = new BinaryReader(memoryStream))
                {
                    var bytes = reader.ReadBytes(maxFileSize);
                    Console.WriteLine($"Read {bytes.Length} bytes");

                    File.WriteAllBytes(outFilename, bytes);
                }
            }
            MainWindow.Instance.AddStatusText($"Wrote {outFilename}");
            return(true);
        }
コード例 #2
0
ファイル: ClassStruct.cs プロジェクト: jtljac/DatBuildTool
        public bool parseClass(ref StreamReader File, ref int lineCount)
        {
            string  fileLine;
            string  line    = "";
            DatType datType = DatType.NONE;
            int     depth   = 0;

            while ((fileLine = File.ReadLine()) != null && depth >= 0)
            {
                lineCount++;
                fileLine = fileLine.Trim();
                // Ignore empty lines and preprocessor stuff
                if (fileLine.Length == 0)
                {
                    continue;
                }
                Console.Out.WriteLine("Line " + lineCount + ": " + fileLine);
                if (fileLine.StartsWith("#"))
                {
                    continue;
                }
                if (fileLine.StartsWith("//"))
                {
                    continue;
                }

                // Dat Things
                if (fileLine.StartsWith("DatClass("))
                {
                    datType = DatType.CLASS;
                }
                else if (fileLine.StartsWith("DatMember("))
                {
                    datType = DatType.MEMBER;
                }
                else if (fileLine.StartsWith("DatFunction("))
                {
                    datType = DatType.FUNCTION;
                }

                // Engine Generated stuff
                if (fileLine.StartsWith("ENGINE_GENERATED()"))
                {
                    if (generatedLine == -1)
                    {
                        generatedLine = lineCount;
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (fileLine.Contains('{'))
                {
                    depth++;
                }
                else if (fileLine.Contains('}'))
                {
                    depth--;
                }

                // Bunch together lines for ease
                if (datType != DatType.NONE)
                {
                    // Add onto current line
                    if (line.Length == 0)
                    {
                        line += fileLine;
                    }
                    else
                    {
                        line += " " + fileLine;
                    }
                }

                // Specifics
                switch (datType)
                {
                case DatType.MEMBER:
                    if (line.Contains(';'))
                    {
                        MemberStruct member = new MemberStruct(line);
                        members.Add(member);
                        line    = "";
                        datType = DatType.NONE;
                    }
                    break;

                case DatType.FUNCTION:
                    if (line.Contains('{') || line.Contains(';'))
                    {
                        MethodStruct method = new MethodStruct(line);
                        methods.Add(method);
                        line    = "";
                        datType = DatType.NONE;
                    }
                    break;
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: DatReader.cs プロジェクト: spazmodica/acrender
 public DatReader(FileInfo sourceFile, DatType datType)
 {
     Debug.Assert(sourceFile != null && sourceFile.Exists);
     m_sourceFile = sourceFile;
     m_datType    = datType;
 }
コード例 #4
0
ファイル: Dungeon.cs プロジェクト: spazmodica/acrender
 public DungeonBlockInfo(DatType sourceType, EmbeddedFile sourceFile)
 {
     m_sourceFile = sourceFile;
     m_sourceType = sourceType;
 }