-- This file is generated by tools/json2lua.js

local ffxiv_ipc_fellowship_member = Proto("ffxiv_ipc_fellowship_member", "FFXIV-IPC FellowshipMember")

local fellowship_member_fields = {
  id                     = ProtoField.uint64("ffxiv_ipc_fellowship_member.id", "ID", base.DEC),
  unknown0               = ProtoField.uint32("ffxiv_ipc_fellowship_member.unknown0", "Unknown0", base.DEC),
  unknown1               = ProtoField.uint32("ffxiv_ipc_fellowship_member.unknown1", "Unknown1", base.DEC),
  unknown2               = ProtoField.uint32("ffxiv_ipc_fellowship_member.unknown2", "Unknown2", base.DEC),
  unknown_time           = ProtoField.uint32("ffxiv_ipc_fellowship_member.unknown_time", "UnknownTime", base.DEC),
  unknown3               = ProtoField.uint32("ffxiv_ipc_fellowship_member.unknown3", "Unknown3", base.DEC),
  unknown4               = ProtoField.uint32("ffxiv_ipc_fellowship_member.unknown4", "Unknown4", base.DEC),
}

ffxiv_ipc_fellowship_member.fields = fellowship_member_fields

function ffxiv_ipc_fellowship_member.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_fellowship_member, tvbuf)
  pktinfo.cols.info:set("FellowshipMember")

  local len = tvbuf:len()

  -- dissect the id field
  local id_tvbr = tvbuf:range(0, 8)
  local id_val  = id_tvbr:le_uint64()
  tree:add_le(fellowship_member_fields.id, id_tvbr, id_val)

  -- dissect the unknown0 field
  local unknown0_tvbr = tvbuf:range(8, 4)
  local unknown0_val  = unknown0_tvbr:le_uint()
  tree:add_le(fellowship_member_fields.unknown0, unknown0_tvbr, unknown0_val)

  -- dissect the unknown1 field
  local unknown1_tvbr = tvbuf:range(12, 4)
  local unknown1_val  = unknown1_tvbr:le_uint()
  tree:add_le(fellowship_member_fields.unknown1, unknown1_tvbr, unknown1_val)

  -- dissect the unknown2 field
  local unknown2_tvbr = tvbuf:range(16, 4)
  local unknown2_val  = unknown2_tvbr:le_uint()
  tree:add_le(fellowship_member_fields.unknown2, unknown2_tvbr, unknown2_val)

  -- dissect the unknown_time field
  local unknown_time_tvbr = tvbuf:range(20, 4)
  local unknown_time_val  = unknown_time_tvbr:le_uint()
  tree:add_le(fellowship_member_fields.unknown_time, unknown_time_tvbr, unknown_time_val)

  -- dissect the unknown3 field
  local unknown3_tvbr = tvbuf:range(24, 4)
  local unknown3_val  = unknown3_tvbr:le_uint()
  tree:add_le(fellowship_member_fields.unknown3, unknown3_tvbr, unknown3_val)

  -- dissect the unknown4 field
  local unknown4_tvbr = tvbuf:range(28, 4)
  local unknown4_val  = unknown4_tvbr:le_uint()
  tree:add_le(fellowship_member_fields.unknown4, unknown4_tvbr, unknown4_val)

  -- dissect fellowship_member_item
  local fellowship_member_item_dissector = Dissector.get('ffxiv_ipc_fellowship_member_item')
  local fellowship_member_item_pos = 32
  local fellowship_member_item_len = 56
  local fellowship_member_item_count = 8

  while fellowship_member_item_pos + fellowship_member_item_len <= len do
    local fellowship_member_item_tvbr = tvbuf:range(fellowship_member_item_pos, 56)
    fellowship_member_item_dissector:call(fellowship_member_item_tvbr:tvb(), pktinfo, root)
    fellowship_member_item_pos = fellowship_member_item_pos + fellowship_member_item_len
    fellowship_member_item_count = fellowship_member_item_count - 1
    if fellowship_member_item_count <= 0 then
      break
    end
  end

  return len
end