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

local ffxiv_ipc_company_info = Proto("ffxiv_ipc_company_info", "FFXIV-IPC Company Info")

local company_info_fields = {
  credits        = ProtoField.uint32("ffxiv_ipc_company_info.credits", "Credits", base.DEC),
  members        = ProtoField.uint32("ffxiv_ipc_company_info.members", "Members", base.DEC),
  online_members = ProtoField.uint32("ffxiv_ipc_company_info.online_members", "OnlineMembers", base.DEC),
  name           = ProtoField.string("ffxiv_ipc_company_info.name", "Name", base.UNICODE),
  tag            = ProtoField.string("ffxiv_ipc_company_info.tag", "Tag", base.UNICODE),
}

ffxiv_ipc_company_info.fields = company_info_fields

function ffxiv_ipc_company_info.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_company_info, tvbuf)
  pktinfo.cols.info:set("Company Info")

  local len = tvbuf:len()

  -- dissect the credits field
  local credits_tvbr = tvbuf:range(24, 4)
  local credits_val  = credits_tvbr:le_uint()
  tree:add_le(company_info_fields.credits, credits_tvbr, credits_val)

  -- dissect the members field
  local members_tvbr = tvbuf:range(44, 2)
  local members_val  = members_tvbr:le_uint()
  tree:add_le(company_info_fields.members, members_tvbr, members_val)

  -- dissect the online_members field
  local online_members_tvbr = tvbuf:range(46, 2)
  local online_members_val  = online_members_tvbr:le_uint()
  tree:add_le(company_info_fields.online_members, online_members_tvbr, online_members_val)

  -- dissect the name field
  local name_tvbr = tvbuf:range(50, 22)
  local name_val  = name_tvbr:string(ENC_UTF_8)
  tree:add(company_info_fields.name, name_tvbr, name_val)

  local name_display = ", Name: " .. name_val
  pktinfo.cols.info:append(name_display)
  tree:append_text(name_display)

  -- dissect the tag field
  local tag_tvbr = tvbuf:range(72, 8)
  local tag_val  = tag_tvbr:string(ENC_UTF_8)
  tree:add(company_info_fields.tag, tag_tvbr, tag_val)

  local tag_display = ", Tag: " .. tag_val
  pktinfo.cols.info:append(tag_display)
  tree:append_text(tag_display)

  return len
end