예제 #1
0
        private bool LoadFile(System.IO.Stream stream)
        {
            // not entirely sure if this is actually type information?
            Type = stream.ReadUInt32();
            if (Type <= 0xFFFF)
            {
                Endian = EndianUtils.Endianness.LittleEndian;
            }
            else
            {
                Endian = EndianUtils.Endianness.BigEndian;
                Type   = Type.SwapEndian();
            }

            bool ToZ;

            switch (Type)
            {
            case 0x08: ToZ = false; break;

            case 0x100: ToZ = true; break;

            default: System.Console.WriteLine("Unknown SDB file type!"); return(false);
            }

            if (ToZ)
            {
                // seems to always be 0x0C
                uint unknown = stream.ReadUInt32().FromEndian(Endian);
            }

            uint textAmount = stream.ReadUInt32().FromEndian(Endian);

            if (ToZ)
            {
                uint otherDataAmount = stream.ReadUInt32().FromEndian(Endian);
                OtherData = new List <uint>((int)otherDataAmount);
                for (uint i = 0; i < otherDataAmount; ++i)
                {
                    OtherData.Add(stream.ReadUInt32().FromEndian(Endian));
                }
                uint textOffset = stream.ReadUInt32().FromEndian(Endian);
            }

            TextList = new List <SDBEntry>((int)textAmount);
            for (uint i = 0; i < textAmount; ++i)
            {
                SDBEntry x = new SDBEntry();
                x.PointerIDString = (uint)stream.Position + stream.ReadUInt32().FromEndian(Endian);
                x.PointerText     = (uint)stream.Position + stream.ReadUInt32().FromEndian(Endian);
                TextList.Add(x);
            }
            for (int i = 0; i < TextList.Count; ++i)
            {
                SDBEntry x = TextList[i];
                stream.Position = x.PointerIDString;
                x.IDString      = stream.ReadUTF8Nullterm();
                stream.Position = x.PointerText;
                x.Text          = stream.ReadUTF8Nullterm();
            }

            return(true);
        }
예제 #2
0
        private bool LoadFile( System.IO.Stream stream )
        {
            // not entirely sure if this is actually type information?
            Type = stream.ReadUInt32();
            if ( Type <= 0xFFFF ) {
                Endian = Util.Endianness.LittleEndian;
            } else {
                Endian = Util.Endianness.BigEndian;
                Type = Type.SwapEndian();
            }

            bool ToZ;
            switch ( Type ) {
                case 0x08: ToZ = false; break;
                case 0x100: ToZ = true; break;
                default: System.Console.WriteLine( "Unknown SDB file type!" ); return false;
            }

            if ( ToZ ) {
                // seems to always be 0x0C
                uint unknown = stream.ReadUInt32().FromEndian( Endian );
            }

            uint textAmount = stream.ReadUInt32().FromEndian( Endian );

            if ( ToZ ) {
                uint otherDataAmount = stream.ReadUInt32().FromEndian( Endian );
                OtherData = new List<uint>( (int)otherDataAmount );
                for ( uint i = 0; i < otherDataAmount; ++i ) {
                    OtherData.Add( stream.ReadUInt32().FromEndian( Endian ) );
                }
                uint textOffset = stream.ReadUInt32().FromEndian( Endian );
            }

            TextList = new List<SDBEntry>( (int)textAmount );
            for ( uint i = 0; i < textAmount; ++i ) {
                SDBEntry x = new SDBEntry();
                x.PointerIDString = (uint)stream.Position + stream.ReadUInt32().FromEndian( Endian );
                x.PointerText = (uint)stream.Position + stream.ReadUInt32().FromEndian( Endian );
                TextList.Add( x );
            }
            for ( int i = 0; i < TextList.Count; ++i ) {
                SDBEntry x = TextList[i];
                stream.Position = x.PointerIDString;
                x.IDString = stream.ReadUTF8Nullterm();
                stream.Position = x.PointerText;
                x.Text = stream.ReadUTF8Nullterm();
            }

            return true;
        }