Exemple #1
0
        private bool LoadFile(byte[] File)
        {
            FunctionCalls = new List <bscrFunc>();
            Strings       = new List <bscrString>();

            UnknownMaybeType       = BitConverter.ToUInt16(File, 0x04);
            Filename               = Util.GetTextUTF8(File, 0x06);
            Filesize               = BitConverter.ToUInt32(File, 0x24);
            FunctionCount          = BitConverter.ToUInt32(File, 0x28);
            StartOfFunctionSection = BitConverter.ToUInt32(File, 0x2C);
            TextCount              = BitConverter.ToUInt32(File, 0x30);
            StartOfTextSection     = BitConverter.ToUInt32(File, 0x34);
            ScriptSize             = BitConverter.ToUInt32(File, 0x38);
            StartOfScriptSection   = BitConverter.ToUInt32(File, 0x3C);

            int pos;

            for (pos = (int)StartOfFunctionSection; pos < StartOfTextSection;)
            {
                bscrFunc f = new bscrFunc();
                f.Size    = BitConverter.ToUInt16(File, pos);
                f.Unknown = BitConverter.ToUInt16(File, pos + 2);
                f.Name    = Util.GetTextUTF8(File, pos + 4);
                f.Params  = new uint[(f.Size - 0x24) / 4];
                for (int i = 0; i < f.Params.Length; ++i)
                {
                    f.Params[i] = BitConverter.ToUInt32(File, pos + 0x24 + i * 4);
                }

                FunctionCalls.Add(f);
                pos += f.Size;
            }

            pos = (int)StartOfTextSection;
            for (uint i = 0; i < TextCount; ++i)
            {
                bscrString s = new bscrString();
                int        nullLoc;
                s.String   = Util.GetTextUTF8(File, pos, out nullLoc);
                s.Position = (uint)pos;

                Strings.Add(s);
                pos = nullLoc + 1;
            }

            Script = new List <uint>((int)ScriptSize);
            for (int i = 0; i < ScriptSize; i += 4)
            {
                uint val = BitConverter.ToUInt32(File, (int)(StartOfScriptSection + i));
                Script.Add(val);
            }


            return(true);
        }
Exemple #2
0
        private bool LoadFile( byte[] File )
        {
            FunctionCalls = new List<bscrFunc>();
            Strings = new List<bscrString>();

            UnknownMaybeType = BitConverter.ToUInt16( File, 0x04 );
            Filename = Util.GetTextUTF8( File, 0x06 );
            Filesize = BitConverter.ToUInt32( File, 0x24 );
            FunctionCount = BitConverter.ToUInt32( File, 0x28 );
            StartOfFunctionSection = BitConverter.ToUInt32( File, 0x2C );
            TextCount = BitConverter.ToUInt32( File, 0x30 );
            StartOfTextSection = BitConverter.ToUInt32( File, 0x34 );
            ScriptSize = BitConverter.ToUInt32( File, 0x38 );
            StartOfScriptSection = BitConverter.ToUInt32( File, 0x3C );

            int pos;
            for ( pos = (int)StartOfFunctionSection; pos < StartOfTextSection; ) {
                bscrFunc f = new bscrFunc();
                f.Size = BitConverter.ToUInt16( File, pos );
                f.Unknown = BitConverter.ToUInt16( File, pos + 2 );
                f.Name = Util.GetTextUTF8( File, pos + 4 );
                f.Params = new uint[( f.Size - 0x24 ) / 4];
                for ( int i = 0; i < f.Params.Length; ++i ) {
                    f.Params[i] = BitConverter.ToUInt32( File, pos + 0x24 + i * 4 );
                }

                FunctionCalls.Add( f );
                pos += f.Size;
            }

            pos = (int)StartOfTextSection;
            for ( uint i = 0; i < TextCount; ++i ) {
                bscrString s = new bscrString();
                int nullLoc;
                s.String = Util.GetTextUTF8( File, pos, out nullLoc );
                s.Position = (uint)pos;

                Strings.Add( s );
                pos = nullLoc + 1;
            }

            Script = new List<uint>( (int)ScriptSize );
            for ( int i = 0; i < ScriptSize; i += 4 ) {
                uint val = BitConverter.ToUInt32( File, (int)( StartOfScriptSection + i ) );
                Script.Add( val );
            }

            return true;
        }