From 6fdbafafbdc8c11569a0f79a06dbe6721c33a7a8 Mon Sep 17 00:00:00 2001 From: Byrth Date: Fri, 11 Sep 2026 15:06:10 -0400 Subject: [PATCH 1/2] fix: a bunch of small gearswap things --- addons/GearSwap/equip_processing.lua | 8 ++++---- addons/GearSwap/export.lua | 11 +++-------- addons/GearSwap/flow.lua | 8 ++++---- addons/GearSwap/gearswap.lua | 4 ++-- addons/GearSwap/helper_functions.lua | 8 ++++---- addons/GearSwap/packet_parsing.lua | 11 ++--------- addons/GearSwap/refresh.lua | 5 +---- addons/GearSwap/statics.lua | 2 +- addons/GearSwap/triggers.lua | 4 ++-- addons/GearSwap/user_functions.lua | 8 ++++---- 10 files changed, 27 insertions(+), 42 deletions(-) diff --git a/addons/GearSwap/equip_processing.lua b/addons/GearSwap/equip_processing.lua index bb6b861559..900aa4e1b4 100644 --- a/addons/GearSwap/equip_processing.lua +++ b/addons/GearSwap/equip_processing.lua @@ -160,14 +160,14 @@ function unpack_equip_list(equip_list,cur_equip) -- If the item is Rare, then even if the augments are wrong try to equip it anyway because you only have one equip_list[slot_name] = nil ret_list[slot_id] = {bag_id=bag.id,slot=item_tab.slot} - used_list = ret_list[slot_id] + used_list[slot_id] = ret_list[slot_id] break --else the piece specifies augments that don't match the current piece, so don't break and keep trying. end else equip_list[slot_name] = nil ret_list[slot_id] = {bag_id=bag.id,slot=item_tab.slot} - used_list = ret_list[slot_id] + used_list[slot_id] = ret_list[slot_id] break end end @@ -192,11 +192,11 @@ function unpack_equip_list(equip_list,cur_equip) else for __,slot_name in pairs(default_slot_map) do local name = expand_entry(equip_list[slot_name]) - if name ~= empty and name_match(item_id,name) then + if name ~= empty and name_match(item_tab.id,name) then if not res.items[item_tab.id].jobs[player.main_job_id] then equip_list[slot_name] = nil error_list[slot_name] = name..' (cannot be worn by this job)' - elseif not (res.items[item_tab.id].level<=player.jobs[player.main_job]) then + elseif not (res.items[item_tab.id].level<=player.jobs[res.jobs[player.main_job_id].ens]) then equip_list[slot_name] = nil error_list[slot_name] = name..' (job level is too low)' elseif not res.items[item_tab.id].races[player.race_id] then diff --git a/addons/GearSwap/export.lua b/addons/GearSwap/export.lua index 2e3f514b3b..a541167af3 100644 --- a/addons/GearSwap/export.lua +++ b/addons/GearSwap/export.lua @@ -65,7 +65,7 @@ function export_set(options) local compact = contains_any('compact') local bgwiki = contains_any('bgwiki') - if check_exclusive(compact) then + if check_exclusive(compact, bgwiki) then msg.addon_msg(123, 'Cannot export: "compact" and "bgwiki" are mutually exclusive.') return end @@ -128,7 +128,7 @@ function export_set(options) msg.addon_msg(123, buildmsg) - local item_list = T{} + local item_list, exported = T{}, nil if all_items then for i = 0, #res.bags do item_list:extend(get_item_list(items[res.bags[i].english:gsub(' ', ''):lower()])) @@ -326,7 +326,7 @@ function unpack_names(ret_tab,up,tab_level,unpacked_table,exported) elseif i=='name' and type(v) == 'string' then alt = up flag = true - elseif type(v) == 'string' and v~='augment' and v~= 'augments' and v~= 'priority' then + elseif type(v) == 'string' and v~='augment' and v~= 'augments' and v~= 'priority' and i ~= 'bag' and v ~= 'bag' then alt = i flag = true end @@ -343,11 +343,6 @@ function unpack_names(ret_tab,up,tab_level,unpacked_table,exported) end if aug_str ~= '' then unpacked_table[#unpacked_table].augments = aug_str end end - if tab_level.augment then - local aug_str = unpacked_table[#unpacked_table].augments or '' - if tab_level.augment ~= 'none' then aug_str = aug_str.."'"..augment:gsub("'","\\'").."'," end - if aug_str ~= '' then unpacked_table[#unpacked_table].augments = aug_str end - end exported[tempname:lower()] = true exported[v:lower()] = true end diff --git a/addons/GearSwap/flow.lua b/addons/GearSwap/flow.lua index 66ce34ded1..1dc929389e 100644 --- a/addons/GearSwap/flow.lua +++ b/addons/GearSwap/flow.lua @@ -65,7 +65,7 @@ function equip_sets(swap_type,ts,...) end end - logit('\n\n'..tostring(os.clock)..'(15) equip_sets: '..tostring(swap_type)) + logit('\n\n'..tostring(os.clock())..'(15) equip_sets: '..tostring(swap_type)) if val1 then if type(val1) == 'table' and val1.english then logit(' : '..val1.english) @@ -142,7 +142,7 @@ function equip_sets(swap_type,ts,...) failure_reason = 'KOed' end msg.debugging("Cannot change gear right now: "..tostring(failure_reason)) - logit('\n\n'..tostring(os.clock)..'(69) failure_reason: '..tostring(failure_reason)) + logit('\n\n'..tostring(os.clock())..'(69) failure_reason: '..tostring(failure_reason)) else local chunk_table = L{} for eq_slot_id,priority in priorities:it() do @@ -318,7 +318,7 @@ end function user_pcall(str,...) if user_env then if type(user_env[str]) == 'function' then - bool,err = pcall(user_env[str],...) + local bool,err = pcall(user_env[str],...) if not bool then error('\nGearSwap has detected an error in the user function '..str..':\n'..err) end elseif user_env[str] then msg.addon_msg(123,windower.to_shift_jis(tostring(str))..'() exists but is not a function') @@ -339,7 +339,7 @@ end function user_pcall2(str,...) if user_env then if type(user_env[str]) == 'function' then - bool,err = pcall(user_env[str],...) + local bool,err = pcall(user_env[str],...) if not bool then print('\nGearSwap has detected an error in the user function '..str..':\n'..err) end elseif user_env[str] then msg.addon_msg(123,windower.to_shift_jis(tostring(str))..'() exists but is not a function') diff --git a/addons/GearSwap/gearswap.lua b/addons/GearSwap/gearswap.lua index 9637894e23..29f8a702e8 100644 --- a/addons/GearSwap/gearswap.lua +++ b/addons/GearSwap/gearswap.lua @@ -114,7 +114,7 @@ require 'actions' packets = require 'packets' -- Resources Checks -if res.items and res.bags and res.slots and res.statuses and res.jobs and res.elements and res.skills and res.buffs and res.spells and res.job_abilities and res.weapon_skills and res.monster_skills and res.action_messages and res.skills and res.monstrosity and res.weather and res.moon_phases and res.races and res.monster_abilities then +if res.items and res.bags and res.slots and res.statuses and res.jobs and res.elements and res.skills and res.buffs and res.spells and res.job_abilities and res.weapon_skills and res.monster_skills and res.action_messages and res.monstrosity and res.weather and res.moon_phases and res.races and res.monster_abilities then else error('Missing resources!') end @@ -151,7 +151,7 @@ end) windower.register_event('addon command',function (...) windower.debug('addon command') - logit('\n\n'..tostring(os.clock)..table.concat({...},' ')) + logit('\n\n'..tostring(os.clock())..table.concat({...},' ')) local splitup = {...} if not splitup[1] then return end -- handles //gs diff --git a/addons/GearSwap/helper_functions.lua b/addons/GearSwap/helper_functions.lua index fb11baa195..13bfda9a5b 100644 --- a/addons/GearSwap/helper_functions.lua +++ b/addons/GearSwap/helper_functions.lua @@ -499,7 +499,7 @@ function assemble_use_item_packet(target_id,target_index,item_id) outstr = outstr..string.char( (target_id%256), math.floor(target_id/256)%256, math.floor( (target_id/65536)%256) , math.floor( (target_id/16777216)%256) ) outstr = outstr..string.char(0,0,0,0) outstr = outstr..string.char( (target_index%256), math.floor(target_index/256)%256) - inventory_index,bag_id = find_usable_item(item_id) + local inventory_index,bag_id = find_usable_item(item_id) if inventory_index then outstr = outstr..string.char(inventory_index%256)..string.char(0,bag_id,0,0,0) else @@ -551,7 +551,7 @@ function assemble_menu_item_packet(target_id,target_index,...) -- Inventory Index for the one unit for i,v in pairs(counts) do - inventory_index = find_inventory_item(i) + local inventory_index = find_inventory_item(i) if inventory_index then outstr = outstr..string.char(inventory_index%256) else @@ -678,7 +678,7 @@ function filter_pretarget(action) if not table.contains(available,action.id) then bool,err = false,"Unable to execute command. You do not have access to that job ability." end - elseif category == 25 and (not player.main_job_id == 23 or not windower.ffxi.get_mjob_data().species or + elseif category == 25 and (player.main_job_id ~= 23 or not windower.ffxi.get_mjob_data().species or not res.monstrosity[windower.ffxi.get_mjob_data().species] or not res.monstrosity[windower.ffxi.get_mjob_data().species].tp_moves[action.id] or not (res.monstrosity[windower.ffxi.get_mjob_data().species].tp_moves[action.id] <= player.main_job_level)) then -- Monstrosity filtering @@ -1008,7 +1008,7 @@ function get_spell(act) spell = copy_entry(res.job_abilities[75]) -- 'Elemental Seal' elseif msg_ID == 305 then spell = copy_entry(res.job_abilities[76]) -- 'Trick Attack' - elseif msg_ID == 311 or msg_ID == 311 then + elseif msg_ID == 311 or msg_ID == 312 then spell = copy_entry(res.job_abilities[79]) -- 'Cover' elseif msg_ID == 240 or msg_ID == 241 then spell = copy_entry(res.job_abilities[43]) -- 'Hide' diff --git a/addons/GearSwap/packet_parsing.lua b/addons/GearSwap/packet_parsing.lua index 568c35e2a8..0cadd9c6cb 100644 --- a/addons/GearSwap/packet_parsing.lua +++ b/addons/GearSwap/packet_parsing.lua @@ -120,7 +120,7 @@ parse.i[0x01B] = function (data) local tab = {} for slot_id,slot_name in pairs(default_slot_map) do local tf = (((enc%(2^(slot_id+1))) / 2^slot_id) >= 1) - if encumbrance_table[slot_id] and not tf and not_sent_out_equip[slot_name] and not disable_table[i] then + if encumbrance_table[slot_id] and not tf and not_sent_out_equip[slot_name] and not disable_table[slot_id] then tab[slot_name] = not_sent_out_equip[slot_name] not_sent_out_equip[slot_name] = nil end @@ -283,7 +283,6 @@ parse.i[0x050] = function (data) if chunk == data:sub(5,7) then -- Matched injected_equipment_registry[slot] = injected_equipment_registry[slot]:slice(ind+1) -- Eliminate current and all preceding packets if we get a match - matched = true return end --[[for i=9,9+4*(chunk:byte(5)-1),4 do -- The server replies to equipset packets with both single equip packets and equipset packets. @@ -307,7 +306,7 @@ function update_equipment() tab[default_slot_map[i]] = { bag_id = last:byte(3), slot = last:byte(1) == 0 and empty or last:byte(1), - } + } end end return tab @@ -615,12 +614,6 @@ parse.i[0x076] = function (data) end end local new_buffs = convert_buff_list(_ExtraPartyData.buffs[index]) - if index == 1464 then - local newbuff_count = 0 - for _,v in pairs(new_buffs) do - newbuff_count = newbuff_count + 1 - end - end if cur_player and cur_player.buffactive and not gearswap_disabled and user_env and type(user_env['party_buff_change']) == 'function' then -- Make sure the character existed before (with a buffactive list) - Avoids zoning. diff --git a/addons/GearSwap/refresh.lua b/addons/GearSwap/refresh.lua index 0242cf6622..82cc6e3f86 100644 --- a/addons/GearSwap/refresh.lua +++ b/addons/GearSwap/refresh.lua @@ -243,7 +243,6 @@ function refresh_player(dt,user_event_flag) pet.claim_id = nil pet.is_npc = nil pet.isvalid = true - if pet.tp then pet.tp = pet.tp/10 end if avatar_element[pet.name] then pet.element = res.elements[avatar_element[pet.name]][language] @@ -346,8 +345,6 @@ function refresh_player(dt,user_event_flag) player.subtarget = target_complete(windower.ffxi.get_mob_by_target('st')) player.last_subtarget = target_complete(windower.ffxi.get_mob_by_target('lastst')) - - table.reassign(fellow,target_complete(windower.ffxi.get_mob_by_target(''))) if fellow.name then fellow.isvalid = true @@ -622,7 +619,7 @@ end ---- It also allows one to check for the alternate spelling of an item. ----------------------------------------------------------------------------------- function refresh_item_list(itemlist) - retarr = make_user_table() + local retarr = make_user_table() for i,v in pairs(itemlist) do if type(v) == 'table' and v.id and v.id ~= 0 then -- If we don't already have the primary item name in the table, add it. diff --git a/addons/GearSwap/statics.lua b/addons/GearSwap/statics.lua index e7c997e444..f6678c9abb 100644 --- a/addons/GearSwap/statics.lua +++ b/addons/GearSwap/statics.lua @@ -345,7 +345,7 @@ region_to_zone_map = { [14] = S{126,127,157,158,179,184}, [15] = S{121,122,153,154,202,251}, [16] = S{114,125,168,208,209,247}, - [17] = S{113,128.174,201,212}, + [17] = S{113,128,174,201,212}, [18] = S{123,176,250,252}, [19] = S{124,159,160,163,205,207,211}, [20] = S{130,177,178,180,181}, diff --git a/addons/GearSwap/triggers.lua b/addons/GearSwap/triggers.lua index 9b423dafbd..defc0298b7 100644 --- a/addons/GearSwap/triggers.lua +++ b/addons/GearSwap/triggers.lua @@ -218,7 +218,7 @@ parse.i[0x028] = function (data) local spell = get_spell(act) -- if not spell_res or (spell.english ~= spell_res.english) then print('Did not match.',spell.english,spell_res) end - if spell then logit('\n\n'..tostring(os.clock)..'(178) Event Action: '..tostring(spell[language])..' '..tostring(act.category)) + if spell then logit('\n\n'..tostring(os.clock())..'(178) Event Action: '..tostring(spell[language])..' '..tostring(act.category)) else logit('\n\nNil spell detected') end if spell and spell[language] then @@ -341,7 +341,7 @@ parse.i[0x029] = function (data) end if unable_to_use:contains(arr.message_id) then - logit('\n\n'..tostring(os.clock)..'(195) Event Action Message: '..tostring(message_id)..' Interrupt') + logit('\n\n'..tostring(os.clock())..'(195) Event Action Message: '..tostring(arr.message_id)..' Interrupt') local ts,tab = command_registry:find_by_time() if tab and tab.spell then diff --git a/addons/GearSwap/user_functions.lua b/addons/GearSwap/user_functions.lua index 6bb8a1712c..06d7cc262e 100644 --- a/addons/GearSwap/user_functions.lua +++ b/addons/GearSwap/user_functions.lua @@ -46,7 +46,7 @@ function debug_mode(boolean) elseif boolean == nil then _settings.debug_mode = true else - error('\nGearSwap: show_swaps() was passed an invalid value ('..tostring(boolean)..'). (true/no value/nil=on, false=off)', 2) + error('\nGearSwap: debug_mode() was passed an invalid value ('..tostring(boolean)..'). (true/no value/nil=on, false=off)', 2) end end @@ -245,7 +245,7 @@ function print_set(set,title) end function send_cmd_user(command) - if string.byte(1) ~= 0x40 then + if command:byte(1) ~= 0x40 then command='@'..command end windower.send_command(command) @@ -355,7 +355,7 @@ function user_midaction(bool) for i,v in pairs(command_registry) do if type(v) == 'table' and v.midaction then - return true, v.spell + return true, v.spell, i end end @@ -366,7 +366,7 @@ function user_pet_midaction(bool) if bool == false then for i,v in pairs(command_registry) do if v.pet_midaction then - command_registry.pet_midaction = false + command_registry[i].pet_midaction = false end end end From c87a0010fd48381b1e5140ffb901bb5b1801996e Mon Sep 17 00:00:00 2001 From: Byrth Date: Fri, 11 Sep 2026 20:55:19 -0400 Subject: [PATCH 2/2] fix: add another not-nil check --- addons/GearSwap/equip_processing.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/GearSwap/equip_processing.lua b/addons/GearSwap/equip_processing.lua index 900aa4e1b4..eb551017a6 100644 --- a/addons/GearSwap/equip_processing.lua +++ b/addons/GearSwap/equip_processing.lua @@ -192,7 +192,7 @@ function unpack_equip_list(equip_list,cur_equip) else for __,slot_name in pairs(default_slot_map) do local name = expand_entry(equip_list[slot_name]) - if name ~= empty and name_match(item_tab.id,name) then + if name and name ~= empty and name_match(item_tab.id,name) then if not res.items[item_tab.id].jobs[player.main_job_id] then equip_list[slot_name] = nil error_list[slot_name] = name..' (cannot be worn by this job)'