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

local ffxiv_ipc_fellowship_message_board = Proto("ffxiv_ipc_fellowship_message_board", "FFXIV-IPC FellowshipMessageBoard")

local fellowship_message_board_fields = {
  id                            = ProtoField.uint64("ffxiv_ipc_fellowship_message_board.id", "ID", base.DEC),
  unknown0                      = ProtoField.uint32("ffxiv_ipc_fellowship_message_board.unknown0", "Unknown0", base.DEC),
  next_offset                   = ProtoField.uint16("ffxiv_ipc_fellowship_message_board.next_offset", "NextOffset", base.DEC),
  current_offset                = ProtoField.uint16("ffxiv_ipc_fellowship_message_board.current_offset", "CurrentOffset", base.DEC),
}

ffxiv_ipc_fellowship_message_board.fields = fellowship_message_board_fields

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

  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_message_board_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_message_board_fields.unknown0, unknown0_tvbr, unknown0_val)

  -- dissect the next_offset field
  local next_offset_tvbr = tvbuf:range(12, 2)
  local next_offset_val  = next_offset_tvbr:le_uint()
  tree:add_le(fellowship_message_board_fields.next_offset, next_offset_tvbr, next_offset_val)

  -- dissect the current_offset field
  local current_offset_tvbr = tvbuf:range(14, 2)
  local current_offset_val  = current_offset_tvbr:le_uint()
  tree:add_le(fellowship_message_board_fields.current_offset, current_offset_tvbr, current_offset_val)

  -- dissect fellowship_message_board_item
  local fellowship_message_board_item_dissector = Dissector.get('ffxiv_ipc_fellowship_message_board_item')
  local fellowship_message_board_item_pos = 16
  local fellowship_message_board_item_len = 152
  local fellowship_message_board_item_count = 10

  while fellowship_message_board_item_pos + fellowship_message_board_item_len <= len do
    local fellowship_message_board_item_tvbr = tvbuf:range(fellowship_message_board_item_pos, 152)
    fellowship_message_board_item_dissector:call(fellowship_message_board_item_tvbr:tvb(), pktinfo, root)
    fellowship_message_board_item_pos = fellowship_message_board_item_pos + fellowship_message_board_item_len
    fellowship_message_board_item_count = fellowship_message_board_item_count - 1
    if fellowship_message_board_item_count <= 0 then
      break
    end
  end

  return len
end