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

local db = require('ffxiv_db')
local enum = require('ffxiv_enum')
local ffxiv_ipc_currency_crystal_info = Proto("ffxiv_ipc_currency_crystal_info", "FFXIV-IPC CurrencyCrystalInfo")

local currency_crystal_info_fields = {
  container_sequence = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.container_sequence", "containerSequence", base.DEC),
  container_id       = ProtoField.uint16("ffxiv_ipc_currency_crystal_info.container_id", "containerId", base.DEC, enum.reverse.item_location),
  slot               = ProtoField.uint16("ffxiv_ipc_currency_crystal_info.slot", "slot", base.DEC),
  quantity           = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.quantity", "quantity", base.DEC),
  unknown            = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.unknown", "unknown", base.DEC),
  catalog_id         = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.catalog_id", "catalogId", base.DEC, db.Item),
  unknown1           = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.unknown1", "unknown1", base.DEC),
  unknown2           = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.unknown2", "unknown2", base.DEC),
  unknown3           = ProtoField.uint32("ffxiv_ipc_currency_crystal_info.unknown3", "unknown3", base.DEC),
}

ffxiv_ipc_currency_crystal_info.fields = currency_crystal_info_fields

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

  local len = tvbuf:len()

  -- dissect the container_sequence field
  local container_sequence_tvbr = tvbuf:range(0, 4)
  local container_sequence_val  = container_sequence_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.container_sequence, container_sequence_tvbr, container_sequence_val)

  -- dissect the container_id field
  local container_id_tvbr = tvbuf:range(4, 2)
  local container_id_val  = container_id_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.container_id, container_id_tvbr, container_id_val)

  local container_id_display = ", containerId: " .. (enum.reverse.item_location[container_id_val] or "(unknown)")
  pktinfo.cols.info:append(container_id_display)
  tree:append_text(container_id_display)

  -- dissect the slot field
  local slot_tvbr = tvbuf:range(6, 2)
  local slot_val  = slot_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.slot, slot_tvbr, slot_val)

  -- dissect the quantity field
  local quantity_tvbr = tvbuf:range(8, 4)
  local quantity_val  = quantity_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.quantity, quantity_tvbr, quantity_val)

  local quantity_display = ", quantity: " .. quantity_val
  pktinfo.cols.info:append(quantity_display)
  tree:append_text(quantity_display)

  -- dissect the unknown field
  local unknown_tvbr = tvbuf:range(12, 4)
  local unknown_val  = unknown_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.unknown, unknown_tvbr, unknown_val)

  -- dissect the catalog_id field
  local catalog_id_tvbr = tvbuf:range(16, 4)
  local catalog_id_val  = catalog_id_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.catalog_id, catalog_id_tvbr, catalog_id_val)

  local catalog_id_display = ", catalogId: " .. (db.Item[catalog_id_val] or "(unknown)")
  pktinfo.cols.info:append(catalog_id_display)
  tree:append_text(catalog_id_display)

  -- dissect the unknown1 field
  local unknown1_tvbr = tvbuf:range(20, 4)
  local unknown1_val  = unknown1_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.unknown1, unknown1_tvbr, unknown1_val)

  -- dissect the unknown2 field
  local unknown2_tvbr = tvbuf:range(24, 4)
  local unknown2_val  = unknown2_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.unknown2, unknown2_tvbr, unknown2_val)

  -- dissect the unknown3 field
  local unknown3_tvbr = tvbuf:range(28, 4)
  local unknown3_val  = unknown3_tvbr:le_uint()
  tree:add_le(currency_crystal_info_fields.unknown3, unknown3_tvbr, unknown3_val)

  return len
end