Ejemplo n.º 1
0
        public static SortedDictionary<string, Stream> GetEntries(string archive)
        {
            SortedDictionary<string, Stream> result = new SortedDictionary<string, Stream>();
            BinaryReader br = new BinaryReader(File.OpenRead(archive));
            StringBuilder sb = new StringBuilder();

            var magic = new String(br.ReadChars(4));
            if (magic != "BIG4" && magic != "BIGF")
            {
                throw new BigLoadException(archive + " is not a valid BIG4 File");
            }

            UInt32 filesize = br.ReadUInt32();
            UInt32 numEntries = ReadUint32LE(br);
            UInt32 offset = ReadUint32LE(br);

            for (var i = 0;i<numEntries;++i)
            {
                var entryOffset = ReadUint32LE(br);
                var entrySize = ReadUint32LE(br);

                char c = br.ReadChar();
                while(c!=0)
                {
                    sb.Append(c);
                    c = br.ReadChar();
                }
                var bs = new BigStream(br.BaseStream, entryOffset, entrySize, sb.ToString());
                result.Add(sb.ToString(), bs);
                sb.Clear();
            }

            return result;
        }
Ejemplo n.º 2
0
        public static SortedDictionary <string, Stream> GetEntries(string archive)
        {
            SortedDictionary <string, Stream> result = new SortedDictionary <string, Stream>();
            BinaryReader  br = new BinaryReader(File.Open(archive, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            StringBuilder sb = new StringBuilder();

            var magic = new String(br.ReadChars(4));

            if (magic != "BIG4" && magic != "BIGF")
            {
                throw new BigLoadException(archive + " is not a valid BIG4 File");
            }

            UInt32 filesize   = br.ReadUInt32();
            UInt32 numEntries = ReadUint32LE(br);
            UInt32 offset     = ReadUint32LE(br);

            for (var i = 0; i < numEntries; ++i)
            {
                var entryOffset = ReadUint32LE(br);
                var entrySize   = ReadUint32LE(br);

                char c = br.ReadChar();
                while (c != 0)
                {
                    sb.Append(c);
                    c = br.ReadChar();
                }
                var bs = new BigStream(br.BaseStream, entryOffset, entrySize, sb.ToString());
                result.Add(sb.ToString(), bs);
                sb.Clear();
            }

            return(result);
        }
Ejemplo n.º 3
0
        public INIParser(Stream stream)
            : base(stream)
        {
            str = (BigStream)stream;
            //Console.WriteLine(str.Name);
            long filesize = str.Length;
            while (str.Position < filesize)
            {
                ParseLine();
                string s = getString();
                string name;
                switch (s)
                {
                    case "#include":
                        includeFile(getString());
                        break;
                    case "#define":
                        macros.Add(getString().ToUpper(), getStrings());
                        break;

                    case "Armor":
                        Armor ar = new Armor();
                        name = getString();
                        ParseObject(ar);
                        INIManager.AddArmor(name, ar);
                        break;
                    case "AmbientStream":
                        AmbientStream ast = new AmbientStream();
                        name = getString();
                        ParseObject(ast);
                        INIManager.AddAmbientStream(name, ast);
                        break;
                    case "AudioEvent":
                        AudioEvent e = new AudioEvent();
                        name = getString();
                        ParseObject(e);
                        INIManager.AddAudioEvent(name, e);
                        break;
                    case "CommandButton":
                        CommandButton cb = new CommandButton();
                        name = getString();
                        ParseObject(cb);
                        INIManager.AddCommandButton(name, cb);
                        break;
                    case "DialogEvent":
                        DialogEvent de = new DialogEvent();
                        name = getString();
                        ParseObject(de);
                        INIManager.AddDialogEvent(name, de);
                        break;
                    case "FXList":
                        FXList fl = new FXList();
                        name = getString();
                        ParseObject(fl);
                        INIManager.AddFXList(name, fl);
                        break;
                    case "GameData":
                        GameData data = new GameData();
                        ParseObject(data);
                        INIManager.SetGameData(data);
                        break;
                    case "LoadSubsystem":
                        LoadSubsystem ls = new LoadSubsystem();
                        name = getString();
                        ParseObject(ls);
                        ls.LoadFiles();
                        break;
                    case "MappedImage":
                        MappedImage mi = new MappedImage();
                        name = getString();
                        ParseObject(mi);
                        INIManager.AddMappedImage(name, mi);
                        break;
                    case "ModifierList":
                        ModifierList ml = new ModifierList();
                        name = getString();
                        ParseObject(ml);
                        INIManager.AddModifierList(name, ml);
                        break;
                    case "Multisound":
                        Multisound ms = new Multisound();
                        name = getString();
                        ParseObject(ms);
                        INIManager.AddMultisound(name, ms);
                        break;
                    case "MusicTrack":
                        MusicTrack mt = new MusicTrack();
                        name = getString();
                        ParseObject(mt);
                        INIManager.AddMusicTrack(name, mt);
                        break;
                    case "Object":
                        INI.Object o = new INI.Object();
                        name = getString();
                        ParseObject(o);
                        INIManager.AddObject(name, o);
                        break;
                    case "Science":
                        Science sc = new Science();
                        name = getString();
                        ParseObject(sc);
                        INIManager.AddScience(name, sc);
                        break;
                    case "StreamedSound":
                        StreamedSound ss = new StreamedSound();
                        name = getString();
                        ParseObject(ss);
                        INIManager.AddStreamedSound(name, ss);
                        break;
                    case "Upgrade":
                        Upgrade u = new Upgrade();
                        name = getString();
                        ParseObject(u);
                        INIManager.AddUpgrade(name, u);
                        break;
                    case "Weapon":
                        Weapon w = new Weapon();
                        name = getString();
                        ParseObject(w);
                        INIManager.AddWeapon(name, w);
                        break;
                    default:
                        if (!objects.Contains(s))
                        {
                            //PrintError("unhandled entry: " + s);
                            objects.Add(s);
                        }
                        break;
                }
            }
            count++;
        }