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

local db = require('ffxiv_db')
local enum = require('ffxiv_enum')
local ffxiv_ipc_retainer_information = Proto("ffxiv_ipc_retainer_information", "FFXIV-IPC Retainer Information")

local retainer_information_fields = {
  unique_id       = ProtoField.uint64("ffxiv_ipc_retainer_information.unique_id", "UniqueID", base.HEX),
  character_id    = ProtoField.uint32("ffxiv_ipc_retainer_information.character_id", "CharacterID", base.HEX),
  user_server     = ProtoField.uint16("ffxiv_ipc_retainer_information.user_server", "UserServer", base.DEC, db.World),
  type            = ProtoField.uint8("ffxiv_ipc_retainer_information.type", "Type", base.DEC, enum.reverse.public_message_type),
  inventory_count = ProtoField.uint8("ffxiv_ipc_retainer_information.inventory_count", "InventoryCount", base.DEC),
  gold            = ProtoField.uint32("ffxiv_ipc_retainer_information.gold", "Gold", base.DEC),
  selling_count   = ProtoField.uint8("ffxiv_ipc_retainer_information.selling_count", "SellingCount", base.DEC),
  market          = ProtoField.uint8("ffxiv_ipc_retainer_information.market", "Market", base.DEC),
  class_job       = ProtoField.uint8("ffxiv_ipc_retainer_information.class_job", "ClassJob", base.DEC, db.ClassJob),
  level           = ProtoField.uint8("ffxiv_ipc_retainer_information.level", "Level", base.DEC),
  sell_end_time   = ProtoField.uint32("ffxiv_ipc_retainer_information.sell_end_time", "SellEndTime", base.DEC),
  adv_end_time    = ProtoField.uint32("ffxiv_ipc_retainer_information.adv_end_time", "AdvEndTime", base.DEC),
  reserved        = ProtoField.uint8("ffxiv_ipc_retainer_information.reserved", "Reserved", base.DEC),
  nickname        = ProtoField.string("ffxiv_ipc_retainer_information.nickname", "Nickname", base.UNICODE),
}

ffxiv_ipc_retainer_information.fields = retainer_information_fields

function ffxiv_ipc_retainer_information.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_retainer_information, tvbuf)
  pktinfo.cols.info:set("Retainer Information")

  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(retainer_information_fields.unique_id, unique_id_tvbr, unique_id_val)

  -- dissect the character_id field
  local character_id_tvbr = tvbuf:range(8, 4)
  local character_id_val  = character_id_tvbr:le_uint()
  tree:add_le(retainer_information_fields.character_id, character_id_tvbr, character_id_val)

  -- dissect the user_server field
  local user_server_tvbr = tvbuf:range(12, 2)
  local user_server_val  = user_server_tvbr:le_uint()
  tree:add_le(retainer_information_fields.user_server, user_server_tvbr, user_server_val)

  -- dissect the type field
  local type_tvbr = tvbuf:range(14, 1)
  local type_val  = type_tvbr:le_uint()
  tree:add_le(retainer_information_fields.type, type_tvbr, type_val)

  -- dissect the inventory_count field
  local inventory_count_tvbr = tvbuf:range(17, 1)
  local inventory_count_val  = inventory_count_tvbr:le_uint()
  tree:add_le(retainer_information_fields.inventory_count, inventory_count_tvbr, inventory_count_val)

  -- dissect the gold field
  local gold_tvbr = tvbuf:range(20, 4)
  local gold_val  = gold_tvbr:le_uint()
  tree:add_le(retainer_information_fields.gold, gold_tvbr, gold_val)

  -- dissect the selling_count field
  local selling_count_tvbr = tvbuf:range(24, 1)
  local selling_count_val  = selling_count_tvbr:le_uint()
  tree:add_le(retainer_information_fields.selling_count, selling_count_tvbr, selling_count_val)

  -- dissect the market field
  local market_tvbr = tvbuf:range(25, 1)
  local market_val  = market_tvbr:le_uint()
  tree:add_le(retainer_information_fields.market, market_tvbr, market_val)

  -- dissect the class_job field
  local class_job_tvbr = tvbuf:range(26, 1)
  local class_job_val  = class_job_tvbr:le_uint()
  tree:add_le(retainer_information_fields.class_job, class_job_tvbr, class_job_val)

  -- dissect the level field
  local level_tvbr = tvbuf:range(27, 1)
  local level_val  = level_tvbr:le_uint()
  tree:add_le(retainer_information_fields.level, level_tvbr, level_val)

  -- dissect the sell_end_time field
  local sell_end_time_tvbr = tvbuf:range(28, 4)
  local sell_end_time_val  = sell_end_time_tvbr:le_uint()
  tree:add_le(retainer_information_fields.sell_end_time, sell_end_time_tvbr, sell_end_time_val)

  -- dissect the adv_end_time field
  local adv_end_time_tvbr = tvbuf:range(36, 4)
  local adv_end_time_val  = adv_end_time_tvbr:le_uint()
  tree:add_le(retainer_information_fields.adv_end_time, adv_end_time_tvbr, adv_end_time_val)

  -- dissect the reserved field
  local reserved_tvbr = tvbuf:range(40, 1)
  local reserved_val  = reserved_tvbr:le_uint()
  tree:add_le(retainer_information_fields.reserved, reserved_tvbr, reserved_val)

  -- dissect the nickname field
  local nickname_tvbr = tvbuf:range(41, 32)
  local nickname_val  = nickname_tvbr:string(ENC_UTF_8)
  tree:add(retainer_information_fields.nickname, nickname_tvbr, nickname_val)

  return len
end