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 ); } }
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; }