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

local enum = require('ffxiv_enum')
local label_param1_category = {
  [310] = "Marker",
}
local ffxiv_ipc_actor_control_target = Proto("ffxiv_ipc_actor_control_target", "FFXIV-IPC Actor Control Target")

local actor_control_target_fields = {
  category  = ProtoField.uint16("ffxiv_ipc_actor_control_target.category", "Category", base.DEC, enum.reverse.actor_control144_category),
  padding   = ProtoField.uint16("ffxiv_ipc_actor_control_target.padding", "padding", base.DEC),
  param1    = ProtoField.uint32("ffxiv_ipc_actor_control_target.param1", "param1", base.DEC),
  param2    = ProtoField.uint32("ffxiv_ipc_actor_control_target.param2", "param2", base.DEC),
  param3    = ProtoField.uint32("ffxiv_ipc_actor_control_target.param3", "param3", base.DEC),
  param4    = ProtoField.uint32("ffxiv_ipc_actor_control_target.param4", "param4", base.DEC),
  padding1  = ProtoField.uint32("ffxiv_ipc_actor_control_target.padding1", "padding1", base.DEC),
  target_id = ProtoField.uint64("ffxiv_ipc_actor_control_target.target_id", "targetId", base.DEC),
}

ffxiv_ipc_actor_control_target.fields = actor_control_target_fields

function ffxiv_ipc_actor_control_target.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_actor_control_target, tvbuf)
  pktinfo.cols.info:set("Actor Control Target")

  local len = tvbuf:len()

  -- dissect the category field
  local category_tvbr = tvbuf:range(0, 2)
  local category_val  = category_tvbr:le_uint()
  tree:add_le(actor_control_target_fields.category, category_tvbr, category_val)

  -- dissect the padding field
  local padding_tvbr = tvbuf:range(2, 2)
  local padding_val  = padding_tvbr:le_uint()
  tree:add_le(actor_control_target_fields.padding, padding_tvbr, padding_val)

  -- dissect the param1 field
  local param1_tvbr = tvbuf:range(4, 4)
  local param1_val  = param1_tvbr:le_uint()
  local param1_label_key = "param1"
  local param1_label_val = param1_val
  if category_val == 310 then
    param1_label_key = "Marker"
    param1_label_val = (enum.reverse.actor_control144_marker[param1_val] or "Unknown") .. " (" .. param1_val .. ")"
  end
  tree:add_le(actor_control_target_fields.param1, param1_tvbr, param1_val, param1_label_key .. ": " .. param1_label_val)

  -- dissect the param2 field
  local param2_tvbr = tvbuf:range(8, 4)
  local param2_val  = param2_tvbr:le_uint()
  tree:add_le(actor_control_target_fields.param2, param2_tvbr, param2_val)

  -- dissect the param3 field
  local param3_tvbr = tvbuf:range(12, 4)
  local param3_val  = param3_tvbr:le_uint()
  tree:add_le(actor_control_target_fields.param3, param3_tvbr, param3_val)

  -- dissect the param4 field
  local param4_tvbr = tvbuf:range(16, 4)
  local param4_val  = param4_tvbr:le_uint()
  tree:add_le(actor_control_target_fields.param4, param4_tvbr, param4_val)

  -- dissect the padding1 field
  local padding1_tvbr = tvbuf:range(20, 4)
  local padding1_val  = padding1_tvbr:le_uint()
  tree:add_le(actor_control_target_fields.padding1, padding1_tvbr, padding1_val)

  -- dissect the target_id field
  local target_id_tvbr = tvbuf:range(24, 8)
  local target_id_val  = target_id_tvbr:le_uint64()
  tree:add_le(actor_control_target_fields.target_id, target_id_tvbr, target_id_val)

  return len
end