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

local ffxiv_ipc_company_airship_status_item = Proto("ffxiv_ipc_company_airship_status_item", "FFXIV-IPC CompanyAirshipStatusItem")

local company_airship_status_item_fields = {
  return_time  = ProtoField.uint32("ffxiv_ipc_company_airship_status_item.return_time", "ReturnTime", base.DEC),
  max_distance = ProtoField.uint16("ffxiv_ipc_company_airship_status_item.max_distance", "MaxDistance", base.DEC),
  name         = ProtoField.string("ffxiv_ipc_company_airship_status_item.name", "Name", base.UNICODE),
  dest1        = ProtoField.uint8("ffxiv_ipc_company_airship_status_item.dest1", "Dest1", base.DEC),
  dest2        = ProtoField.uint8("ffxiv_ipc_company_airship_status_item.dest2", "Dest2", base.DEC),
  dest3        = ProtoField.uint8("ffxiv_ipc_company_airship_status_item.dest3", "Dest3", base.DEC),
  dest4        = ProtoField.uint8("ffxiv_ipc_company_airship_status_item.dest4", "Dest4", base.DEC),
  dest5        = ProtoField.uint8("ffxiv_ipc_company_airship_status_item.dest5", "Dest5", base.DEC),
  unknown3     = ProtoField.uint16("ffxiv_ipc_company_airship_status_item.unknown3", "Unknown3", base.DEC),
}

ffxiv_ipc_company_airship_status_item.fields = company_airship_status_item_fields

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

  local len = tvbuf:len()

  -- dissect the return_time field
  local return_time_tvbr = tvbuf:range(0, 4)
  local return_time_val  = return_time_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.return_time, return_time_tvbr, return_time_val)

  -- dissect the max_distance field
  local max_distance_tvbr = tvbuf:range(4, 2)
  local max_distance_val  = max_distance_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.max_distance, max_distance_tvbr, max_distance_val)

  -- dissect the name field
  if tvbuf:len() >= 29 then
    local name_tvbr = tvbuf:range(6, 23)
    local name_val  = name_tvbr:string(ENC_UTF_8)
    tree:add(company_airship_status_item_fields.name, name_tvbr, name_val)

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

  -- dissect the dest1 field
  local dest1_tvbr = tvbuf:range(29, 1)
  local dest1_val  = dest1_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.dest1, dest1_tvbr, dest1_val)

  -- dissect the dest2 field
  local dest2_tvbr = tvbuf:range(30, 1)
  local dest2_val  = dest2_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.dest2, dest2_tvbr, dest2_val)

  -- dissect the dest3 field
  local dest3_tvbr = tvbuf:range(31, 1)
  local dest3_val  = dest3_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.dest3, dest3_tvbr, dest3_val)

  -- dissect the dest4 field
  local dest4_tvbr = tvbuf:range(32, 1)
  local dest4_val  = dest4_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.dest4, dest4_tvbr, dest4_val)

  -- dissect the dest5 field
  local dest5_tvbr = tvbuf:range(33, 1)
  local dest5_val  = dest5_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.dest5, dest5_tvbr, dest5_val)

  -- dissect the unknown3 field
  local unknown3_tvbr = tvbuf:range(34, 2)
  local unknown3_val  = unknown3_tvbr:le_uint()
  tree:add_le(company_airship_status_item_fields.unknown3, unknown3_tvbr, unknown3_val)

  return len
end