Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct improper ID range check #2110

Merged
merged 2 commits into from
Dec 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions addons/GearSwap/targets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,33 @@

function valid_target(targ)
local spelltarget = {}

local spell_targ
if pass_through_targs[targ] then

if targ and pass_through_targs[targ] then
local j = windower.ffxi.get_mob_by_target(targ)

if j then spelltarget = target_complete(j) end

spelltarget.raw = targ
return targ, spelltarget
elseif targ and tonumber(targ) and tonumber(targ) > 255 then
local j = windower.ffxi.get_mob_by_id(tonumber(targ))

if j then spelltarget = target_complete(j) end

if j then
spelltarget = target_complete(j)
end
spelltarget.raw = targ
return targ, spelltarget
elseif targ and not tonumber(targ) and targ ~= '' then
local mob_array = windower.ffxi.get_mob_array()
for i,v in pairs(mob_array) do
if v.name:lower()==targ:lower() and (not v.is_npc or v.spawn_type == 14) then
spelltarget = target_complete(v)
spelltarget.raw = targ
return targ, spelltarget
elseif targ then
local id = tonumber(targ)
if id then
local j = windower.ffxi.get_mob_by_id(id)
if j then
spelltarget = target_complete(j)
end
spelltarget.raw = targ
return targ, spelltarget
elseif targ ~= '' then
local targ_name = targ:lower()
local mob_array = windower.ffxi.get_mob_array()
for i,v in pairs(mob_array) do
if v.name:lower()==targ_name and (not v.is_npc or v.spawn_type == 14) then
spelltarget = target_complete(v)
spelltarget.raw = targ
return targ, spelltarget
end
end
end
end
Expand Down Expand Up @@ -146,4 +150,4 @@ function target_type_check(spell)

if spell.targets[temptype] then return true end
return false
end
end