Class: Tassadar::MPQ::EncryptedBlockTable

Inherits:
BinData::BasePrimitive
  • Object
show all
Defined in:
lib/tassadar/mpq/block_table.rb

Instance Method Summary collapse

Instance Method Details

#read_and_return_value(io) ⇒ Object



17
18
19
20
# File 'lib/tassadar/mpq/block_table.rb', line 17

def read_and_return_value(io)
  value = BlockEncryptor.new("(block table)", 0x300, io, eval_parameter(:entries) * 16).decrypt
  BlockTable.read(value)
end

#sensible_defaultObject



31
32
33
# File 'lib/tassadar/mpq/block_table.rb', line 31

def sensible_default
  [0,0,0,0].pack("VVVV")
end

#value_to_binary_string(value) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/tassadar/mpq/block_table.rb', line 22

def value_to_binary_string(value)
  packed_string = ""
  value.blocks.each do |block|
    packed_string += [block.block_offset, block.block_size, block.file_size, block.flags].pack("VVVV")
  end

  BlockEncryptor.new("(block table)", 0x300, BinData::IO.new(packed_string), eval_parameter(:entries) * 16).encrypt
end