Beispiel #1
0
        public static EXP Load(string path)
        {
            FileInfo fi = new FileInfo(path);

            Logger.LogToFile(Logger.LogLevel.Info, "{0}", path);
            EXP exp = new EXP()
            {
                name     = Path.GetFileNameWithoutExtension(path),
                location = Path.GetDirectoryName(path) + "\\"
            };

            using (BEBinaryReader br = new BEBinaryReader(fi.OpenRead()))
            {
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    string section = br.ReadString(4);
                    int    length  = 0;

                    switch (section)
                    {
                    case "FORM":
                        length = (int)br.ReadUInt32();
                        break;

                    case "TERR":
                    case "XOBF":
                        break;

                    case "TITL":
                        length = (int)br.ReadUInt32();
                        if (length > 0)
                        {
                            throw new NotImplementedException(string.Format("TITL section has a length ({0}), don't know what to do!", length));
                        }
                        break;

                    case "TEXT":
                        length = (int)br.ReadUInt32();
                        if (length > 0)
                        {
                            throw new NotImplementedException(string.Format("TEXT section has a length ({0}), don't know what to do!", length));
                        }
                        break;

                    case "HEAD":
                        length = (int)br.ReadUInt32();
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                        exp.entryCount = br.ReadUInt16();
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                        Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                        break;

                    case "BIN ":
                        length = (int)br.ReadUInt32();
                        exp.contents.Add(new EXPEntry {
                            Size = length, Offset = (int)br.BaseStream.Position, EntryType = EXPEntryType.Binary
                        });
                        br.ReadBytes(length);
                        break;

                    case "ANM ":
                        length = (int)br.ReadUInt32();
                        exp.contents.Add(new EXPEntry {
                            Size = length, Offset = (int)br.BaseStream.Position, EntryType = EXPEntryType.Animation
                        });
                        br.ReadBytes(length);
                        break;

                    case "PLTX":
                        length = (int)br.ReadUInt32();
                        if (length > 0)
                        {
                            throw new NotImplementedException(string.Format("PLTX section has a length ({0}), don't know what to do!", length));
                        }
                        break;

                    default:
                        throw new NotImplementedException(string.Format("Unexpected section \"{0}\" at {1,0:X0}", section, br.BaseStream.Position - 4));
                    }
                }
            }

            return(exp);
        }
Beispiel #2
0
        public static EXP Load(string path)
        {
            FileInfo fi = new FileInfo(path);
            Logger.LogToFile(Logger.LogLevel.Info, "{0}", path);
            EXP exp = new EXP();

            exp.name = Path.GetFileNameWithoutExtension(path);
            exp.location = Path.GetDirectoryName(path) + "\\";

            using (var br = new BEBinaryReader(fi.OpenRead()))
            {
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    string section = br.ReadString(4);
                    int length = 0;

                    switch (section)
                    {
                        case "FORM":
                            length = (int)br.ReadUInt32();
                            break;

                        case "TERR":
                        case "XOBF":
                            break;

                        case "TITL":
                            length = (int)br.ReadUInt32();
                            if (length > 0) { throw new NotImplementedException(string.Format("TITL section has a length ({0}), don't know what to do!", length)); }
                            break;

                        case "TEXT":
                            length = (int)br.ReadUInt32();
                            if (length > 0) { throw new NotImplementedException(string.Format("TEXT section has a length ({0}), don't know what to do!", length)); }
                            break;

                        case "HEAD":
                            length = (int)br.ReadUInt32();
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                            exp.entryCount = br.ReadUInt16();
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt16());
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                            Logger.LogToFile(Logger.LogLevel.Debug, "U: {0}", br.ReadUInt32());
                            break;

                        case "BIN ":
                            length = (int)br.ReadUInt32();
                            exp.contents.Add(new EXPEntry { Size = length, Offset = (int)br.BaseStream.Position, EntryType = EXPEntryType.Binary });
                            br.ReadBytes(length);
                            break;

                        case "ANM ":
                            length = (int)br.ReadUInt32();
                            exp.contents.Add(new EXPEntry { Size = length, Offset = (int)br.BaseStream.Position, EntryType = EXPEntryType.Animation });
                            br.ReadBytes(length);
                            break;

                        case "PLTX":
                            length = (int)br.ReadUInt32();
                            if (length > 0) { throw new NotImplementedException(string.Format("PLTX section has a length ({0}), don't know what to do!", length)); }
                            break;

                        default:
                            throw new NotImplementedException(string.Format("Unexpected section \"{0}\" at {1,0:X0}", section, br.BaseStream.Position - 4));
                    }
                }
            }

            return exp;
        }