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

local db = require('ffxiv_db')
local enum = require('ffxiv_enum')
local ffxiv_ipc_content_finder_notify = Proto("ffxiv_ipc_content_finder_notify", "FFXIV-IPC Content Finder Notify")

local content_finder_notify_fields = {
  type                           = ProtoField.uint8("ffxiv_ipc_content_finder_notify.type", "Type", base.DEC, enum.reverse.match_event_type),
  class_job                      = ProtoField.uint8("ffxiv_ipc_content_finder_notify.class_job", "ClassJob", base.DEC, db.ClassJob),
  unknown1                       = ProtoField.uint16("ffxiv_ipc_content_finder_notify.unknown1", "Unknown1", base.DEC),
  unknown2                       = ProtoField.uint16("ffxiv_ipc_content_finder_notify.unknown2", "Unknown2", base.DEC),
  unknown3                       = ProtoField.uint16("ffxiv_ipc_content_finder_notify.unknown3", "Unknown3", base.DEC),
  roulette                       = ProtoField.uint16("ffxiv_ipc_content_finder_notify.roulette", "Roulette", base.DEC, db.ContentRoulette),
  unknown5                       = ProtoField.uint16("ffxiv_ipc_content_finder_notify.unknown5", "Unknown5", base.DEC),
}

ffxiv_ipc_content_finder_notify.fields = content_finder_notify_fields

function ffxiv_ipc_content_finder_notify.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_content_finder_notify, tvbuf)
  pktinfo.cols.info:set("Content Finder Notify")

  local len = tvbuf:len()

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

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

  -- dissect the unknown1 field
  local unknown1_tvbr = tvbuf:range(2, 2)
  local unknown1_val  = unknown1_tvbr:le_uint()
  tree:add_le(content_finder_notify_fields.unknown1, unknown1_tvbr, unknown1_val)

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

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

  -- dissect the roulette field
  local roulette_tvbr = tvbuf:range(8, 2)
  local roulette_val  = roulette_tvbr:le_uint()
  tree:add_le(content_finder_notify_fields.roulette, roulette_tvbr, roulette_val)

  -- dissect the unknown5 field
  local unknown5_tvbr = tvbuf:range(10, 2)
  local unknown5_val  = unknown5_tvbr:le_uint()
  tree:add_le(content_finder_notify_fields.unknown5, unknown5_tvbr, unknown5_val)

  -- dissect content_finder_notify_instance
  local content_finder_notify_instance_dissector = Dissector.get('ffxiv_ipc_content_finder_notify_instance')
  local content_finder_notify_instance_pos = 12
  local content_finder_notify_instance_len = 4
  local content_finder_notify_instance_count = 5

  while content_finder_notify_instance_pos + content_finder_notify_instance_len <= len do
    local content_finder_notify_instance_tvbr = tvbuf:range(content_finder_notify_instance_pos, 4)
    content_finder_notify_instance_dissector:call(content_finder_notify_instance_tvbr:tvb(), pktinfo, root)
    content_finder_notify_instance_pos = content_finder_notify_instance_pos + content_finder_notify_instance_len
    content_finder_notify_instance_count = content_finder_notify_instance_count - 1
    if content_finder_notify_instance_count <= 0 then
      break
    end
  end

  return len
end