Created
February 21, 2014 09:47
-
-
Save teeceepee/9131508 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bindata' | |
module W3G | |
# 68 bytes | |
class ReplayHeader < BinData::Record | |
endian :little | |
string :id_string, :read_length => 28 | |
uint32 :header_size | |
uint32 :compressed_size | |
uint32 :header_version | |
uint32 :decompressed_size | |
uint32 :block_count | |
string :version_string, :length => 4 | |
uint32 :version_number | |
uint16 :build_number | |
uint16 :game_mode | |
uint32 :replay_duration | |
uint32 :checksum | |
end | |
class CompressedDataBlock < BinData::Record | |
endian :little | |
# 8 bytes header | |
uint16 :compressed_size | |
uint16 :decompressed_size | |
uint32 :unknown | |
string :data, :read_length => :compressed_size | |
end | |
class Replay < BinData::Record | |
replay_header :header | |
array :blocks, :type => :compressed_data_block, | |
:initial_length => lambda { header.block_count } | |
end | |
end | |
f = File.new "rep1.w3g", 'rb' | |
replay = W3G::Replay.read f | |
#p replay.header.block_count | |
#p replay.blocks.size | |
p " header size: #{replay.header_size}" | |
p "compressed size: #{replay.compressed_size}" | |
p | |
p f.eof? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment