Skip to content

[GearSwap] equip_sets_exit pretarget cleanup part 2 - #2586

Merged
lili-ffxi merged 1 commit into
Windower:devfrom
Zirk40:zirk-flow-cleanup-2
Oct 24, 2026
Merged

lili-ffxi merged 1 commit into
Windower:devfrom
Zirk40:zirk-flow-cleanup-2

Conversation

@Zirk40

@Zirk40 Zirk40 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

The current code path is a bit tangled and not cohesive, as demonstrated by the "This case should not be hittable - 2" being hit for any item trades where the target is greater than 6 yalms away, which is a very real scenario.

The overall code path should be pretty straightforward, either we succeeded in assembling a proposed packet and will proceed into the precast event, or we didn't get a proposed packet and will do some cleanup before bailing out and letting the client handle the action.

Assigning nil to storedcommand is not necessary as part of cleanup, as any subsequent outgoing text trigger is guaranteed to assign a new value to storedcommand before storedcommand is ever used, so it is not possible for a stale value to persist from a previous trigger and be utilized.

The same cleanup steps are added to outgoing text for consistency.

We shouldn't be doing the val1.target.name check because filter_precast already validates the target by checking .target.id and .target.index, so inside filter_precast code block is where we have a valid target and outside filter_precast code block is where we don't have a valid target, we don't need to check for valid target in multiple places.

The debug message about "Change target was used to pick an invalid target" was modified because that debug message lies most of the time, most often change target was not exercised and the original command contained without any target selected, for example.

In order for an action to be a trade, the item must be in the inventory with a status of 0, so this find_inventory_item check should be baked into the trade determination. Before this commit, it was possible to have an item action_type labeled as a trade, but we still end up assembling an item use packet instead of a trade packet if the find_inventory_item check failed but the find_usable_item check succeeded. With this commit, we only set the action_type as trade if it really is a trade.

As part of this commit's untangling of things, GearSwap will no longer fake out the "Target out of range" message for out of range trades, and will instead do the proper thing of letting the client handle that action and print out a native out of range message, along with the native feedback of echoing the input command that produced the out of range message. Outgoing text is also updated to no longer fake out these out of range trades to remain consistent.

The current code path is a bit tangled and not cohesive, as demonstrated by
the "This case should not be hittable - 2" being hit for any item trades where
the target is greater than 6 yalms away, which is a very real scenario.

The overall code path should be pretty straightforward, either we succeeded in
assembling a proposed packet and will proceed into the precast event, or we
didn't get a proposed packet and will do some cleanup before bailing out and
letting the client handle the action.

Assigning nil to storedcommand is not necessary as part of cleanup, as any
subsequent outgoing text trigger is guaranteed to assign a new value to
storedcommand before storedcommand is ever used, so it is not possible for a
stale value to persist from a previous trigger and be utilized.

The same cleanup steps are added to outgoing text for consistency.

We shouldn't be doing the val1.target.name check because filter_precast
already validates the target by checking .target.id and .target.index, so
inside filter_precast code block is where we have a valid target and outside
filter_precast code block is where we don't have a valid target, we don't need
to check for valid target in multiple places.

The debug message about "Change target was used to pick an invalid target" was
modified because that debug message lies most of the time, most often change
target was not exercised and the original command contained <t> without any
target selected, for example.

In order for an action to be a trade, the item must be in the inventory with a
status of 0, so this find_inventory_item check should be baked into
the trade determination. Before this commit, it was possible to have an item
action_type labeled as a trade, but we still end up assembling an item use
packet instead of a trade packet if the find_inventory_item check failed but
the find_usable_item check succeeded. With this commit, we only set the
action_type as trade if it really is a trade.

As part of this commit's untangling of things, GearSwap will no longer fake
out the "Target out of range" message for out of range trades, and will
instead do the proper thing of letting the client handle that action and print
out a native out of range message, along with the native feedback of echoing
the input command that produced the out of range message. Outgoing text is
also updated to no longer fake out these out of range trades to remain
consistent.
@lili-ffxi
lili-ffxi merged commit 719072a into Windower:dev Oct 24, 2026
@Zirk40
Zirk40 deleted the zirk-flow-cleanup-2 branch October 24, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants