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

local db = require('ffxiv_db')
local ffxiv_ipc_fate_info = Proto("ffxiv_ipc_fate_info", "FFXIV-IPC Fate Info")

local fate_info_fields = {
  fate       = ProtoField.uint16("ffxiv_ipc_fate_info.fate", "Fate", base.DEC, db.Fate),
  unknown0   = ProtoField.uint32("ffxiv_ipc_fate_info.unknown0", "Unknown0", base.DEC),
  unknown1   = ProtoField.uint32("ffxiv_ipc_fate_info.unknown1", "Unknown1", base.DEC),
  start_time = ProtoField.uint32("ffxiv_ipc_fate_info.start_time", "StartTime", base.DEC),
  unknown3   = ProtoField.uint32("ffxiv_ipc_fate_info.unknown3", "Unknown3", base.DEC),
  duration   = ProtoField.uint32("ffxiv_ipc_fate_info.duration", "Duration", base.DEC),
  unknown5   = ProtoField.float("ffxiv_ipc_fate_info.unknown5", "Unknown5", base.DEC),
}

ffxiv_ipc_fate_info.fields = fate_info_fields

function ffxiv_ipc_fate_info.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_fate_info, tvbuf)
  pktinfo.cols.info:set("Fate Info")

  local len = tvbuf:len()

  -- dissect the fate field
  local fate_tvbr = tvbuf:range(0, 2)
  local fate_val  = fate_tvbr:le_uint()
  tree:add_le(fate_info_fields.fate, fate_tvbr, fate_val)

  local fate_display = ", Fate: " .. (db.Fate[fate_val] or "(unknown)")
  pktinfo.cols.info:append(fate_display)
  tree:append_text(fate_display)

  -- dissect the unknown0 field
  local unknown0_tvbr = tvbuf:range(2, 2)
  local unknown0_val  = unknown0_tvbr:le_uint()
  tree:add_le(fate_info_fields.unknown0, unknown0_tvbr, unknown0_val)

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

  -- dissect the start_time field
  local start_time_tvbr = tvbuf:range(8, 4)
  local start_time_val  = start_time_tvbr:le_uint()
  tree:add_le(fate_info_fields.start_time, start_time_tvbr, start_time_val)

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

  -- dissect the duration field
  local duration_tvbr = tvbuf:range(16, 4)
  local duration_val  = duration_tvbr:le_uint()
  tree:add_le(fate_info_fields.duration, duration_tvbr, duration_val)

  -- dissect the unknown5 field
  local unknown5_tvbr = tvbuf:range(20, 4)
  local unknown5_val  = unknown5_tvbr:le_float()
  tree:add_le(fate_info_fields.unknown5, unknown5_tvbr, unknown5_val)

  return len
end