Class: Tassadar::MPQ::MPQ

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

Instance Method Summary collapse

Instance Method Details

#filesObject



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

def files
  @files ||= read_file('(listfile)').split
end

#get_hash_table_entry(filename) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/tassadar/mpq.rb', line 38

def get_hash_table_entry(filename)
  hash_a = BlockEncryptor.hash_string(filename, 0x100)
  hash_b = BlockEncryptor.hash_string(filename, 0x200)

  block = self.block_table.blocks[self.hash_table.hashes.select {|hash| hash.file_path_hash_a == hash_a && hash.file_path_hash_b == hash_b}.first.file_block_index]
  self.file_data.select {|f| f.block_offset == block.block_offset}.first
end

#read_file(filename) ⇒ Object



34
35
36
# File 'lib/tassadar/mpq.rb', line 34

def read_file(filename)
  get_hash_table_entry(filename).decompressed_data
end