Пример #1
0
        public MonsterEntry( byte[] data, bool from3gpkm )
        {
            PropertyChangedEnabled = true;
            _data = new GameSection( data );
            _offset = 0;
            Storage = data.Length == 80;

            if( from3gpkm )
            {
                // definiton for 3gpkm-file is
                // decrypted subsection, with shuffle order GAEM
                // Fix by encrypting  incoming data and shifting personality to 0 before recrypting
                var personality = Personality;
                _data.SetInt( 0, 0 );
                _specificXor = new Cipher( 0, OriginalTrainerId );
                for( int i = 32; i < 80; i += 4 )
                {
                    SetEncryptedDWord( i, _data.GetInt( i ) );
                }
                Personality = personality;
                Checksum = CalculatedChecksum;
            }
            else
            {
                _specificXor = new Cipher( Personality, OriginalTrainerId );
            }
        }
Пример #2
0
 public static string ReadStringRaw( GameSection b, int offset, int length )
 {
     var sb = new StringBuilder();
     for( int i = offset; i < offset + length; i++ )
         sb.Append( _data[b[i]] );
     return sb.ToString();
 }
Пример #3
0
 public MonsterEntry( GameSection data, int offset, bool storage )
 {
     PropertyChangedEnabled = true;
     _data = data;
     _offset = offset;
     Storage = storage;
     _specificXor = new Cipher( Personality, OriginalTrainerId );
 }
Пример #4
0
 public void Setup()
 {
     using( var fs = File.OpenRead( "p2.sav" ) )
     {
         var s1 = new GameSection( fs );
         var s2 = new GameSection( fs );
         var s3 = new GameSection( fs );
         _buffer = new PcBuffer( new[] { s1, s2, s3 } );
     }
 }
Пример #5
0
        static void WriteStringInternal( GameSection b, string data, int offset, int length, bool guard )
        {
            for( int stringindex = 0; stringindex < length; stringindex++ )
            {
                var arrayindex = offset + stringindex;
                if( stringindex >= data.Length || ( guard && arrayindex == ( offset + length - 1 ) ) )
                    b[arrayindex] = 0xFF;
                else
                    b[arrayindex] = IndexOf( data[stringindex] );

            }
        }
Пример #6
0
 public static string ReadString( GameSection b, int index, int length )
 {
     var sb = new StringBuilder();
     for( int i = index; i < index + length; i++ )
     {
         byte c = b[i];
         if( c == 255 )
             break;
         sb.Append( _data[c] );
     }
     return sb.ToString();
 }
Пример #7
0
 public void Setup()
 {
     _b = new byte[4096];
     _gs = new GameSection( _b );
 }
Пример #8
0
        public void Setup()
        {
            using( var fs = File.OpenRead( "p2.sav" ) )
            {
                _savesA = new GameSection[14];
                for( int i = 0; i < _savesA.Length; i++ )
                    _savesA[i] = new GameSection( fs );

                _savesB = new GameSection[14];
                for( int i = 0; i < _savesB.Length; i++ )
                    _savesB[i] = new GameSection( fs );
            }
        }
Пример #9
0
 public byte[] To3gPkm()
 {
     var section = new GameSection( RawData );
     var clone = new MonsterEntry( section, 0, Storage );
     clone.Personality = 0;
     for( int i = 32; i < 80; i += 4 )
     {
         section.SetInt( i, clone.GetEncryptedDWord( i ) );
     }
     section.SetInt( 0, Personality );
     section.SetShort( 28, CalculatedChecksum );
     return clone.RawData;
 }
Пример #10
0
 public ItemEntry( GameSection data, int offset, Cipher xor )
 {
     _data = data;
     _offset = offset;
     _xor = xor;
 }
Пример #11
0
 public ItemEntry( GameSection data, int offset )
     : this(data, offset, null)
 {
 }
Пример #12
0
        MonsterEntry TestSection()
        {
            var data = @"9de847ffe1dd6e3bbdbbcdbdc9c9c8ff80430202c5d9e2ffffffff00a4f100007c3529c47c3529c47c3529c4593429c4013529c47c7329c47c0eace45875f8c97c3529c4163529c47c3529c4623529c4";
            var array = new byte[80];

            for( int i = 0; i < array.Length; i++ )
            {
                array[i] = byte.Parse( data.Substring( 2 * i, 2 ), NumberStyles.HexNumber );
            }
            _gs = new GameSection( array );
            return new MonsterEntry( _gs, 0, true );
        }
Пример #13
0
 public static void WriteStringRaw( GameSection b, string data, int offset, int length )
 {
     WriteStringInternal( b, data, offset, length, false );
 }
Пример #14
0
        public GameSave( Stream instream )
        {
            _sections = new List<GameSection>();
            _originalOrderSections = new List<GameSection>();

            for( int i = 0; i < 14; i++ )
            {
                var section = new GameSection( instream );
                section.PropertyChanged += BubbleIsDirty;
                _originalOrderSections.Add( section );
            }
            _sections = _originalOrderSections.OrderBy( s => s.ID ).ToList();

            ExtractType();

            Xor = new Cipher( SecurityKey );

            Dex = new BindingList<DexEntry>();
            for( var i = 0; i < 416; i++ )
                Dex.Add( new DexEntry( i, this ) );

            ExtractTeam();
            ExtractPcBuffer();
            ExtractItems();
            GuessGame();
        }
Пример #15
0
 public void Setup()
 {
     _b = new byte[100];
     _gs = new GameSection( _b );
     _m = new MonsterEntry( _gs, 0, false );
 }