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

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

local effect_header_fields = {
  animation_target_id = ProtoField.uint32("ffxiv_ipc_effect_header.animation_target_id", "animationTargetId", base.DEC),
  unknown             = ProtoField.uint32("ffxiv_ipc_effect_header.unknown", "unknown", base.DEC),
  action              = ProtoField.uint32("ffxiv_ipc_effect_header.action", "Action", base.DEC, db.Action),
  sequence            = ProtoField.uint32("ffxiv_ipc_effect_header.sequence", "sequence", base.DEC),
  animation_lock_time = ProtoField.float("ffxiv_ipc_effect_header.animation_lock_time", "animationLockTime", base.DEC),
  some_target_id      = ProtoField.uint32("ffxiv_ipc_effect_header.some_target_id", "someTargetId", base.HEX),
  source_sequence     = ProtoField.uint16("ffxiv_ipc_effect_header.source_sequence", "sourceSequence", base.DEC),
  rotation            = ProtoField.uint16("ffxiv_ipc_effect_header.rotation", "rotation", base.DEC),
  action_animation_id = ProtoField.uint16("ffxiv_ipc_effect_header.action_animation_id", "actionAnimationId", base.DEC),
  variation           = ProtoField.uint8("ffxiv_ipc_effect_header.variation", "variation", base.DEC),
  effect_display_type = ProtoField.uint8("ffxiv_ipc_effect_header.effect_display_type", "effectDisplayType", base.DEC, enum.reverse.action_effect_display_type),
  unknown20           = ProtoField.uint8("ffxiv_ipc_effect_header.unknown20", "unknown20", base.DEC),
  effect_count        = ProtoField.uint8("ffxiv_ipc_effect_header.effect_count", "effectCount", base.DEC),
  padding_21          = ProtoField.uint16("ffxiv_ipc_effect_header.padding_21", "padding_21", base.DEC),
  padding_220         = ProtoField.uint16("ffxiv_ipc_effect_header.padding_220", "padding_220", base.DEC),
  padding_221         = ProtoField.uint16("ffxiv_ipc_effect_header.padding_221", "padding_221", base.DEC),
  padding_222         = ProtoField.uint16("ffxiv_ipc_effect_header.padding_222", "padding_222", base.DEC),
}

ffxiv_ipc_effect_header.fields = effect_header_fields

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

  local len = tvbuf:len()

  -- dissect the animation_target_id field
  local animation_target_id_tvbr = tvbuf:range(0, 4)
  local animation_target_id_val  = animation_target_id_tvbr:le_uint()
  tree:add_le(effect_header_fields.animation_target_id, animation_target_id_tvbr, animation_target_id_val)

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

  -- dissect the action field
  local action_tvbr = tvbuf:range(8, 4)
  local action_val  = action_tvbr:le_uint()
  tree:add_le(effect_header_fields.action, action_tvbr, action_val)

  local action_display = ", Action: " .. (db.Action[action_val] or "(unknown)")
  pktinfo.cols.info:append(action_display)
  tree:append_text(action_display)

  -- dissect the sequence field
  local sequence_tvbr = tvbuf:range(12, 4)
  local sequence_val  = sequence_tvbr:le_uint()
  tree:add_le(effect_header_fields.sequence, sequence_tvbr, sequence_val)

  -- dissect the animation_lock_time field
  local animation_lock_time_tvbr = tvbuf:range(16, 4)
  local animation_lock_time_val  = animation_lock_time_tvbr:le_float()
  tree:add_le(effect_header_fields.animation_lock_time, animation_lock_time_tvbr, animation_lock_time_val)

  -- dissect the some_target_id field
  local some_target_id_tvbr = tvbuf:range(20, 4)
  local some_target_id_val  = some_target_id_tvbr:le_uint()
  tree:add_le(effect_header_fields.some_target_id, some_target_id_tvbr, some_target_id_val)

  -- dissect the source_sequence field
  local source_sequence_tvbr = tvbuf:range(24, 2)
  local source_sequence_val  = source_sequence_tvbr:le_uint()
  tree:add_le(effect_header_fields.source_sequence, source_sequence_tvbr, source_sequence_val)

  -- dissect the rotation field
  local rotation_tvbr = tvbuf:range(26, 2)
  local rotation_val  = rotation_tvbr:le_uint()
  tree:add_le(effect_header_fields.rotation, rotation_tvbr, rotation_val)

  -- dissect the action_animation_id field
  local action_animation_id_tvbr = tvbuf:range(28, 2)
  local action_animation_id_val  = action_animation_id_tvbr:le_uint()
  tree:add_le(effect_header_fields.action_animation_id, action_animation_id_tvbr, action_animation_id_val)

  -- dissect the variation field
  local variation_tvbr = tvbuf:range(30, 1)
  local variation_val  = variation_tvbr:le_uint()
  tree:add_le(effect_header_fields.variation, variation_tvbr, variation_val)

  -- dissect the effect_display_type field
  local effect_display_type_tvbr = tvbuf:range(31, 1)
  local effect_display_type_val  = effect_display_type_tvbr:le_uint()
  tree:add_le(effect_header_fields.effect_display_type, effect_display_type_tvbr, effect_display_type_val)

  -- dissect the unknown20 field
  local unknown20_tvbr = tvbuf:range(32, 1)
  local unknown20_val  = unknown20_tvbr:le_uint()
  tree:add_le(effect_header_fields.unknown20, unknown20_tvbr, unknown20_val)

  -- dissect the effect_count field
  local effect_count_tvbr = tvbuf:range(33, 1)
  local effect_count_val  = effect_count_tvbr:le_uint()
  tree:add_le(effect_header_fields.effect_count, effect_count_tvbr, effect_count_val)

  -- dissect the padding_21 field
  local padding_21_tvbr = tvbuf:range(34, 2)
  local padding_21_val  = padding_21_tvbr:le_uint()
  tree:add_le(effect_header_fields.padding_21, padding_21_tvbr, padding_21_val)

  -- dissect the padding_220 field
  local padding_220_tvbr = tvbuf:range(36, 2)
  local padding_220_val  = padding_220_tvbr:le_uint()
  tree:add_le(effect_header_fields.padding_220, padding_220_tvbr, padding_220_val)

  -- dissect the padding_221 field
  local padding_221_tvbr = tvbuf:range(38, 2)
  local padding_221_val  = padding_221_tvbr:le_uint()
  tree:add_le(effect_header_fields.padding_221, padding_221_tvbr, padding_221_val)

  -- dissect the padding_222 field
  local padding_222_tvbr = tvbuf:range(40, 2)
  local padding_222_val  = padding_222_tvbr:le_uint()
  tree:add_le(effect_header_fields.padding_222, padding_222_tvbr, padding_222_val)

  return len
end