class OpenRAReplay::MetadataPacket

Constants

METADATA_HEADER
METADATA_VERSION

Public Instance Methods

metadata?() click to toggle source
# File lib/openrareplay/packet/metadata_packet.rb, line 33
def metadata?
  true
end
unknown?() click to toggle source
# File lib/openrareplay/packet/metadata_packet.rb, line 29
def unknown?
  false
end

Private Instance Methods

construct_byte_array(type) click to toggle source
# File lib/openrareplay/packet/metadata_packet.rb, line 55
def construct_byte_array(type)
  raise "#{self.class.name} only supports :data construction!" unless type == :data
  @orders = []
  @client_id = -1
  @frame = -1
  @length = data.length
  @byte_array = METADATA_HEADER + METADATA_VERSION +
                (encode_u32 length) +
                data.force_encoding('ASCII-8BIT') +
                encode_u32(length + 4) + METADATA_FOOTER
end
parse_byte_array() click to toggle source
# File lib/openrareplay/packet/metadata_packet.rb, line 39
def parse_byte_array
  header = byte_array[0..3]
  raise "Metadata header is not a header: #{header.inspect}" unless header == METADATA_HEADER
  version = byte_array[4..7]
  raise "Metadata version doesn't match current version: #{version.inspect}" unless version == METADATA_VERSION
  @length = decode_u32 byte_array[8..11]
  @client_id = -1
  @frame = -1
  @data = byte_array[12..(11 + length)]
  length2 = decode_u32 byte_array[(12 + length)..(15 + length)]
  raise "Appended length isn't correct: #{length2} vs expected #{length + 4}" unless length2 == (length + 4)
  footer = byte_array[(16 + length)..(19 + length)]
  raise "Metadata footer is not a footer: #{footer.inspect}" unless footer == METADATA_FOOTER
  @orders = []
end