feh-bin 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6ae7f744caaaea5469cdccc2df546cc75ecc47113065e1dd23f683e55bcd929
4
- data.tar.gz: 23d4587f451147c72a4612b9b259ea308e05bedc747b16fc6fc11b63f5161e15
3
+ metadata.gz: 0304cfd58f785acb4908eb96856da9380ae89e6161d7d450ab2e40ea2d465ce0
4
+ data.tar.gz: 671afa221a5a7d418c6baec3d8517a38b1dcd6f0a83da55a712f515ea3db71ce
5
5
  SHA512:
6
- metadata.gz: 8bb752115f14ba7815a8faadc7bedb7772501f2ec4bb66270cf14fd2850a6646cf519df407ab60b21e4fa34fa0e41f086873e7abf79f4d831fd1e762bdbfd429
7
- data.tar.gz: ba17da68e9538d5a094fc50e7801b35c5b983d4449bbec9cc78245d107e298c77e04af094f826b8503a1a6b8c89ae7a4c1ee85acfd616bf1338a735aa41e3905
6
+ metadata.gz: 7f3585ad8d91ffc43b3af67fd918ffe74435155f33f247d605175352805c7edf709566de3b3e0bc10fa8efbf29fa58f188535e73c3175c6a2a1c5bec545a53aa
7
+ data.tar.gz: 01baff5c76e53a9cdd6b2e6432be210197fec4158292dbc0c26e38015bc24627f15e6fb3de1da3362e0142fdb3569921a36ce4a50cd634107b33b9700f3872df
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feh-bin (0.1.0)
4
+ feh-bin (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -19,4 +19,4 @@ DEPENDENCIES
19
19
  rake (~> 10.0)
20
20
 
21
21
  BUNDLED WITH
22
- 1.16.3
22
+ 1.16.5
data/README.md CHANGED
@@ -26,6 +26,16 @@ Dir.glob('assets/Common/SRPGMap/*.bin.lz').each do |fname|
26
26
  end
27
27
  ```
28
28
 
29
+ ## Changelog
30
+
31
+ ### V0.1.2
32
+
33
+ - Fixed double encryption issue in `Feh::Bin.compress`
34
+
35
+ ### V0.1.0
36
+
37
+ - Initial release
38
+
29
39
  ## License
30
40
 
31
41
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -10,10 +10,9 @@ module Feh
10
10
  # @return [Symbol] error code if the input is not a valid .bin.lz file
11
11
  def self.decompress(buf)
12
12
  buf = buf.bytes if buf.is_a?(String)
13
- read_bin_lz(buf)
14
- # buf = read_bin_lz(buf)
15
- # return buf if buf.is_a?(Symbol)
16
- # LZ11.new(buf).decompress
13
+ buf2 = read_bin_lz(buf)
14
+ return buf2 if buf2.is_a?(Symbol)
15
+ LZ11.new(buf2).decompress
17
16
  end
18
17
 
19
18
  # Compresses data into a .bin.lz file.
@@ -22,9 +21,9 @@ module Feh
22
21
  # @return [Symbol] error code if the input is not a valid data buffer
23
22
  def self.compress(buf)
24
23
  buf = buf.bytes if buf.is_a?(String)
25
- buf = LZ11.new(buf).compress
26
- return buf if buf.is_a?(Symbol)
27
- write_bin_lz(buf)
24
+ buf2 = LZ11.new(buf).compress
25
+ return buf2 if buf2.is_a?(Symbol)
26
+ write_bin_lz(buf2, buf.size)
28
27
  end
29
28
 
30
29
  # Unpacks a Fire Emblem Heroes .bin.lz file.
@@ -41,29 +40,27 @@ module Feh
41
40
  4.times {|j| buf[i + j] ^= xorkey[j]}
42
41
  4.times {|j| xorkey[j] ^= buf[i + j]}
43
42
  end
44
- LZ11.new(buf).decompress
45
- elsif header.first == 0x04 && xorseed == buf.size
46
- xorkey = [0x8083 * xorseed].pack('<I').bytes
47
- (0...buf.size).step(4).each do |i|
48
- 4.times {|j| buf[i + j] ^= xorkey[j]}
49
- 4.times {|j| xorkey[j] ^= buf[i + j]}
50
- end
51
43
  buf
44
+ # elsif header.first == 0x04 && xorseed == buf.size
45
+ # xorkey = [0x8083 * xorseed].pack('<I').bytes
46
+ # (0...buf.size).step(4).each do |i|
47
+ # 4.times {|j| buf[i + j] ^= xorkey[j]}
48
+ # 4.times {|j| xorkey[j] ^= buf[i + j]}
49
+ # end
50
+ # buf
52
51
  else
53
52
  :invalid_archive
54
53
  end
55
54
  end
56
55
 
57
56
  # Packs a Fire Emblem Heroes .bin.lz file.
58
- # @param buf [Array<Integer>, String] content of an LZ11 archive
57
+ # @param bytes [Array<Integer>, String] content of an LZ11 archive
58
+ # @param xorseed [Integer, nil] optional XOR encryption value
59
59
  # @return [Array<Integer>] content of the packed .bin.lz file
60
- # @return [Symbol] error code if the input is not a valid LZ11 archive
61
- def self.write_bin_lz(buf)
62
- buf = buf.bytes if buf.is_a?(String)
63
- bytes = LZ11.new(buf).compress
64
- return bytes if bytes.is_a?(Symbol)
60
+ def self.write_bin_lz(bytes, xorseed = nil)
61
+ bytes = bytes.bytes if bytes.is_a?(String)
65
62
  bytes += [0] * ((-bytes.size) % 4)
66
- xorseed = buf.size
63
+ xorseed = bytes.size if xorseed.nil?
67
64
  header = [xorseed * 0x100 + 0x17].pack('<I').bytes
68
65
  xorkey = [0x8083 * xorseed].pack('<I').bytes
69
66
  4.times {|j| bytes[4 + j] ^= xorkey[j]}
@@ -1,6 +1,6 @@
1
1
  module Feh
2
2
  module Bin
3
3
  # Version number.
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feh-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quinton Miller