class OpenRAReplay::ClientOrder

Public Class Methods

construct(input) click to toggle source
# File lib/openrareplay/order/client.rb, line 25
def self.construct(input)
  command_length = decode_uleb128_io input
  command = input.read(command_length)

  # Credit to AMHOL for figuring out the structure
  # of these orders
  data = input.read(5) # subject id + flag
  flags = decode_u8(data[-1])
  if (flags & 1) == 1 # if the order has a target
    data += input.read(1)
    target_type = decode_u8(data[-1])
    case target_type
    when 1 # target is an actor
      data += input.read(4) # actor_id
    when 2 # target is the terrain
      data += if (flags & 64) == 64 # target is a cell
                input.read(13) # target x, y, layer,
              # and subcell
              else # target is not a cell
                input.read(12) # pos x, y, and z
              end
    when 3 # target is a frozen actor
      data += input.read(8) # player actor id + frozen actor id
    end
  end
  if (flags & 4) == 4 # has target string
    strlen, out = decode_uleb128_io input, output_read: true
    data += out + input.read(strlen)
  end
  if (flags & 16) == 16 # has extra location data
    data += input.read(9) # extra x, y, and layer
  end
  if (flags & 32) == 32 # has extra data
    data += input.read(4) # has extra data
  end
  new(command: command, data: data)
end

Public Instance Methods

client_order?() click to toggle source
# File lib/openrareplay/order/client.rb, line 68
def client_order?
  true
end
serialize() click to toggle source
# File lib/openrareplay/order/client.rb, line 63
def serialize
  (Order::CLIENT_COMMAND + encode_uleb128(command.length) +
   command + data)
end