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

local ffxiv_ipc_fellowship_detail = Proto("ffxiv_ipc_fellowship_detail", "FFXIV-IPC FellowshipDetail")

local fellowship_detail_fields = {
  unique_id            = ProtoField.uint64("ffxiv_ipc_fellowship_detail.unique_id", "UniqueID", base.DEC),
  unknown0             = ProtoField.uint64("ffxiv_ipc_fellowship_detail.unknown0", "Unknown0", base.DEC),
  padding0             = ProtoField.uint32("ffxiv_ipc_fellowship_detail.padding0", "Padding0", base.DEC),
  create_time          = ProtoField.uint32("ffxiv_ipc_fellowship_detail.create_time", "CreateTime", base.DEC),
  vote_end_time        = ProtoField.uint32("ffxiv_ipc_fellowship_detail.vote_end_time", "VoteEndTime", base.DEC),
  recruit_end_time     = ProtoField.uint32("ffxiv_ipc_fellowship_detail.recruit_end_time", "RecruitEndTime", base.DEC),
  joined_time          = ProtoField.uint32("ffxiv_ipc_fellowship_detail.joined_time", "JoinedTime", base.DEC),
  unknown1             = ProtoField.uint64("ffxiv_ipc_fellowship_detail.unknown1", "Unknown1", base.DEC),
  padding2             = ProtoField.uint32("ffxiv_ipc_fellowship_detail.padding2", "Padding2", base.DEC),
  padding3             = ProtoField.uint8("ffxiv_ipc_fellowship_detail.padding3", "Padding3", base.DEC),
  name                 = ProtoField.string("ffxiv_ipc_fellowship_detail.name", "Name", base.UNICODE),
  boardcast            = ProtoField.string("ffxiv_ipc_fellowship_detail.boardcast", "Boardcast", base.UNICODE),
  owner_name           = ProtoField.string("ffxiv_ipc_fellowship_detail.owner_name", "OwnerName", base.UNICODE),
}

ffxiv_ipc_fellowship_detail.fields = fellowship_detail_fields

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

  local len = tvbuf:len()

  -- dissect the unique_id field
  local unique_id_tvbr = tvbuf:range(0, 8)
  local unique_id_val  = unique_id_tvbr:le_uint64()
  tree:add_le(fellowship_detail_fields.unique_id, unique_id_tvbr, unique_id_val)

  -- dissect the unknown0 field
  local unknown0_tvbr = tvbuf:range(8, 8)
  local unknown0_val  = unknown0_tvbr:le_uint64()
  tree:add_le(fellowship_detail_fields.unknown0, unknown0_tvbr, unknown0_val)

  -- dissect the padding0 field
  local padding0_tvbr = tvbuf:range(16, 4)
  local padding0_val  = padding0_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.padding0, padding0_tvbr, padding0_val)

  -- dissect the create_time field
  local create_time_tvbr = tvbuf:range(20, 4)
  local create_time_val  = create_time_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.create_time, create_time_tvbr, create_time_val)

  -- dissect the vote_end_time field
  local vote_end_time_tvbr = tvbuf:range(24, 4)
  local vote_end_time_val  = vote_end_time_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.vote_end_time, vote_end_time_tvbr, vote_end_time_val)

  -- dissect the recruit_end_time field
  local recruit_end_time_tvbr = tvbuf:range(28, 4)
  local recruit_end_time_val  = recruit_end_time_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.recruit_end_time, recruit_end_time_tvbr, recruit_end_time_val)

  -- dissect the joined_time field
  local joined_time_tvbr = tvbuf:range(32, 4)
  local joined_time_val  = joined_time_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.joined_time, joined_time_tvbr, joined_time_val)

  -- dissect the unknown1 field
  local unknown1_tvbr = tvbuf:range(36, 8)
  local unknown1_val  = unknown1_tvbr:le_uint64()
  tree:add_le(fellowship_detail_fields.unknown1, unknown1_tvbr, unknown1_val)

  -- dissect byte_padding
  local byte_padding_dissector = Dissector.get('ffxiv_ipc_byte_padding')
  local byte_padding_pos = 44
  local byte_padding_len = 1
  local byte_padding_count = 368

  while byte_padding_pos + byte_padding_len <= len do
    local byte_padding_tvbr = tvbuf:range(byte_padding_pos, 1)
    byte_padding_dissector:call(byte_padding_tvbr:tvb(), pktinfo, root)
    byte_padding_pos = byte_padding_pos + byte_padding_len
    byte_padding_count = byte_padding_count - 1
    if byte_padding_count <= 0 then
      break
    end
  end

  -- dissect fellowship_note_item
  local fellowship_note_item_dissector = Dissector.get('ffxiv_ipc_fellowship_note_item')
  local fellowship_note_item_pos = 412
  local fellowship_note_item_len = 97
  local fellowship_note_item_count = 5

  while fellowship_note_item_pos + fellowship_note_item_len <= len do
    local fellowship_note_item_tvbr = tvbuf:range(fellowship_note_item_pos, 97)
    fellowship_note_item_dissector:call(fellowship_note_item_tvbr:tvb(), pktinfo, root)
    fellowship_note_item_pos = fellowship_note_item_pos + fellowship_note_item_len
    fellowship_note_item_count = fellowship_note_item_count - 1
    if fellowship_note_item_count <= 0 then
      break
    end
  end

  -- dissect the padding2 field
  local padding2_tvbr = tvbuf:range(897, 4)
  local padding2_val  = padding2_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.padding2, padding2_tvbr, padding2_val)

  -- dissect the padding3 field
  local padding3_tvbr = tvbuf:range(901, 1)
  local padding3_val  = padding3_tvbr:le_uint()
  tree:add_le(fellowship_detail_fields.padding3, padding3_tvbr, padding3_val)

  -- dissect the name field
  local name_tvbr = tvbuf:range(902, 61)
  local name_val  = name_tvbr:string(ENC_UTF_8)
  tree:add(fellowship_detail_fields.name, name_tvbr, name_val)

  -- dissect the boardcast field
  local boardcast_tvbr = tvbuf:range(963, 193)
  local boardcast_val  = boardcast_tvbr:string(ENC_UTF_8)
  tree:add(fellowship_detail_fields.boardcast, boardcast_tvbr, boardcast_val)

  -- dissect the owner_name field
  local owner_name_tvbr = tvbuf:range(1156, 36)
  local owner_name_val  = owner_name_tvbr:string(ENC_UTF_8)
  tree:add(fellowship_detail_fields.owner_name, owner_name_tvbr, owner_name_val)

  return len
end