public static void ReadDatabase( StringFile StringFile, string ConnectionString )
        {
            SQLiteConnection Connection = new SQLiteConnection( ConnectionString );
            Connection.Open();

            StringFile.Strings = new List<bscrString>();

            using ( SQLiteTransaction Transaction = Connection.BeginTransaction() )
            using ( SQLiteCommand Command = new SQLiteCommand( Connection ) ) {
                Command.CommandText = "SELECT english, PointerRef FROM Text ORDER BY PointerRef";
                SQLiteDataReader r = Command.ExecuteReader();
                while ( r.Read() ) {
                    String SQLText;

                    try {
                        SQLText = r.GetString( 0 ).Replace( "''", "'" );
                    } catch ( System.InvalidCastException ) {
                        SQLText = "";
                    }

                    int PointerRef = r.GetInt32( 1 );

                    bscrString b = new bscrString();
                    b.Position = (uint)PointerRef;
                    b.String = SQLText;
                    StringFile.Strings.Add( b );
                }

                Transaction.Rollback();
            }
            return;
        }
Example #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);
        }
Example #3
0
        private bool LoadFile( byte[] File )
        {
            Strings = new List<bscrString>();
            StringBlockSize = BitConverter.ToUInt32( File, 0 );

            int pos = 0x04;
            while ( pos < StringBlockSize + 4 ) {
                bscrString s = new bscrString();
                int nullLoc;
                s.String = Util.GetTextUTF8( File, pos, out nullLoc );
                s.Position = (uint)pos;

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

            return true;
        }
Example #4
0
        private bool LoadFile(byte[] File)
        {
            Strings         = new List <bscrString>();
            StringBlockSize = BitConverter.ToUInt32(File, 0);

            int pos = 0x04;

            while (pos < StringBlockSize + 4)
            {
                bscrString s = new bscrString();
                int        nullLoc;
                s.String   = Util.GetTextUTF8(File, pos, out nullLoc);
                s.Position = (uint)pos;

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

            return(true);
        }
Example #5
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;
        }