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

local ffxiv_ipc_effect = Proto("ffxiv_ipc_effect", "FFXIV-IPC Effect")

local effect_fields = {
  padding_6_a0     = ProtoField.uint16("ffxiv_ipc_effect.padding_6_a0", "padding_6A0", base.DEC),
  padding_6_a1     = ProtoField.uint16("ffxiv_ipc_effect.padding_6_a1", "padding_6A1", base.DEC),
  padding_6_a2     = ProtoField.uint16("ffxiv_ipc_effect.padding_6_a2", "padding_6A2", base.DEC),
  effect_target_id = ProtoField.uint32("ffxiv_ipc_effect.effect_target_id", "effectTargetId", base.HEX),
  effect_flags     = ProtoField.uint32("ffxiv_ipc_effect.effect_flags", "effectFlags", base.DEC),
  padding_78       = ProtoField.uint32("ffxiv_ipc_effect.padding_78", "padding_78", base.DEC),
}

ffxiv_ipc_effect.fields = effect_fields

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

  local len = tvbuf:len()

  -- dissect effect_header
  local effect_header_dissector = Dissector.get('ffxiv_ipc_effect_header')
  local effect_header_pos = 0
  local effect_header_len = 42
  local effect_header_count = 1

  while effect_header_pos + effect_header_len <= len do
    local effect_header_tvbr = tvbuf:range(effect_header_pos, 42)
    effect_header_dissector:call(effect_header_tvbr:tvb(), pktinfo, root)
    effect_header_pos = effect_header_pos + effect_header_len
    effect_header_count = effect_header_count - 1
    if effect_header_count <= 0 then
      break
    end
  end

  -- dissect effect_entry
  local effect_entry_dissector = Dissector.get('ffxiv_ipc_effect_entry')
  local effect_entry_pos = 42
  local effect_entry_len = 8
  local effect_entry_count = 8

  while effect_entry_pos + effect_entry_len <= len do
    local effect_entry_tvbr = tvbuf:range(effect_entry_pos, 8)
    effect_entry_dissector:call(effect_entry_tvbr:tvb(), pktinfo, root)
    effect_entry_pos = effect_entry_pos + effect_entry_len
    effect_entry_count = effect_entry_count - 1
    if effect_entry_count <= 0 then
      break
    end
  end

  -- dissect the padding_6_a0 field
  local padding_6_a0_tvbr = tvbuf:range(106, 2)
  local padding_6_a0_val  = padding_6_a0_tvbr:le_uint()
  tree:add_le(effect_fields.padding_6_a0, padding_6_a0_tvbr, padding_6_a0_val)

  -- dissect the padding_6_a1 field
  local padding_6_a1_tvbr = tvbuf:range(108, 2)
  local padding_6_a1_val  = padding_6_a1_tvbr:le_uint()
  tree:add_le(effect_fields.padding_6_a1, padding_6_a1_tvbr, padding_6_a1_val)

  -- dissect the padding_6_a2 field
  local padding_6_a2_tvbr = tvbuf:range(110, 2)
  local padding_6_a2_val  = padding_6_a2_tvbr:le_uint()
  tree:add_le(effect_fields.padding_6_a2, padding_6_a2_tvbr, padding_6_a2_val)

  -- dissect the effect_target_id field
  local effect_target_id_tvbr = tvbuf:range(112, 4)
  local effect_target_id_val  = effect_target_id_tvbr:le_uint()
  tree:add_le(effect_fields.effect_target_id, effect_target_id_tvbr, effect_target_id_val)

  -- dissect the effect_flags field
  local effect_flags_tvbr = tvbuf:range(116, 4)
  local effect_flags_val  = effect_flags_tvbr:le_uint()
  tree:add_le(effect_fields.effect_flags, effect_flags_tvbr, effect_flags_val)

  -- dissect the padding_78 field
  local padding_78_tvbr = tvbuf:range(120, 4)
  local padding_78_val  = padding_78_tvbr:le_uint()
  tree:add_le(effect_fields.padding_78, padding_78_tvbr, padding_78_val)

  return len
end